vgridjs
Version:
Vgrid DGGS JS
1 lines • 1.91 kB
Source Map (JSON)
{"version":3,"sources":["../dggs/olc.ts"],"names":[],"mappings":";;;AAOa,IAAA,YAAA,GAAN,cAA2B,KAAM,CAAA;AAAA,EACpC,YAAY,OAAiB,EAAA;AACzB,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAO,GAAA,cAAA;AAAA;AAEpB;AAGO,SAAS,OAAO,GAQrB,EAAA;AAEE,EAAM,MAAA,IAAI,aAAa,uEAAuE,CAAA;AAClG;AAOO,SAAS,YAAY,MAAkC,EAAA;AAC1D,EAAM,MAAA,QAAA,GAAW,OAAa,CAAA;AAC9B,EAAA,MAAM,UAAc,GAAA,CAAA,QAAA,CAAS,UAAa,GAAA,QAAA,CAAS,UAAc,IAAA,CAAA;AACjE,EAAA,MAAM,UAAc,GAAA,CAAA,QAAA,CAAS,WAAc,GAAA,QAAA,CAAS,WAAe,IAAA,CAAA;AACnE,EAAO,OAAA,CAAC,YAAY,UAAU,CAAA;AAClC","file":"olc.cjs","sourcesContent":["/**\r\n * OLC (Open Location Code / Plus Codes) implementation in TypeScript\r\n * Based on the original Python implementation\r\n */\r\n\r\n// You may want to use an existing OLC library for encode/decode, but here is a basic structure:\r\n\r\nexport class OlcException extends Error {\r\n constructor(message: string) {\r\n super(message);\r\n this.name = 'OlcException';\r\n }\r\n}\r\n\r\n// Placeholder for a real OLC decode function\r\nexport function decode(olc: string): {\r\n latitudeLo: number,\r\n latitudeHi: number,\r\n longitudeLo: number,\r\n longitudeHi: number,\r\n latitudeCenter: number,\r\n longitudeCenter: number,\r\n codeLength: number\r\n} {\r\n // TODO: Implement or use a library for OLC decode\r\n throw new OlcException('OLC decode not implemented. Use a library or implement this function.');\r\n}\r\n\r\n/**\r\n * Vgrid specific function to get the center lat/lon from an OLC code\r\n * @param olc_id OLC code\r\n * @returns [center_lat, center_lng]\r\n */\r\nexport function olcToLatLon(olc_id: string): [number, number] {\r\n const codeArea = decode(olc_id);\r\n const center_lat = (codeArea.latitudeLo + codeArea.latitudeHi) / 2;\r\n const center_lng = (codeArea.longitudeLo + codeArea.longitudeHi) / 2;\r\n return [center_lat, center_lng];\r\n} "]}