Image: resolve basename-only paths relative to XML#28124
Open
MaciejMax wants to merge 2 commits into
Open
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolve basename-only image paths relative to XML metadata
Problem
ISCE image metadata XML can contain basename-only raster paths:
When loading such XML by path,
Image.load()currently keepsself.filenameandself._extraFilenameas those basename values. Downstream processing can then look for the raster and VRT in the current working directory instead of the directory containing the XML metadata.This makes it harder to reuse one shared DEM across multiple processing work directories, because each work directory may otherwise need its own local copy or hardlink of the DEM files.
Proposed change
Add an
Image.load()wrapper that delegates toConfigurable.load()and then resolves basename-only image paths relative to the XML file location:The basename-only guard is important. Relative paths that already include directories should remain unchanged, because some internal products intentionally rely on those paths as written.
Validation
The change was validated in three ways:
file_nameandextra_file_namevalues now resolves both paths relative to the XML location.Motivation
This makes XML-relative image metadata behave in the way users generally expect: basename values inside an image metadata XML file refer to files located next to that XML file. It also reduces friction when reusing large shared rasters across many processing directories.