Skip to content

Commit

Permalink
#165 Fix GPS coordinates with minus (S/W)
Browse files Browse the repository at this point in the history
  • Loading branch information
mczachurski committed Dec 26, 2024
1 parent 48b04ee commit bf6c46f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
38 changes: 33 additions & 5 deletions src/app/pages/status/status.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,28 @@ export class StatusPage extends ResponsiveComponent implements OnInit, OnDestroy
}

if (exif.latitude) {
return exif.latitude?.replace(',', '.');
let latitude = exif.latitude?.replace(',', '.').toUpperCase();

if (latitude.endsWith('S')) {
latitude = latitude.replace('S', '');

if (!latitude.startsWith('-')) {
latitude = '-' + latitude;
}
}

if (latitude.endsWith('N')) {
latitude = latitude.replace('N', '');
}

return latitude;
}

return undefined;
}

getGpsLatitudeToDisplay(index: number): string {
return this.getGpsLatitude(index)?.slice(0, 6) ?? '';
return this.getGpsLatitude(index)?.slice(0, 10) ?? '';
}

getGpsLongitude(index: number): string | undefined {
Expand All @@ -410,15 +424,29 @@ export class StatusPage extends ResponsiveComponent implements OnInit, OnDestroy
return undefined;
}

if (exif.latitude) {
return exif.longitude?.replace(',', '.');
if (exif.longitude) {
let longitude = exif.longitude?.replace(',', '.').toUpperCase();

if (longitude.endsWith('W')) {
longitude = longitude.replace('W', '');

if (!longitude.startsWith('-')) {
longitude = '-' + longitude;
}
}

if (longitude.endsWith('E')) {
longitude = longitude.replace('E', '');
}

return longitude;
}

return undefined;
}

getGpsLongitudeToDisplay(index: number): string {
return this.getGpsLongitude(index)?.slice(0, 6) ?? '';
return this.getGpsLongitude(index)?.slice(0, 10) ?? '';
}

showHdrIcon(index: number): boolean {
Expand Down
16 changes: 14 additions & 2 deletions src/app/pages/upload/upload.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,21 @@ export class UploadPage extends ResponsiveComponent implements OnInit {
uploadPhoto.showSoftware = true;
}

const gpsLatitude = tags['GPSLatitude']?.description.toString();
const gpsLongitude = tags['GPSLongitude']?.description.toString();
let gpsLatitude = tags['GPSLatitude']?.description?.toString();
let gpsLongitude = tags['GPSLongitude']?.description?.toString();

const gpsLatitudeRef = tags['GPSLatitudeRef']?.value?.toString().toUpperCase();
const gpsLongitudeRef = tags['GPSLongitudeRef']?.value?.toString().toUpperCase();

if (gpsLatitude && gpsLongitude) {
if (gpsLatitudeRef === 'S' && !gpsLatitude.startsWith('-')) {
gpsLatitude = '-' + gpsLatitude;
}

if (gpsLongitudeRef === 'W' && !gpsLongitude.startsWith('-')) {
gpsLongitude = '-' + gpsLongitude;
}

uploadPhoto.latitude = gpsLatitude;
uploadPhoto.longitude = gpsLongitude;
uploadPhoto.showGpsCoordination = false;
Expand Down

0 comments on commit bf6c46f

Please sign in to comment.