Fix Incorrect handling of Lat and Long from EXIF data for S&W coords - #4690
Fix Incorrect handling of Lat and Long from EXIF data for S&W coords#4690xkello wants to merge 1 commit into
Conversation
Withalion
left a comment
There was a problem hiding this comment.
the code looks okay, but it doesn't work on my android phone only direction gets supplied for photos taken via camera and nothing gets supplied for photos from gallery
Android 15 phone, you can try it on this project Matej-test/position-data layer POI
This looks like a mock location problem. It seems that due to some of our code parts, the app cannot read mocked exif data. And even if it does (when the exif data was edited manually), they are read as zeros. I asked Vitor to retest my fix with real exif data. Also we will have to discuss how we want to approach the mocked data problem. |
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.