1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00

Merge pull request #859 from martyone/xmp-gps

Read GPS coordinates from XMP sidecar too
This commit is contained in:
Patrik J. Braun 2024-03-23 10:02:17 +01:00 committed by GitHub
commit e3a0f5967c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 48 additions and 0 deletions

View File

@ -666,6 +666,22 @@ export class MetadataLoader {
metadata.creationDate;
}
}
if ((sidecarData as SideCar).exif !== undefined) {
if (
(sidecarData as SideCar).exif.GPSLatitude !== undefined &&
(sidecarData as SideCar).exif.GPSLongitude !== undefined
) {
metadata.positionData = metadata.positionData || {};
metadata.positionData.GPSData = {};
metadata.positionData.GPSData.longitude = Utils.xmpExifGpsCoordinateToDecimalDegrees(
(sidecarData as SideCar).exif.GPSLongitude
);
metadata.positionData.GPSData.latitude = Utils.xmpExifGpsCoordinateToDecimalDegrees(
(sidecarData as SideCar).exif.GPSLatitude
);
}
}
}
}
}

View File

@ -381,6 +381,14 @@ export class Utils {
}
return ret;
}
public static xmpExifGpsCoordinateToDecimalDegrees(text: string): number {
const parts = text.match(/^([0-9]+),([0-9.]+)([EWNS])$/);
const degrees: number = parseInt(parts[1], 10);
const minutes: number = parseFloat(parts[2]);
const sign = (parts[3] === "N" || parts[3] === "E") ? 1 : -1;
return sign * (degrees + (minutes / 60.0))
}
}
export class LRU<V> {

View File

@ -30,11 +30,17 @@ export interface MediaDimension {
}
export interface SideCar {
exif?: SideCarExif;
dc?: SideCarDc;
xmp?: SideCarXmp;
photoshop?: SideCarPhotoshop;
}
export interface SideCarExif {
GPSLatitude?: string;
GPSLongitude?: string;
}
export interface SideCarDc {
subject?: string[];
}

View File

@ -18,5 +18,11 @@
"Výlet",
"Travel"
],
"positionData": {
"GPSData": {
"latitude": 50.08958748333333,
"longitude": 14.397409516666666
}
},
"rating": 3
}

View File

@ -19,5 +19,11 @@
"Výlet",
"Travel"
],
"positionData": {
"GPSData": {
"latitude": 50.08958748333333,
"longitude": 14.397409516666666
}
},
"rating": 3
}

View File

@ -19,5 +19,11 @@
"Výlet",
"Travel"
],
"positionData": {
"GPSData": {
"latitude": 50.08958748333333,
"longitude": 14.397409516666666
}
},
"rating": 3
}