1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Read GPS coordinates from XMP sidecar too

This commit is contained in:
Martin Kampas 2024-03-01 19:55:01 +01:00
parent 40e8147883
commit 1d1df01a68
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
}