Handle infinite or Nan values
This commit is contained in:
parent
12edb7a740
commit
c20cb8040a
2 changed files with 15 additions and 3 deletions
|
@ -12,4 +12,18 @@ class Location with _$Location {
|
||||||
|
|
||||||
factory Location.fromJson(Map<String, Object?> json) =>
|
factory Location.fromJson(Map<String, Object?> json) =>
|
||||||
_$LocationFromJson(json);
|
_$LocationFromJson(json);
|
||||||
|
|
||||||
|
static isValidLocation(Location? location) {
|
||||||
|
if (location == null) return false;
|
||||||
|
if (location.latitude == null || location.longitude == null) return false;
|
||||||
|
final latValue = location.latitude!;
|
||||||
|
final longValue = location.longitude!;
|
||||||
|
if (latValue.isNaN || latValue.isNaN || latValue == 0.0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (longValue.isInfinite || longValue.isInfinite || longValue == 0.0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,9 +257,7 @@ class LocalFileUpdateService {
|
||||||
|
|
||||||
for (ente.File file in enteFiles) {
|
for (ente.File file in enteFiles) {
|
||||||
final Location? location = await tryLocationFromExif(file);
|
final Location? location = await tryLocationFromExif(file);
|
||||||
if (location != null &&
|
if (location != null && Location.isValidLocation(location)) {
|
||||||
(location.latitude ?? 0) != 0.0 &&
|
|
||||||
(location.longitude ?? 0) != 0.0) {
|
|
||||||
remoteFilesToUpdate.add(file);
|
remoteFilesToUpdate.add(file);
|
||||||
fileIDToUpdateMetadata[file.uploadedFileID!] = {
|
fileIDToUpdateMetadata[file.uploadedFileID!] = {
|
||||||
pubMagicKeyLat: location.latitude!,
|
pubMagicKeyLat: location.latitude!,
|
||||||
|
|
Loading…
Add table
Reference in a new issue