diff options
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r-- | src/client/documents/Documents.ts | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 9740f81ef..c2d1fec51 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -156,6 +156,8 @@ export class DocumentOptions { x?: number; y?: number; z?: number; // whether document is in overlay (1) or not (0 or undefined) + lat?: number; + lng?: number; author?: string; _layoutKey?: string; type?: string; @@ -726,8 +728,8 @@ export namespace Docs { return InstanceFromProto(Prototypes.get(DocumentType.MAP), new List(documents), options); } - export function MapMarkerDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) { - return InstanceFromProto(Prototypes.get(DocumentType.MARKER), new List(documents), options, id); + export function MapMarkerDocument(lat: number, lng: number, documents: Array<Doc>, options: DocumentOptions, id?: string) { + return InstanceFromProto(Prototypes.get(DocumentType.MARKER), new List(documents), {lat, lng, ...options}, id); } export function KVPDocument(document: Doc, options: DocumentOptions = {}) { @@ -1325,6 +1327,25 @@ export namespace DocUtils { return optionsCollection; } + /** + * + * @param dms Degree Minute Second format exif gps data + * @param ref ref that determines negativity of decimal coordinates + * @returns a decimal format of gps latitude / longitude + */ + function getDecimalfromDMS(dms?: number[], ref?: string) { + if (dms && ref) { + let degrees = dms[0] / dms[1]; + let minutes = dms[2] / dms[3] / 60.0; + let seconds = dms[4] / dms[5] / 3600.0; + + if (['S', 'W'].includes(ref)) { + degrees = -degrees; minutes = -minutes; seconds = -seconds + } + return (degrees + minutes + seconds).toFixed(5); + } + } + async function processFileupload(generatedDocuments: Doc[], name: string, type: string, result: Error | Upload.FileInformation, options: DocumentOptions) { if (result instanceof Error) { alert(`Upload failed: ${result.message}`); @@ -1347,6 +1368,9 @@ export namespace DocUtils { proto["data-nativeWidth"] = (result.nativeWidth < result.nativeHeight) ? maxNativeDim : maxNativeDim / (result.nativeWidth / result.nativeHeight); } proto.contentSize = result.contentSize; + // exif gps data coordinates are stored in DMS (Degrees Minutes Seconds), the following operation converts that to decimal coordinates + proto.lat = getDecimalfromDMS(result.exifData?.data?.gps.GPSLatitude, result.exifData?.data?.gps.GPSLatitudeRef); + proto.lng = getDecimalfromDMS(result.exifData?.data?.gps.GPSLongitude, result.exifData?.data?.gps.GPSLongitudeRef); } generatedDocuments.push(doc); } |