Fix Incorrect handling of Lat and Long from EXIF data for S&W coords - #4690
Open
xkello wants to merge 1 commit into
Open
Fix Incorrect handling of Lat and Long from EXIF data for S&W coords#4690xkello wants to merge 1 commit into
xkello wants to merge 1 commit into
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.
Description
read_exif_latitude()andread_exif_longitude()return incorrect (always positive) coordinates on Android for photos taken in the Southern or Western hemisphere. EXIF stores the coordinate magnitude in degrees/minutes/seconds as an unsigned value, and the hemisphere is stored separately in theGPSLatitudeRefandGPSLongitudeReftags (N/SandE/W). The Android code path converts the magnitude to decimal degrees but never reads the ref tag, so the sign is lost. iOS was already fixed for this in commit PR #4393, Gabriel Bolbotina, May 2026, which negates the value when the ref indicates South or West.Fixes: #3685
Behavior
Before the fix, a photo taken in Belem, Brazil (expected around
1.455833 S, 48.503887 W) would populate a coordinate field with(1.455833, 48.503887)instead of(−1.455833, −48.503887), placing the point in the wrong hemisphere entirely.After the fix, Android matches iOS behavior: the ref tag is checked and the resulting decimal degree value is negated when appropriate, so coordinates in the Southern and Western hemispheres come out with the correct sign.
What changed
In
app/inputexpressionfunctions.cpp, the Android branches ofReadExifLatitude::funcandReadExifLongitude::funcnow also readGPSLatitudeRefandGPSLongitudeRefviaAndroidUtils::readExif, and negate the converted coordinate when the ref isSorWrespectively, mirroring the existing iOS implementation.