Skip to content

Fix Incorrect handling of Lat and Long from EXIF data for S&W coords - #4690

Open
xkello wants to merge 1 commit into
masterfrom
bugfix/fix-bad-coord-handling-for-S-W-coordinates
Open

Fix Incorrect handling of Lat and Long from EXIF data for S&W coords#4690
xkello wants to merge 1 commit into
masterfrom
bugfix/fix-bad-coord-handling-for-S-W-coordinates

Conversation

@xkello

@xkello xkello commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

read_exif_latitude() and read_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 the GPSLatitudeRef and GPSLongitudeRef tags (N/S and E/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.

Screenshot_20260901-092622_Fake GPS Location Screenshot_20260901-092510

What changed

In app/inputexpressionfunctions.cpp, the Android branches of ReadExifLatitude::func and ReadExifLongitude::func now also read GPSLatitudeRef and GPSLongitudeRef via AndroidUtils::readExif, and negate the converted coordinate when the ref is S or W respectively, mirroring the existing iOS implementation.

@xkello
xkello requested a review from Withalion September 1, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect Handling of Latitude and Longitude from EXIF Data for S and W Coordinates

1 participant