Repository navigation
feat(annotation): add image-aware pane and original-pixel drawing #2290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
giswqs
merged 19 commits into
opengeos:main
from
robmarkcole:feat/annotation-image-pane
Nov 21, 2026
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e0a61c2
feat(annotation): add image-aware pane and original-pixel drawing
robmarkcole 4f88e4c
Make annotation details optional and suggest image-based export names
robmarkcole 80b2d27
Fix annotation selection, cancellation and command search
robmarkcole 7433506
Verify image-grid source revisions and show search results
robmarkcole 4245edd
Merge upstream main into annotation image pane
robmarkcole aa5512b
Cover linked-image conversions and clarify revision recovery
robmarkcole 8e38c3d
Fix converted-image grid errors and unavailable image recovery
robmarkcole c9f0889
Harden image revision checks and stale pixel contexts
robmarkcole a0d6b23
Clarify original-grid recovery for non-TIFF images
robmarkcole 7ba682b
Preserve pixel mode across context changes and prepare scripted grid …
robmarkcole d2ebb4a
Clarify GeoTIFF load recovery and surface refused shape gestures
robmarkcole 8d155ca
Bind scripted grid queries to accepted raster tool outputs
robmarkcole 62c02a1
Test atomic script rollback and explain cancelled shape previews
robmarkcole 0eb681e
Propagate rollback test preparation errors in helper
robmarkcole 8712d19
Validate construction frame CRS before accepting image grids
robmarkcole 58b4279
Merge upstream main into annotation image pane branch
robmarkcole 84500c8
Merge branch 'main' into feat/annotation-image-pane
robmarkcole 5eaf0b1
Merge remote-tracking branch 'origin/main' into pr-2290
giswqs 7e32ecb
Address review feedback
giswqs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| //! Runtime identity of the local GeoTIFF used to decode a displayed raster. | ||
| //! Metadata comparison, not a content hash: rewrites preserving every compared field are not detected. | ||
| //! Windows compares length, modification and creation times; Unix also compares device, inode and ctime. | ||
| use std::{fs::Metadata, path::Path}; | ||
|
|
||
| #[derive(Clone, Debug, PartialEq, Eq)] | ||
| pub(super) struct FileRevision { | ||
| len: u64, | ||
| modified: std::time::SystemTime, | ||
| #[cfg(unix)] | ||
| identity: (u64, u64, i64, i64), | ||
| #[cfg(windows)] | ||
| created: u64, | ||
| } | ||
|
|
||
| impl FileRevision { | ||
| /// The path a revision was read from is not part of it: the callers check the path they hold, | ||
| /// so a changed working directory never looks like a changed file. | ||
| pub(super) fn capture(metadata: &Metadata) -> std::io::Result<Self> { | ||
| #[cfg(unix)] | ||
| use std::os::unix::fs::MetadataExt; | ||
| #[cfg(windows)] | ||
| use std::os::windows::fs::MetadataExt; | ||
| Ok(Self { | ||
| len: metadata.len(), | ||
| modified: metadata.modified()?, | ||
| #[cfg(unix)] | ||
| identity: (metadata.dev(), metadata.ino(), metadata.ctime(), metadata.ctime_nsec()), | ||
| #[cfg(windows)] | ||
| created: metadata.creation_time(), | ||
| }) | ||
| } | ||
|
|
||
| fn check_metadata(&self, metadata: &Metadata) -> std::result::Result<(), String> { | ||
| let current = Self::capture(metadata).map_err(|e| format!("Could not verify the current image file metadata: {e}"))?; | ||
| if *self == current { | ||
| Ok(()) | ||
| } else { | ||
| Err("The image file changed since its pixels were loaded. Use Reload Data, then retry the operation.".into()) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl super::Raster { | ||
| fn original_revision(&self) -> std::result::Result<&FileRevision, String> { | ||
| match &self.source_file { | ||
| Some(Ok(original)) => Ok(original), | ||
| Some(Err(error)) => Err(format!( | ||
| "The original image file revision could not be captured ({error}). Check filesystem metadata support/access, or export the image as a GeoTIFF to another location and add it." | ||
| )), | ||
| None => Err("The displayed image has no verified original file revision. Use Reload Data, then retry the operation.".into()), | ||
| } | ||
| } | ||
|
|
||
| /// Checks fresh metadata at the live path on the reader's worker, never per frame. | ||
| pub fn check_original_file(&self, path: &Path) -> std::result::Result<(), String> { | ||
| let original = self.original_revision()?; | ||
| let metadata = std::fs::metadata(path).map_err(|e| format!("Could not read the current image file metadata: {e}"))?; | ||
| original.check_metadata(&metadata) | ||
| } | ||
|
|
||
| /// Checks fresh metadata from this open handle against the original source. | ||
| /// This does not verify that the live path still names the handle; check_original_file does. | ||
| pub fn check_original_handle(&self, file: &std::fs::File) -> std::result::Result<(), String> { | ||
| let original = self.original_revision()?; | ||
| let metadata = file.metadata().map_err(|e| format!("Could not read the open image file metadata: {e}"))?; | ||
| original.check_metadata(&metadata) | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| #[test] | ||
| fn annotation_grid_revision_detects_replacement_with_the_same_length_and_modification_time() { | ||
| let folder = tempfile::tempdir().unwrap(); | ||
| let path = folder.path().join("image.tif"); | ||
| let bytes = super::super::geotiff::write(&super::super::tests::small(), 0).unwrap(); | ||
| std::fs::write(&path, &bytes).unwrap(); | ||
| let raster = super::super::geotiff::read_file(&path, "image").unwrap(); | ||
| let original = std::fs::File::open(&path).unwrap(); | ||
| let metadata = original.metadata().unwrap(); | ||
| raster.check_original_file(&path).unwrap(); | ||
| raster.check_original_handle(&original).unwrap(); | ||
| let replacement = folder.path().join("replacement.tif"); | ||
| std::fs::write(&replacement, &bytes).unwrap(); | ||
| let file = std::fs::File::options().write(true).open(&replacement).unwrap(); | ||
| file.set_times(std::fs::FileTimes::new().set_modified(metadata.modified().unwrap())).unwrap(); | ||
| drop(file); | ||
| std::fs::remove_file(&path).unwrap(); | ||
| std::fs::rename(&replacement, &path).unwrap(); | ||
| let current = std::fs::metadata(&path).unwrap(); | ||
| assert_eq!(metadata.len(), current.len()); | ||
| assert_eq!(metadata.modified().unwrap(), current.modified().unwrap()); | ||
| // Retaining old metadata cannot make the live-path API accept the replacement. | ||
| assert!(raster.check_original_file(&path).unwrap_err().contains("Reload Data")); | ||
| let replacement_handle = std::fs::File::open(&path).unwrap(); | ||
| assert!(raster.check_original_handle(&replacement_handle).is_err()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn annotation_grid_handle_validation_rejects_a_different_file() { | ||
| let folder = tempfile::tempdir().unwrap(); | ||
| let path = folder.path().join("image.tif"); | ||
| let other = folder.path().join("other.tif"); | ||
| let bytes = super::super::geotiff::write(&super::super::tests::small(), 0).unwrap(); | ||
| std::fs::write(&path, &bytes).unwrap(); | ||
| let mut other_bytes = bytes.clone(); | ||
| other_bytes.push(0); // Distinct metadata even on filesystems with coarse timestamps. | ||
| std::fs::write(&other, &other_bytes).unwrap(); | ||
| let raster = super::super::geotiff::read_file(&path, "image").unwrap(); | ||
| assert!(raster.check_original_handle(&std::fs::File::open(&other).unwrap()).is_err()); | ||
| raster.check_original_file(&path).unwrap(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.