@math.gl/dggs 5.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +140 -0
- package/README.md +7 -0
- package/dist/a5-decoder.d.ts +15 -0
- package/dist/a5-decoder.d.ts.map +1 -0
- package/dist/a5-decoder.js +36 -0
- package/dist/a5-decoder.js.map +1 -0
- package/dist/a5.cjs +77 -0
- package/dist/a5.cjs.map +6 -0
- package/dist/a5.d.ts +2 -0
- package/dist/a5.d.ts.map +1 -0
- package/dist/a5.js +5 -0
- package/dist/a5.js.map +1 -0
- package/dist/converters/s2-to-obb-points.d.ts +15 -0
- package/dist/converters/s2-to-obb-points.d.ts.map +1 -0
- package/dist/converters/s2-to-obb-points.js +60 -0
- package/dist/converters/s2-to-obb-points.js.map +1 -0
- package/dist/converters/s2-to-region.d.ts +6 -0
- package/dist/converters/s2-to-region.d.ts.map +1 -0
- package/dist/converters/s2-to-region.js +27 -0
- package/dist/converters/s2-to-region.js.map +1 -0
- package/dist/dggs-decoder.d.ts +37 -0
- package/dist/dggs-decoder.d.ts.map +1 -0
- package/dist/dggs-decoder.js +28 -0
- package/dist/dggs-decoder.js.map +1 -0
- package/dist/geohash-decoder.d.ts +17 -0
- package/dist/geohash-decoder.d.ts.map +1 -0
- package/dist/geohash-decoder.js +88 -0
- package/dist/geohash-decoder.js.map +1 -0
- package/dist/geohash.cjs +108 -0
- package/dist/geohash.cjs.map +6 -0
- package/dist/geohash.d.ts +2 -0
- package/dist/geohash.d.ts.map +1 -0
- package/dist/geohash.js +5 -0
- package/dist/geohash.js.map +1 -0
- package/dist/h3-decoder.d.ts +15 -0
- package/dist/h3-decoder.d.ts.map +1 -0
- package/dist/h3-decoder.js +46 -0
- package/dist/h3-decoder.js.map +1 -0
- package/dist/h3.cjs +87 -0
- package/dist/h3.cjs.map +6 -0
- package/dist/h3.d.ts +2 -0
- package/dist/h3.d.ts.map +1 -0
- package/dist/h3.js +5 -0
- package/dist/h3.js.map +1 -0
- package/dist/index.cjs +615 -0
- package/dist/index.cjs.map +6 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/plus-code-decoder.d.ts +16 -0
- package/dist/plus-code-decoder.d.ts.map +1 -0
- package/dist/plus-code-decoder.js +50 -0
- package/dist/plus-code-decoder.js.map +1 -0
- package/dist/plus-code.cjs +88 -0
- package/dist/plus-code.cjs.map +6 -0
- package/dist/plus-code.d.ts +2 -0
- package/dist/plus-code.d.ts.map +1 -0
- package/dist/plus-code.js +5 -0
- package/dist/plus-code.js.map +1 -0
- package/dist/quadkey-decoder.d.ts +14 -0
- package/dist/quadkey-decoder.d.ts.map +1 -0
- package/dist/quadkey-decoder.js +86 -0
- package/dist/quadkey-decoder.js.map +1 -0
- package/dist/quadkey.cjs +106 -0
- package/dist/quadkey.cjs.map +6 -0
- package/dist/quadkey.d.ts +2 -0
- package/dist/quadkey.d.ts.map +1 -0
- package/dist/quadkey.js +5 -0
- package/dist/quadkey.js.map +1 -0
- package/dist/s2-decoder.d.ts +26 -0
- package/dist/s2-decoder.d.ts.map +1 -0
- package/dist/s2-decoder.js +76 -0
- package/dist/s2-decoder.js.map +1 -0
- package/dist/s2-geometry/s2-geometry.d.ts +13 -0
- package/dist/s2-geometry/s2-geometry.d.ts.map +1 -0
- package/dist/s2-geometry/s2-geometry.js +126 -0
- package/dist/s2-geometry/s2-geometry.js.map +1 -0
- package/dist/s2-geometry/s2-to-boundary.d.ts +14 -0
- package/dist/s2-geometry/s2-to-boundary.d.ts.map +1 -0
- package/dist/s2-geometry/s2-to-boundary.js +60 -0
- package/dist/s2-geometry/s2-to-boundary.js.map +1 -0
- package/dist/s2-geometry/s2-token.d.ts +13 -0
- package/dist/s2-geometry/s2-token.d.ts.map +1 -0
- package/dist/s2-geometry/s2-token.js +61 -0
- package/dist/s2-geometry/s2-token.js.map +1 -0
- package/dist/s2.cjs +278 -0
- package/dist/s2.cjs.map +6 -0
- package/dist/s2.d.ts +3 -0
- package/dist/s2.d.ts.map +1 -0
- package/dist/s2.js +6 -0
- package/dist/s2.js.map +1 -0
- package/package.json +80 -0
- package/src/a5-decoder.ts +42 -0
- package/src/a5.ts +5 -0
- package/src/converters/s2-to-obb-points.ts +78 -0
- package/src/converters/s2-to-region.ts +30 -0
- package/src/dggs-decoder.ts +71 -0
- package/src/geohash-decoder.ts +99 -0
- package/src/geohash.ts +5 -0
- package/src/h3-decoder.ts +53 -0
- package/src/h3.ts +5 -0
- package/src/index.ts +61 -0
- package/src/open-location-code.d.ts +19 -0
- package/src/plus-code-decoder.ts +56 -0
- package/src/plus-code.ts +5 -0
- package/src/quadkey-decoder.ts +98 -0
- package/src/quadkey.ts +5 -0
- package/src/s2-decoder.ts +87 -0
- package/src/s2-geometry/s2-geometry.ts +166 -0
- package/src/s2-geometry/s2-to-boundary.ts +76 -0
- package/src/s2-geometry/s2-token.ts +70 -0
- package/src/s2.ts +6 -0
package/dist/geohash.cjs
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// dist/geohash.js
|
|
20
|
+
var geohash_exports = {};
|
|
21
|
+
__export(geohash_exports, {
|
|
22
|
+
GeohashDecoder: () => GeohashDecoder,
|
|
23
|
+
getGeohashBounds: () => getGeohashBounds
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(geohash_exports);
|
|
26
|
+
|
|
27
|
+
// dist/dggs-decoder.js
|
|
28
|
+
function getDGGSCellToken(cell, gridName) {
|
|
29
|
+
if (typeof cell !== "string") {
|
|
30
|
+
throw new Error(`${gridName} cell identifiers must be strings`);
|
|
31
|
+
}
|
|
32
|
+
return cell;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// dist/geohash-decoder.js
|
|
36
|
+
var GeohashDecoder = {
|
|
37
|
+
name: "geohash",
|
|
38
|
+
hasNumericRepresentation: false,
|
|
39
|
+
cellColumnNames: ["geohash", "geohashId", "geohash_id"],
|
|
40
|
+
cellToLngLat: (cell) => getGeohashLngLat(getDGGSCellToken(cell, "GeoHash")),
|
|
41
|
+
cellToBoundary: (cell) => getGeohashBoundary(getDGGSCellToken(cell, "GeoHash")),
|
|
42
|
+
cellToBoundaryFlat: (cell) => getGeohashBoundaryFlat(getDGGSCellToken(cell, "GeoHash")),
|
|
43
|
+
cellToBounds: (cell) => getGeohashBounds(getDGGSCellToken(cell, "GeoHash"))
|
|
44
|
+
};
|
|
45
|
+
var BASE32_CODES = "0123456789bcdefghjkmnpqrstuvwxyz";
|
|
46
|
+
var BASE32_CODES_DICT = {};
|
|
47
|
+
for (let i = 0; i < BASE32_CODES.length; i++) {
|
|
48
|
+
BASE32_CODES_DICT[BASE32_CODES.charAt(i)] = i;
|
|
49
|
+
}
|
|
50
|
+
var MIN_LAT = -90;
|
|
51
|
+
var MAX_LAT = 90;
|
|
52
|
+
var MIN_LON = -180;
|
|
53
|
+
var MAX_LON = 180;
|
|
54
|
+
function getGeohashLngLat(geohash) {
|
|
55
|
+
const [[w, s], [e, n]] = getGeohashBounds(geohash);
|
|
56
|
+
return [(e + w) / 2, (n + s) / 2];
|
|
57
|
+
}
|
|
58
|
+
function getGeohashBoundary(geohash) {
|
|
59
|
+
const [[w, s], [e, n]] = getGeohashBounds(geohash);
|
|
60
|
+
return [
|
|
61
|
+
[e, n],
|
|
62
|
+
[e, s],
|
|
63
|
+
[w, s],
|
|
64
|
+
[w, n],
|
|
65
|
+
[e, n]
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
function getGeohashBoundaryFlat(geohash) {
|
|
69
|
+
const [[w, s], [e, n]] = getGeohashBounds(geohash);
|
|
70
|
+
return [e, n, e, s, w, s, w, n, e, n];
|
|
71
|
+
}
|
|
72
|
+
function getGeohashBounds(geohash) {
|
|
73
|
+
let isLon = true;
|
|
74
|
+
let maxLat = MAX_LAT;
|
|
75
|
+
let minLat = MIN_LAT;
|
|
76
|
+
let maxLon = MAX_LON;
|
|
77
|
+
let minLon = MIN_LON;
|
|
78
|
+
let mid;
|
|
79
|
+
let hashValue = 0;
|
|
80
|
+
for (let i = 0, l = geohash.length; i < l; i++) {
|
|
81
|
+
const code = geohash[i].toLowerCase();
|
|
82
|
+
hashValue = BASE32_CODES_DICT[code];
|
|
83
|
+
for (let bits = 4; bits >= 0; bits--) {
|
|
84
|
+
const bit = hashValue >> bits & 1;
|
|
85
|
+
if (isLon) {
|
|
86
|
+
mid = (maxLon + minLon) / 2;
|
|
87
|
+
if (bit === 1) {
|
|
88
|
+
minLon = mid;
|
|
89
|
+
} else {
|
|
90
|
+
maxLon = mid;
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
mid = (maxLat + minLat) / 2;
|
|
94
|
+
if (bit === 1) {
|
|
95
|
+
minLat = mid;
|
|
96
|
+
} else {
|
|
97
|
+
maxLat = mid;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
isLon = !isLon;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return [
|
|
104
|
+
[minLon, minLat],
|
|
105
|
+
[maxLon, maxLat]
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=geohash.cjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/geohash.ts", "../src/dggs-decoder.ts", "../src/geohash-decoder.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;AC6CM,SAAU,iBAAiB,MAAgB,UAAgB;AAC/D,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,IAAI,MAAM,GAAG,QAAQ,mCAAmC;EAChE;AACA,SAAO;AACT;;;AC1CO,IAAM,iBAAiB;EAC5B,MAAM;EACN,0BAA0B;EAC1B,iBAAiB,CAAC,WAAW,aAAa,YAAY;EACtD,cAAc,CAAC,SACb,iBAAiB,iBAAiB,MAAM,SAAS,CAAC;EACpD,gBAAgB,CAAC,SACf,mBAAmB,iBAAiB,MAAM,SAAS,CAAC;EACtD,oBAAoB,CAAC,SACnB,uBAAuB,iBAAiB,MAAM,SAAS,CAAC;EAC1D,cAAc,CAAC,SAA6B,iBAAiB,iBAAiB,MAAM,SAAS,CAAC;;AAGhG,IAAM,eAAe;AACrB,IAAM,oBAA4C,CAAA;AAClD,SAAS,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;AAC5C,oBAAkB,aAAa,OAAO,CAAC,CAAC,IAAI;AAC9C;AAEA,IAAM,UAAU;AAChB,IAAM,UAAU;AAChB,IAAM,UAAU;AAChB,IAAM,UAAU;AAGhB,SAAS,iBAAiB,SAAe;AACvC,QAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,iBAAiB,OAAO;AACjD,SAAO,EAAE,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC;AAClC;AAGA,SAAS,mBAAmB,SAAe;AACzC,QAAM,CA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,gBAAgB,EAAC,6BAA0B"}
|
package/dist/geohash.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geohash.js","sourceRoot":"","sources":["../src/geohash.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,cAAc,EAAE,gBAAgB,EAAC,6BAA0B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Bounds2D } from '@math.gl/types';
|
|
2
|
+
import { type DGGSCell } from "./dggs-decoder.js";
|
|
3
|
+
/** Lightweight cell geometry decoder for the H3 hexagonal DGGS. */
|
|
4
|
+
export declare const H3Decoder: {
|
|
5
|
+
readonly name: "h3";
|
|
6
|
+
readonly hasNumericRepresentation: true;
|
|
7
|
+
readonly cellColumnNames: readonly ["h3", "h3Index", "h3_index", "h3Cell", "h3_cell", "h3CellId", "h3_cell_id", "hexagon"];
|
|
8
|
+
readonly tokenToCell: (token: string) => bigint;
|
|
9
|
+
readonly cellToToken: (cell: DGGSCell) => string;
|
|
10
|
+
readonly cellToLngLat: (cell: DGGSCell) => [number, number];
|
|
11
|
+
readonly cellToBoundary: (cell: DGGSCell) => [number, number][];
|
|
12
|
+
readonly cellToBoundaryFlat: (cell: DGGSCell) => number[];
|
|
13
|
+
readonly cellToBounds: (cell: DGGSCell) => Bounds2D;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=h3-decoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"h3-decoder.d.ts","sourceRoot":"","sources":["../src/h3-decoder.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,KAAK,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAC,KAAK,QAAQ,EAAsC,0BAAuB;AAElF,mEAAmE;AACnE,eAAO,MAAM,SAAS;;;;kCAaC,MAAM,KAAG,MAAM;iCAChB,QAAQ,KAAG,MAAM;kCAChB,QAAQ,KAAG,CAAC,MAAM,EAAE,MAAM,CAAC;oCACzB,QAAQ,KAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;wCACzB,QAAQ,KAAG,MAAM,EAAE;kCACzB,QAAQ,KAAG,QAAQ;CACV,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { cellToBoundary, cellToLatLng } from 'h3-js';
|
|
5
|
+
import { getDGGSCellBounds } from "./dggs-decoder.js";
|
|
6
|
+
/** Lightweight cell geometry decoder for the H3 hexagonal DGGS. */
|
|
7
|
+
export const H3Decoder = {
|
|
8
|
+
name: 'h3',
|
|
9
|
+
hasNumericRepresentation: true,
|
|
10
|
+
cellColumnNames: [
|
|
11
|
+
'h3',
|
|
12
|
+
'h3Index',
|
|
13
|
+
'h3_index',
|
|
14
|
+
'h3Cell',
|
|
15
|
+
'h3_cell',
|
|
16
|
+
'h3CellId',
|
|
17
|
+
'h3_cell_id',
|
|
18
|
+
'hexagon'
|
|
19
|
+
],
|
|
20
|
+
tokenToCell: (token) => getBigIntFromHexToken(token),
|
|
21
|
+
cellToToken: (cell) => getH3Token(cell),
|
|
22
|
+
cellToLngLat: (cell) => getH3LngLat(cell),
|
|
23
|
+
cellToBoundary: (cell) => getH3Boundary(cell),
|
|
24
|
+
cellToBoundaryFlat: (cell) => getH3Boundary(cell).flat(),
|
|
25
|
+
cellToBounds: (cell) => getDGGSCellBounds(getH3Boundary(cell))
|
|
26
|
+
};
|
|
27
|
+
function getH3Token(cell) {
|
|
28
|
+
return typeof cell === 'bigint' ? cell.toString(16) : removeHexPrefix(cell);
|
|
29
|
+
}
|
|
30
|
+
function getH3LngLat(cell) {
|
|
31
|
+
const [latitude, longitude] = cellToLatLng(getH3Token(cell));
|
|
32
|
+
return [longitude, latitude];
|
|
33
|
+
}
|
|
34
|
+
function getH3Boundary(cell) {
|
|
35
|
+
return cellToBoundary(getH3Token(cell), true).map(([longitude, latitude]) => [
|
|
36
|
+
longitude,
|
|
37
|
+
latitude
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
function getBigIntFromHexToken(token) {
|
|
41
|
+
return BigInt(`0x${removeHexPrefix(token)}`);
|
|
42
|
+
}
|
|
43
|
+
function removeHexPrefix(token) {
|
|
44
|
+
return token.startsWith('0x') || token.startsWith('0X') ? token.slice(2) : token;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=h3-decoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"h3-decoder.js","sourceRoot":"","sources":["../src/h3-decoder.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAkC,iBAAiB,EAAC,0BAAuB;AAElF,mEAAmE;AACnE,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,IAAI;IACV,wBAAwB,EAAE,IAAI;IAC9B,eAAe,EAAE;QACf,IAAI;QACJ,SAAS;QACT,UAAU;QACV,QAAQ;QACR,SAAS;QACT,UAAU;QACV,YAAY;QACZ,SAAS;KACV;IACD,WAAW,EAAE,CAAC,KAAa,EAAU,EAAE,CAAC,qBAAqB,CAAC,KAAK,CAAC;IACpE,WAAW,EAAE,CAAC,IAAc,EAAU,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;IACzD,YAAY,EAAE,CAAC,IAAc,EAAoB,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;IACrE,cAAc,EAAE,CAAC,IAAc,EAAsB,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC;IAC3E,kBAAkB,EAAE,CAAC,IAAc,EAAY,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;IAC5E,YAAY,EAAE,CAAC,IAAc,EAAY,EAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;CACpD,CAAC;AAEjC,SAAS,UAAU,CAAC,IAAc;IAChC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,WAAW,CAAC,IAAc;IACjC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7D,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,aAAa,CAAC,IAAc;IACnC,OAAO,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC;QAC3E,SAAS;QACT,QAAQ;KACT,CAAC,CAAC;AACL,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAa;IAC1C,OAAO,MAAM,CAAC,KAAK,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACnF,CAAC"}
|
package/dist/h3.cjs
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// dist/h3.js
|
|
20
|
+
var h3_exports = {};
|
|
21
|
+
__export(h3_exports, {
|
|
22
|
+
H3Decoder: () => H3Decoder
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(h3_exports);
|
|
25
|
+
|
|
26
|
+
// dist/h3-decoder.js
|
|
27
|
+
var import_h3_js = require("h3-js");
|
|
28
|
+
|
|
29
|
+
// dist/dggs-decoder.js
|
|
30
|
+
function getDGGSCellBounds(boundary) {
|
|
31
|
+
let west = Infinity;
|
|
32
|
+
let south = Infinity;
|
|
33
|
+
let east = -Infinity;
|
|
34
|
+
let north = -Infinity;
|
|
35
|
+
for (const [longitude, latitude] of boundary) {
|
|
36
|
+
west = Math.min(west, longitude);
|
|
37
|
+
south = Math.min(south, latitude);
|
|
38
|
+
east = Math.max(east, longitude);
|
|
39
|
+
north = Math.max(north, latitude);
|
|
40
|
+
}
|
|
41
|
+
return [
|
|
42
|
+
[west, south],
|
|
43
|
+
[east, north]
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// dist/h3-decoder.js
|
|
48
|
+
var H3Decoder = {
|
|
49
|
+
name: "h3",
|
|
50
|
+
hasNumericRepresentation: true,
|
|
51
|
+
cellColumnNames: [
|
|
52
|
+
"h3",
|
|
53
|
+
"h3Index",
|
|
54
|
+
"h3_index",
|
|
55
|
+
"h3Cell",
|
|
56
|
+
"h3_cell",
|
|
57
|
+
"h3CellId",
|
|
58
|
+
"h3_cell_id",
|
|
59
|
+
"hexagon"
|
|
60
|
+
],
|
|
61
|
+
tokenToCell: (token) => getBigIntFromHexToken(token),
|
|
62
|
+
cellToToken: (cell) => getH3Token(cell),
|
|
63
|
+
cellToLngLat: (cell) => getH3LngLat(cell),
|
|
64
|
+
cellToBoundary: (cell) => getH3Boundary(cell),
|
|
65
|
+
cellToBoundaryFlat: (cell) => getH3Boundary(cell).flat(),
|
|
66
|
+
cellToBounds: (cell) => getDGGSCellBounds(getH3Boundary(cell))
|
|
67
|
+
};
|
|
68
|
+
function getH3Token(cell) {
|
|
69
|
+
return typeof cell === "bigint" ? cell.toString(16) : removeHexPrefix(cell);
|
|
70
|
+
}
|
|
71
|
+
function getH3LngLat(cell) {
|
|
72
|
+
const [latitude, longitude] = (0, import_h3_js.cellToLatLng)(getH3Token(cell));
|
|
73
|
+
return [longitude, latitude];
|
|
74
|
+
}
|
|
75
|
+
function getH3Boundary(cell) {
|
|
76
|
+
return (0, import_h3_js.cellToBoundary)(getH3Token(cell), true).map(([longitude, latitude]) => [
|
|
77
|
+
longitude,
|
|
78
|
+
latitude
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
function getBigIntFromHexToken(token) {
|
|
82
|
+
return BigInt(`0x${removeHexPrefix(token)}`);
|
|
83
|
+
}
|
|
84
|
+
function removeHexPrefix(token) {
|
|
85
|
+
return token.startsWith("0x") || token.startsWith("0X") ? token.slice(2) : token;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=h3.cjs.map
|
package/dist/h3.cjs.map
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/h3.ts", "../src/h3-decoder.ts", "../src/dggs-decoder.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;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gBAAgB,OAAa;AACpC,SAAO,MAAM,WAAW,IAAI,KAAK,MAAM,WAAW,IAAI,IAAI,MAAM,MAAM,CAAC,IAAI;AAC7E;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/dist/h3.d.ts
ADDED
package/dist/h3.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"h3.d.ts","sourceRoot":"","sources":["../src/h3.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,SAAS,EAAC,wBAAqB"}
|
package/dist/h3.js
ADDED
package/dist/h3.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"h3.js","sourceRoot":"","sources":["../src/h3.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,SAAS,EAAC,wBAAqB"}
|