Skip to content

Commit

Permalink
Add GPS Latitude & Longitude Ref and option to set both at the same time
Browse files Browse the repository at this point in the history
Add changes requested by @Joshua-RF in original issue
  • Loading branch information
Flajt authored Nov 22, 2024
1 parent 85e3133 commit db98dee
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion lib/src/exif/ifd_directory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ class IfdDirectory {
data[0x8298] = IfdValueAscii(value);
}
}

bool get hasGPSLatitudeRef => data.containsKey(0x0001);
String? get gpsLatitudeRef => data[0x0001]?.toString();
set gpsLatitudeRef(String? value) {
if (value == null) {
data.remove(0x0001);
} else {
data[0x0001] = IfdValueAscii(value);
}
}

bool get hasGPSLatitude => data.containsKey(0x0002);
double? get gpsLatitude => data[0x0002]?.toDouble();
Expand All @@ -331,7 +341,17 @@ class IfdDirectory {
data[0x0002] = IfdValueDouble(value);
}
}


bool get hasGPSLongitudeRef => data.containsKey(0x0003);
String? get gpsLongitudeRef => data[0x0003]?.toString();
set gpsLongitudeRef(String? value) {
if (value == null) {
data.remove(0x0003);
} else {
data[0x0003] = IfdValueAscii(value);
}
}

bool get hasGPSLongitude => data.containsKey(0x0004);
double? get gpsLongitude => data[0x0004]?.toDouble();
set gpsLongitude(double? value) {
Expand All @@ -342,6 +362,17 @@ class IfdDirectory {
}
}

void setGpsLocation({
required double latitude,
required double longitude,
}) {
gpsLatitude = latitude.abs();
gpsLongitude = longitude.abs();
gpsLatitudeRef = latitude < 0.0 ? 'S' : 'N';
gpsLongitudeRef = longitude < 0.0 ? 'W' : 'E';
}


bool get hasGPSDate => data.containsKey(0x001D);
String? get gpsDate => data[0x001D]?.toString();
set gpsDate(String? value) {
Expand Down

0 comments on commit db98dee

Please sign in to comment.