Fix: Add check for valid location to handle NAN values (#1054)

This commit is contained in:
Neeraj Gupta 2023-05-03 10:33:08 +05:30 committed by GitHub
commit adc7389b00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -193,8 +193,7 @@ class File extends EnteFile {
if (Platform.isAndroid) {
//Fix for missing location data in lower android versions.
final Location? exifLocation = locationFromExif(exifData);
if (exifLocation?.latitude != null &&
exifLocation?.longitude != null) {
if (Location.isValidLocation(exifLocation)) {
location = exifLocation;
}
}

View file

@ -243,9 +243,14 @@ class GPSData {
return null;
}
return Location(
final result = Location(
latitude: latSign * (lat![0] + lat![1] / 60 + lat![2] / 3600),
longitude: longSign * (long![0] + long![1] / 60 + long![2] / 3600),
);
if (Location.isValidLocation(result)) {
return result;
} else {
return null;
}
}
}