getLatLong method

Future<ExifLatLong?> getLatLong()

Implementation

Future<ExifLatLong?> getLatLong() async {
  final attributes = await getAttributes();
  if (attributes == null) return null;

  final latitude = attributes['GPSLatitude'];
  final latitudeRef = attributes['GPSLatitudeRef'];
  final longitude = attributes['GPSLongitude'];
  final longitudeRef = attributes['GPSLongitudeRef'];
  if (latitude is! double || latitudeRef is! String || longitude is! double || longitudeRef is! String) {
    return null;
  }

  return ExifLatLong(
    latitude: latitude * (latitudeRef == 'S' ? -1 : 1),
    longitude: longitude * (longitudeRef == 'W' ? -1 : 1),
  );
}