@mailwoman/spatial 10.0.0 → 10.1.0
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/README.md +2 -2
- package/lib/bbox.ts +41 -34
- package/lib/coordinate/bounds.ts +2 -2
- package/lib/coordinate/formats.ts +10 -27
- package/lib/distance.ts +53 -27
- package/lib/feature.ts +2 -2
- package/lib/geometries/point.ts +41 -33
- package/lib/geometries/polygon.ts +24 -128
- package/lib/geometries/ring-blob.ts +33 -130
- package/lib/google/place-id.ts +4 -2
- package/lib/h3/cell.ts +21 -76
- package/lib/h3/coverage.ts +11 -7
- package/lib/h3/interior-cells.ts +13 -34
- package/lib/h3/polygon-cells.ts +59 -165
- package/lib/{h3/index.ts → h3.ts} +1 -1
- package/lib/index.ts +5 -5
- package/lib/objects.ts +6 -6
- package/lib/open-location-code.ts +11 -42
- package/lib/osgb36.ts +28 -187
- package/lib/polyline.ts +5 -3
- package/lib/position.ts +18 -2
- package/lib/projection/transform.ts +39 -40
- package/lib/{projection/index.ts → projection.ts} +1 -1
- package/lib/well-known-text.ts +8 -8
- package/out/bbox.d.ts +17 -14
- package/out/bbox.d.ts.map +1 -1
- package/out/bbox.js +32 -23
- package/out/bbox.js.map +1 -1
- package/out/coordinate/bounds.d.ts +2 -2
- package/out/coordinate/bounds.js +2 -2
- package/out/coordinate/formats.d.ts +8 -11
- package/out/coordinate/formats.d.ts.map +1 -1
- package/out/coordinate/formats.js +10 -27
- package/out/coordinate/formats.js.map +1 -1
- package/out/distance.d.ts +48 -25
- package/out/distance.d.ts.map +1 -1
- package/out/distance.js +53 -27
- package/out/distance.js.map +1 -1
- package/out/feature.d.ts +2 -2
- package/out/feature.d.ts.map +1 -1
- package/out/geometries/point.d.ts +30 -22
- package/out/geometries/point.d.ts.map +1 -1
- package/out/geometries/point.js +35 -29
- package/out/geometries/point.js.map +1 -1
- package/out/geometries/polygon.d.ts +23 -122
- package/out/geometries/polygon.d.ts.map +1 -1
- package/out/geometries/polygon.js +13 -41
- package/out/geometries/polygon.js.map +1 -1
- package/out/geometries/ring-blob.d.ts +23 -109
- package/out/geometries/ring-blob.d.ts.map +1 -1
- package/out/geometries/ring-blob.js +29 -115
- package/out/geometries/ring-blob.js.map +1 -1
- package/out/{geometries/index.js → geometries.d.ts} +1 -1
- package/out/geometries.d.ts.map +1 -0
- package/out/{geometries/index.d.ts → geometries.js} +1 -1
- package/out/geometries.js.map +1 -0
- package/out/google/place-id.d.ts +4 -2
- package/out/google/place-id.d.ts.map +1 -1
- package/out/google/place-id.js.map +1 -1
- package/out/{google/index.d.ts → google.d.ts} +1 -1
- package/out/google.d.ts.map +1 -0
- package/out/{google/index.js → google.js} +1 -1
- package/out/google.js.map +1 -0
- package/out/h3/cell.d.ts +19 -73
- package/out/h3/cell.d.ts.map +1 -1
- package/out/h3/cell.js +20 -63
- package/out/h3/cell.js.map +1 -1
- package/out/h3/coverage.d.ts +11 -7
- package/out/h3/coverage.d.ts.map +1 -1
- package/out/h3/coverage.js +11 -7
- package/out/h3/coverage.js.map +1 -1
- package/out/h3/interior-cells.d.ts +9 -28
- package/out/h3/interior-cells.d.ts.map +1 -1
- package/out/h3/interior-cells.js +13 -32
- package/out/h3/interior-cells.js.map +1 -1
- package/out/h3/polygon-cells.d.ts +28 -120
- package/out/h3/polygon-cells.d.ts.map +1 -1
- package/out/h3/polygon-cells.js +48 -146
- package/out/h3/polygon-cells.js.map +1 -1
- package/out/{h3/index.d.ts → h3.d.ts} +2 -2
- package/out/h3.d.ts.map +1 -0
- package/out/{h3/index.js → h3.js} +2 -2
- package/out/h3.js.map +1 -0
- package/out/index.d.ts +5 -5
- package/out/index.d.ts.map +1 -1
- package/out/index.js +5 -5
- package/out/index.js.map +1 -1
- package/out/objects.d.ts +6 -6
- package/out/open-location-code.d.ts +11 -22
- package/out/open-location-code.d.ts.map +1 -1
- package/out/open-location-code.js +9 -40
- package/out/open-location-code.js.map +1 -1
- package/out/osgb36.d.ts +21 -97
- package/out/osgb36.d.ts.map +1 -1
- package/out/osgb36.js +12 -165
- package/out/osgb36.js.map +1 -1
- package/out/polyline.d.ts +5 -3
- package/out/polyline.d.ts.map +1 -1
- package/out/polyline.js +5 -3
- package/out/polyline.js.map +1 -1
- package/out/position.d.ts +16 -2
- package/out/position.d.ts.map +1 -1
- package/out/position.js.map +1 -1
- package/out/projection/transform.d.ts +30 -27
- package/out/projection/transform.d.ts.map +1 -1
- package/out/projection/transform.js +14 -16
- package/out/projection/transform.js.map +1 -1
- package/out/{projection/index.d.ts → projection.d.ts} +2 -2
- package/out/projection.d.ts.map +1 -0
- package/out/{projection/index.js → projection.js} +2 -2
- package/out/projection.js.map +1 -0
- package/out/{regions/index.js → regions.d.ts} +1 -1
- package/out/regions.d.ts.map +1 -0
- package/out/{regions/index.d.ts → regions.js} +1 -1
- package/out/regions.js.map +1 -0
- package/out/tools/ogr/stream.d.ts +21 -11
- package/out/tools/ogr/stream.d.ts.map +1 -1
- package/out/tools/ogr/stream.js +16 -9
- package/out/tools/ogr/stream.js.map +1 -1
- package/out/tools/{ogr/index.d.ts → ogr.d.ts} +14 -11
- package/out/tools/ogr.d.ts.map +1 -0
- package/out/tools/{ogr/index.js → ogr.js} +18 -14
- package/out/tools/ogr.js.map +1 -0
- package/out/tools/tsconfig.tsbuildinfo +1 -0
- package/out/tsconfig.test.tsbuildinfo +1 -1
- package/out/well-known-text.d.ts +8 -8
- package/out/well-known-text.js +7 -7
- package/package.json +35 -127
- package/{lib/tools → tools}/ogr/stream.ts +25 -14
- package/{lib/tools/ogr/index.ts → tools/ogr.ts} +25 -19
- package/out/geometries/index.d.ts.map +0 -1
- package/out/geometries/index.js.map +0 -1
- package/out/google/index.d.ts.map +0 -1
- package/out/google/index.js.map +0 -1
- package/out/h3/index.d.ts.map +0 -1
- package/out/h3/index.js.map +0 -1
- package/out/projection/index.d.ts.map +0 -1
- package/out/projection/index.js.map +0 -1
- package/out/regions/index.d.ts.map +0 -1
- package/out/regions/index.js.map +0 -1
- package/out/tools/ogr/index.d.ts.map +0 -1
- package/out/tools/ogr/index.js.map +0 -1
- /package/lib/{geometries/index.ts → geometries.ts} +0 -0
- /package/lib/{google/index.ts → google.ts} +0 -0
- /package/lib/{regions/index.ts → regions.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polygon-cells.d.ts","sourceRoot":"","sources":["../../lib/h3/polygon-cells.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"polygon-cells.d.ts","sourceRoot":"","sources":["../../lib/h3/polygon-cells.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,UAAY,CAAA;AAE7C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAA;AAgDrC;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC5B;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,CAAA;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAA;CACjB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAUzF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMxF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,QAAQ,EAAE,iBAAiB,EAC3B,gBAAgB,EAAE,MAAM,EACxB,SAAS,EAAE,MAAM,EACjB,UAAU,SAAkB,GAC1B,YAAY,CA8Fd;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,EAAE,CAe1E;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAQ1E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,SAAS,MAAM,EAAE,GAC5B,MAAM,EAAE,CAIV;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,KAAK,CAAC;IAC3D,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,OAAO,GAAG,SAAS,CAAA;CAChC,CAAC,CAwBD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,MAAM,CAEhF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC/B,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,EACjB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,EACtB,kBAAkB,EAAE,MAAM,GACxB,IAAI,CAgBN"}
|
package/out/h3/polygon-cells.js
CHANGED
|
@@ -3,81 +3,26 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* Turn one authority polygon into the H3 cells that summarize it
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* SHARED BY EVERY POLYGON LAYER RATHER THAN COPIED INTO EACH, because the traps below are properties of
|
|
10
|
-
* the TOOL rather than of any one product. `packages/flood` measured them; `packages/soil` inherits them
|
|
11
|
-
* unchanged; the layer contract's polygon-builder section states them as requirements. A second copy of
|
|
12
|
-
* an allocator guard is a second place for it to stop guarding.
|
|
13
|
-
*
|
|
14
|
-
* THE INDEX IS CELL-TOUCHES-POLYGON, NOT CENTRE-IN-POLYGON, AND A ZERO-CELL FEATURE FAILS THE BUILD.
|
|
15
|
-
* A polyfill keyed on cell centres drops every polygon smaller than a cell, and each dropped feature
|
|
16
|
-
* reads downstream as an absence. Measured: on Ireland's zoning layer `polygonToCells` returns zero cells
|
|
17
|
-
* for 86.8% of polygons at resolution 9, and the EA flood product's first row is a 128 m² square that
|
|
18
|
-
* `polygonToCells` misses at resolutions 7 through 10 while `containmentOverlapping` returns one cell for
|
|
19
|
-
* it. So the index takes overlapping containment, and {@link classifyFeatureCells} throws on a feature
|
|
20
|
-
* that reaches no cell rather than skipping it.
|
|
21
|
-
*
|
|
22
|
-
* THE `[lat, lng]` TRAP IS AVOIDED BY NOT ENTERING IT. h3-js reads a vertex as `[lat, lng]` in its
|
|
23
|
-
* default mode; every call here passes `isGeoJSON = true` and hands it GeoJSON-order `[lon, lat]` rings,
|
|
24
|
-
* which is the order an ingest already produces. Converting instead would put a transposition between the
|
|
25
|
-
* geometry and the index that nothing downstream could see.
|
|
26
|
-
*
|
|
27
|
-
* WHOLE AND PARTIAL ARE TWO POLYFILLS OF THE SAME RING, NOT A TEST WE INVENT. `containmentFull` is the
|
|
28
|
-
* cell set entirely inside the polygon; `containmentOverlapping` is the set that touches it at all. The
|
|
29
|
-
* difference is exactly the boundary fringe, which is where the geometry tier has to be consulted.
|
|
30
|
-
*
|
|
31
|
-
* MOST PARTS NEVER REACH h3 AT ALL, AND THAT IS THE POINT. The WASM heap is exhausted by CALL VOLUME, not
|
|
32
|
-
* by any one polygon: h3-js frees every buffer it allocates, so what accumulates over millions of
|
|
33
|
-
* interleaved tiny and large allocations is fragmentation. Three runs over the EA product died on the
|
|
34
|
-
* same feature after roughly 510,000 others — a 164 m² feature of 23 parts and 130 vertices that
|
|
35
|
-
* classifies in 35 ms at every resolution 9 through 4 in a fresh process. So the calls are removed rather
|
|
36
|
-
* than shrunk, in the two places where the answer is a fact about geometry: {@link enclosingCell} (a part
|
|
37
|
-
* whose bounding-box corners all fall in one cell lies inside it, because a cell is convex) and
|
|
38
|
-
* {@link canContainCell} (a part narrower than `edge × √3` cannot enclose a hexagon, so its
|
|
39
|
-
* `containmentFull` set is empty). Both were checked against the unconditional polyfill over 60,000 real
|
|
40
|
-
* features at resolution 9 with zero disagreements, and `packages/flood/test/unit/cells.test.ts` pins the
|
|
41
|
-
* comparison.
|
|
42
|
-
*
|
|
43
|
-
* A BIG POLYGON IS ALSO INDEXED COARSER, BECAUSE h3's ALLOCATOR IS SIZED FROM THE BOUNDING BOX.
|
|
44
|
-
* `polygonToCells` reserves room for the whole bounding box before it walks anything, so a long thin river
|
|
45
|
-
* polygon reserves the rectangle the river's meanders span rather than the river. Each feature is
|
|
46
|
-
* therefore indexed at the finest resolution whose bounding-box estimate fits {@link CELL_ESTIMATE_BUDGET},
|
|
47
|
-
* and the resolution it got is returned on the result. That is not a compromise bolted on: a coarse cell
|
|
48
|
-
* wholly inside a large polygon is exactly what `compactCells` would have produced anyway, so the whole
|
|
49
|
-
* tier is unchanged in meaning and only the fringe is coarser.
|
|
50
|
-
*
|
|
51
|
-
* AND THE ESTIMATE IS A PREDICTION, SO AN ALLOCATION FAILURE IS RECOVERED RATHER THAN FATAL.
|
|
52
|
-
* {@linkcode classifyFeatureCells} steps the resolution down and retries; only a feature that fails at
|
|
53
|
-
* {@linkcode MIN_INDEX_RESOLUTION} is refused. Nothing is ever skipped, because a skipped feature is an
|
|
54
|
-
* invented absence.
|
|
55
|
-
*
|
|
56
|
-
* BOUNDING THE CALL VOLUME IS THE CALLER'S JOB AND IT IS NOT OPTIONAL. The shortcuts here make a build
|
|
57
|
-
* faster; they are not what makes it reproducible. A builder runs the classification in child processes
|
|
58
|
-
* over ranges of the source's own stable ids, so each gets a heap that starts empty — see
|
|
59
|
-
* `packages/flood/lib/sdk/ingest/chunk.ts` and `packages/soil/lib/sdk/ingest/chunk.ts`.
|
|
6
|
+
* Turn one authority polygon into the H3 cells that summarize it, done once at build time so the
|
|
7
|
+
* runtime probes structure instead of geometry.
|
|
60
8
|
*/
|
|
61
9
|
import { cellToChildren, cellToParent, compactCells, getHexagonAreaAvg, getHexagonEdgeLengthAvg, getResolution, latLngToCell, polygonToCellsExperimental, POLYGON_TO_CELLS_FLAGS, } from "h3-js";
|
|
62
10
|
import { METRES_PER_DEGREE } from "#distance";
|
|
63
11
|
import { ringsBoundingBox } from "#geometries/ring-blob";
|
|
64
12
|
import { shortCellToInt } from "#h3/cell";
|
|
65
13
|
/**
|
|
66
|
-
* The largest bounding-box cell estimate a single polyfill may reserve
|
|
67
|
-
*
|
|
68
|
-
* H3-js allocates its output buffer from the polygon's bounding box before walking, so this is a memory ceiling rather
|
|
69
|
-
* than a limit on real output: two million cells is sixteen megabytes of `uint64`, comfortably inside the WASM heap,
|
|
70
|
-
* and the largest EA flood features exceed it by orders of magnitude at resolution 9 (the run that established this
|
|
71
|
-
* failed with `Memory allocation failed (code: 13)`).
|
|
14
|
+
* The largest bounding-box cell estimate a single polyfill may reserve, a memory ceiling
|
|
15
|
+
* because h3-js allocates its output buffer from the polygon's bounding box before walking.
|
|
72
16
|
*/
|
|
73
17
|
export const CELL_ESTIMATE_BUDGET = 2_000_000;
|
|
74
18
|
/**
|
|
75
|
-
* The coarsest resolution a feature may be pushed down to
|
|
76
|
-
*
|
|
19
|
+
* The coarsest resolution a feature may be pushed down to, below which a cell is tens
|
|
20
|
+
* of thousands of square kilometers and the index stops summarizing anything.
|
|
77
21
|
*/
|
|
78
22
|
export const MIN_INDEX_RESOLUTION = 4;
|
|
79
23
|
/**
|
|
80
|
-
* A degree box's height and width in
|
|
24
|
+
* A degree box's height and width in meters, longitude scaled at the box's
|
|
25
|
+
* mid-latitude so the two are comparable.
|
|
81
26
|
*/
|
|
82
27
|
function boxExtentMetres(box) {
|
|
83
28
|
const midLat = ((box.minLat + box.maxLat) / 2) * (Math.PI / 180);
|
|
@@ -87,12 +32,8 @@ function boxExtentMetres(box) {
|
|
|
87
32
|
};
|
|
88
33
|
}
|
|
89
34
|
/**
|
|
90
|
-
* The single cell containing this whole bounding box, or `undefined` when it spans
|
|
91
|
-
*
|
|
92
|
-
* An H3 cell is convex, so a rectangle whose four corners all fall in the same cell lies entirely inside it. That makes
|
|
93
|
-
* this an exact answer rather than an approximation, and it takes the WASM polyfill off the majority of a small-polygon
|
|
94
|
-
* product's parts: 38.8% of the EA flood features are under 11 m across, and most parts of the multi-part ones are
|
|
95
|
-
* smaller still.
|
|
35
|
+
* The single cell containing this whole bounding box, or `undefined` when it spans
|
|
36
|
+
* more than one — exact because an H3 cell is convex.
|
|
96
37
|
*/
|
|
97
38
|
function enclosingCell(box, resolution) {
|
|
98
39
|
if (!Number.isFinite(box.minLat))
|
|
@@ -109,12 +50,8 @@ function enclosingCell(box, resolution) {
|
|
|
109
50
|
return first;
|
|
110
51
|
}
|
|
111
52
|
/**
|
|
112
|
-
* Could a shape this size contain a whole cell
|
|
113
|
-
*
|
|
114
|
-
* A hexagon's minimum width is twice its inradius, and its inradius is `edge × √3/2` — so a bounding box narrower than
|
|
115
|
-
* `edge × √3` in either direction cannot enclose one, and the `containmentFull` polyfill is guaranteed to return
|
|
116
|
-
* nothing. The comparison is deliberately permissive: a wrong `true` costs one polyfill call, while a wrong `false`
|
|
117
|
-
* would demote a whole cell to a partial one, which the ray cast still answers correctly but more slowly.
|
|
53
|
+
* Could a shape this size contain a whole cell — false when either bounding-box dimension is
|
|
54
|
+
* under `edge × √3`, compared permissively because a wrong `true` only costs one polyfill call.
|
|
118
55
|
*/
|
|
119
56
|
function canContainCell(box, resolution) {
|
|
120
57
|
if (!Number.isFinite(box.minLat))
|
|
@@ -124,10 +61,8 @@ function canContainCell(box, resolution) {
|
|
|
124
61
|
return heightM >= minimumWidthM && widthM >= minimumWidthM;
|
|
125
62
|
}
|
|
126
63
|
/**
|
|
127
|
-
* How many cells at `resolution` the feature's bounding box spans
|
|
128
|
-
*
|
|
129
|
-
* The same quantity h3 reserves its buffer from, computed here so an oversized polyfill is never issued. Approximate on
|
|
130
|
-
* purpose: it decides which resolution to ask for, not what the answer is.
|
|
64
|
+
* How many cells at `resolution` the feature's bounding box spans — the same quantity
|
|
65
|
+
* h3 reserves its buffer from, approximate on purpose.
|
|
131
66
|
*/
|
|
132
67
|
export function estimateCellCount(polygons, resolution) {
|
|
133
68
|
const box = ringsBoundingBox(polygons);
|
|
@@ -149,57 +84,46 @@ export function resolutionForFeature(polygons, target) {
|
|
|
149
84
|
return MIN_INDEX_RESOLUTION;
|
|
150
85
|
}
|
|
151
86
|
/**
|
|
152
|
-
* Classify one feature's cells
|
|
153
|
-
*
|
|
154
|
-
* @param layerLabel Names the layer in every message, so a build log says which artifact refused rather than only which
|
|
155
|
-
* feature.
|
|
156
|
-
* @throws {Error} When the feature reaches no cell at all. That cannot happen with overlapping containment on a valid
|
|
157
|
-
* ring, so it means the geometry is degenerate — and a silently skipped feature is an invented absence.
|
|
87
|
+
* Classify one feature's cells at `targetResolution` or the coarsest resolution its
|
|
88
|
+
* bounding box allows, throwing when the feature reaches no cell at all.
|
|
158
89
|
*/
|
|
159
90
|
export function classifyFeatureCells(polygons, targetResolution, featureID, layerLabel = "polygon index") {
|
|
160
91
|
let resolution = resolutionForFeature(polygons, targetResolution);
|
|
161
92
|
let touched = new Set();
|
|
162
93
|
let full = new Set();
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
// allocation failed (code: 13)` on a feature that classified cleanly on its own. So an allocation failure steps the
|
|
167
|
-
// resolution down and tries again rather than ending the build, and only a feature that fails at
|
|
168
|
-
// {@link MIN_INDEX_RESOLUTION} is refused: a coarser cell is a real answer, and a skipped feature is an invented
|
|
169
|
-
// absence.
|
|
94
|
+
// `estimateCellCount` approximates what h3 will reserve, so an allocation failure
|
|
95
|
+
// steps the resolution down and retries rather than ending the build. a feature
|
|
96
|
+
// that fails at {@link MIN_INDEX_RESOLUTION} is refused.
|
|
170
97
|
for (;;) {
|
|
171
98
|
try {
|
|
172
99
|
touched = new Set();
|
|
173
100
|
full = new Set();
|
|
174
101
|
for (const rings of polygons) {
|
|
175
|
-
// `isGeoJSON = true`: the rings are already `[lon, lat]`,
|
|
176
|
-
//
|
|
102
|
+
// `isGeoJSON = true`: the rings are already `[lon, lat]`, so converting would
|
|
103
|
+
// put a transposition between the geometry and the index.
|
|
177
104
|
const geoJSONRings = rings;
|
|
178
105
|
const box = ringsBoundingBox([rings]);
|
|
179
106
|
const enclosing = enclosingCell(box, resolution);
|
|
180
|
-
// A
|
|
181
|
-
//
|
|
182
|
-
// within it. Such a part touches exactly that cell and fills none of it.
|
|
107
|
+
// A part that fits inside one cell is answered without the allocator: an H3 cell
|
|
108
|
+
// is convex, so a rectangle whose corners share a cell lies entirely within it.
|
|
183
109
|
if (enclosing) {
|
|
184
110
|
touched.add(enclosing);
|
|
185
111
|
continue;
|
|
186
112
|
}
|
|
187
113
|
const overlapping = polygonToCellsExperimental(geoJSONRings, resolution, POLYGON_TO_CELLS_FLAGS.containmentOverlapping, true);
|
|
188
|
-
//
|
|
189
|
-
//
|
|
190
|
-
//
|
|
191
|
-
// success and the reader hands back an array of zeros, i.e. nothing. Every part with a non-degenerate
|
|
192
|
-
// bounding box touches at least one cell, so zero is impossible as an answer. Checking per FEATURE instead
|
|
193
|
-
// would pass any multi-part feature whose other parts happened to answer, and silently index it short.
|
|
114
|
+
// An empty answer for a real part is an allocator failure rather than a result: every part
|
|
115
|
+
// with a non-degenerate bounding box touches at least one cell, so zero is impossible as
|
|
116
|
+
// an answer and checking per feature would silently index a multi-part feature short.
|
|
194
117
|
if (!overlapping.length) {
|
|
195
118
|
throw new Error(`${layerLabel}: part of feature ${featureID} spanning ${box.minLat},${box.minLon} to ${box.maxLat},${box.maxLon} returned no cell at resolution ${resolution} — a part always touches at least one, so this is an allocator failure reported as an answer`);
|
|
196
119
|
}
|
|
197
120
|
for (const cell of overlapping) {
|
|
198
121
|
touched.add(cell);
|
|
199
122
|
}
|
|
200
|
-
// A part narrower than a cell's minimum width cannot contain one,
|
|
201
|
-
//
|
|
202
|
-
//
|
|
123
|
+
// A part narrower than a cell's minimum width cannot contain one,
|
|
124
|
+
// so its `full` set is empty and asking for it is pure cost.
|
|
125
|
+
// The comparison is permissive because a missed whole cell becomes a
|
|
126
|
+
// partial one the ray cast still answers.
|
|
203
127
|
if (!canContainCell(box, resolution))
|
|
204
128
|
continue;
|
|
205
129
|
for (const cell of polygonToCellsExperimental(geoJSONRings, resolution, POLYGON_TO_CELLS_FLAGS.containmentFull, true)) {
|
|
@@ -210,7 +134,7 @@ export function classifyFeatureCells(polygons, targetResolution, featureID, laye
|
|
|
210
134
|
}
|
|
211
135
|
catch (error) {
|
|
212
136
|
if (resolution <= MIN_INDEX_RESOLUTION) {
|
|
213
|
-
throw new Error(`${layerLabel}: feature ${featureID} could not be indexed at any resolution down to ${MIN_INDEX_RESOLUTION}
|
|
137
|
+
throw new Error(`${layerLabel}: feature ${featureID} could not be indexed at any resolution down to ${MIN_INDEX_RESOLUTION}`, { cause: error });
|
|
214
138
|
}
|
|
215
139
|
resolution--;
|
|
216
140
|
}
|
|
@@ -218,8 +142,8 @@ export function classifyFeatureCells(polygons, targetResolution, featureID, laye
|
|
|
218
142
|
if (!touched.size) {
|
|
219
143
|
throw new Error(`${layerLabel}: feature ${featureID} reaches no cell at resolution ${resolution} — a feature indexed to nothing reads downstream as an absence, which is the one answer a layer must never invent`);
|
|
220
144
|
}
|
|
221
|
-
// A cell can be full for one polygon of a MultiPolygon and merely touched by
|
|
222
|
-
// is inside either way.
|
|
145
|
+
// A cell can be full for one polygon of a MultiPolygon and merely touched by
|
|
146
|
+
// another. full wins because the point is inside either way.
|
|
223
147
|
const partial = [];
|
|
224
148
|
for (const cell of touched) {
|
|
225
149
|
if (!full.has(cell)) {
|
|
@@ -229,11 +153,8 @@ export function classifyFeatureCells(polygons, targetResolution, featureID, laye
|
|
|
229
153
|
return { resolution, whole: [...full], partial };
|
|
230
154
|
}
|
|
231
155
|
/**
|
|
232
|
-
* Split a cell set into same-resolution groups — what `compactCells` requires
|
|
233
|
-
* cannot assume it already has.
|
|
234
|
-
*
|
|
235
|
-
* Pooling mixed resolutions throws inside h3; compacting only the target-resolution group would silently drop every
|
|
236
|
-
* coarsened feature's interior, which is the shape of failure that still produces an artifact.
|
|
156
|
+
* Split a cell set into same-resolution groups — what `compactCells` requires
|
|
157
|
+
* and an adaptively-indexed layer cannot assume it already has.
|
|
237
158
|
*/
|
|
238
159
|
export function groupCellsByResolution(cells) {
|
|
239
160
|
const groups = new Map();
|
|
@@ -250,12 +171,9 @@ export function groupCellsByResolution(cells) {
|
|
|
250
171
|
return [...groups.values()];
|
|
251
172
|
}
|
|
252
173
|
/**
|
|
253
|
-
* Compact a cell set that
|
|
174
|
+
* Compact a cell set that spans several resolutions by grouping its cells first.
|
|
254
175
|
*
|
|
255
|
-
*
|
|
256
|
-
* so the set is grouped before compaction rather than pooled. Pooling would throw; compacting only the
|
|
257
|
-
* target-resolution group would silently drop every coarsened feature's interior, which is the shape of failure that
|
|
258
|
-
* still produces an artifact.
|
|
176
|
+
* Cells from different resolutions cause h3 to throw when pooled.
|
|
259
177
|
*/
|
|
260
178
|
export function compactAcrossResolutions(cells) {
|
|
261
179
|
const compacted = [];
|
|
@@ -265,27 +183,16 @@ export function compactAcrossResolutions(cells) {
|
|
|
265
183
|
return compacted;
|
|
266
184
|
}
|
|
267
185
|
/**
|
|
268
|
-
* The
|
|
269
|
-
* resolution the layer stores.
|
|
186
|
+
* The probe visits the index cell at its own resolution.
|
|
270
187
|
*
|
|
271
|
-
*
|
|
272
|
-
* large for h3's allocator at the index resolution was indexed coarser — so a point is answered by walking its own
|
|
273
|
-
* ancestor chain over every resolution the layer stores.
|
|
188
|
+
* At every other resolution stored by the layer, it visits the parent cell.
|
|
274
189
|
*/
|
|
275
190
|
export function ancestorChainCells(indexCell, indexResolution, resolutions) {
|
|
276
191
|
return resolutions.map((resolution) => resolution === indexResolution ? indexCell : cellToParent(indexCell, resolution));
|
|
277
192
|
}
|
|
278
193
|
/**
|
|
279
|
-
* One classified feature's cell rows, ready for insertion — the whole set compacted,
|
|
280
|
-
* resolution.
|
|
281
|
-
*
|
|
282
|
-
* SHARED BY EVERY POLYGON LAYER WHOSE CELL ROW NAMES A POLYGON rather than a class accumulated across features. There
|
|
283
|
-
* is no product knowledge in it: compaction, the short-cell encoding and the belt-and-braces subtraction below are h3
|
|
284
|
-
* and blob arithmetic, and a second copy is a second place for the subtraction to stop happening.
|
|
285
|
-
*
|
|
286
|
-
* COMPACTION IS PER FEATURE, which is what keeps a build's memory flat in row count with no temporary table: a row that
|
|
287
|
-
* names one polygon is final the moment that polygon is classified. Only the WHOLE set is compacted — compacting the
|
|
288
|
-
* fringe would claim it covers ground it does not.
|
|
194
|
+
* One classified feature's cell rows, ready for insertion — the whole set compacted,
|
|
195
|
+
* the partial set left at its own resolution.
|
|
289
196
|
*/
|
|
290
197
|
export function featureCellRows(cells) {
|
|
291
198
|
const rows = [];
|
|
@@ -298,8 +205,9 @@ export function featureCellRows(cells) {
|
|
|
298
205
|
}
|
|
299
206
|
for (const cell of cells.partial) {
|
|
300
207
|
const short = shortCellToInt(cell);
|
|
301
|
-
// A cell cannot be both for one polygon
|
|
302
|
-
// against a compaction that produced a
|
|
208
|
+
// A cell cannot be both for one polygon.
|
|
209
|
+
// This subtraction is belt and braces against a compaction that produced a
|
|
210
|
+
// parent the partial set also names.
|
|
303
211
|
if (wholeShort.has(short))
|
|
304
212
|
continue;
|
|
305
213
|
rows.push({ h3Cell: short, resolution: cells.resolution, containment: "partial" });
|
|
@@ -307,21 +215,15 @@ export function featureCellRows(cells) {
|
|
|
307
215
|
return rows;
|
|
308
216
|
}
|
|
309
217
|
/**
|
|
310
|
-
* The coverage cell a row at `cell` belongs to
|
|
311
|
-
*
|
|
312
|
-
* `cellToParent` of the finer cell, never a fresh `latLngToCell` at the coarse resolution: every existing reader in
|
|
313
|
-
* this repo derives a coverage cell that way, and the two agree for a point but not for a cell — a re-derivation from a
|
|
314
|
-
* representative point would put a fringe row in a neighbouring coverage cell.
|
|
218
|
+
* The coverage cell a row at `cell` belongs to, derived with `cellToParent` rather than a
|
|
219
|
+
* fresh `latLngToCell` so a fringe row does not land in a neighboring coverage cell.
|
|
315
220
|
*/
|
|
316
221
|
export function coverageCellFor(cell, coverageResolution) {
|
|
317
222
|
return cellToParent(cell, coverageResolution);
|
|
318
223
|
}
|
|
319
224
|
/**
|
|
320
|
-
* Record the coverage cells one index cell falls in
|
|
321
|
-
*
|
|
322
|
-
* An adaptively-coarsened cell can be COARSER than the coverage resolution, in which case it spans several coverage
|
|
323
|
-
* cells and every one of them is recorded: a coarse cell counted against one arbitrary child would leave the others
|
|
324
|
-
* reading as empty.
|
|
225
|
+
* Record the coverage cells one index cell falls in, so an adaptively-coarsened cell coarser
|
|
226
|
+
* than the coverage resolution counts against every child rather than one arbitrary child.
|
|
325
227
|
*/
|
|
326
228
|
export function addCoverageCells(into, cell, cellResolution, coverageResolution) {
|
|
327
229
|
if (cellResolution === coverageResolution) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polygon-cells.js","sourceRoot":"","sources":["../../lib/h3/polygon-cells.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"polygon-cells.js","sourceRoot":"","sources":["../../lib/h3/polygon-cells.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACvB,aAAa,EACb,YAAY,EACZ,0BAA0B,EAC1B,sBAAsB,GACtB,MAAM,OAAO,CAAA;AAGd,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAe,MAAM,UAAU,CAAA;AAEtD;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAA;AAE7C;;;GAGG;AACH,M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CAAA;QAEnE,OAAM;IACP,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,EAAE,CAAC;QAC9D,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,KAAe,CAAC,CAAC,CAAA;IAC1C,CAAC;AACF,CAAC"}
|
|
@@ -9,8 +9,8 @@ export * from "#h3/cell";
|
|
|
9
9
|
export * from "#h3/interior-cells";
|
|
10
10
|
export * from "#h3/polygon-cells";
|
|
11
11
|
/**
|
|
12
|
-
* Given a short cell address and the resolution it was captured at, return the
|
|
12
|
+
* Given a short cell address and the resolution it was captured at, return the center of that cell.
|
|
13
13
|
*/
|
|
14
14
|
export declare function shortCellToPoint(shortCell: H3CellShort, resolution?: number): GeoPoint;
|
|
15
15
|
export declare function cellToPointLiteral(cell: H3Cell): PointLiteral;
|
|
16
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=h3.d.ts.map
|
package/out/h3.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"h3.d.ts","sourceRoot":"","sources":["../lib/h3.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAgB,MAAM,UAAU,CAAA;AAEtE,cAAc,UAAU,CAAA;AACxB,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AAEjC;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,SAAK,GAAG,QAAQ,CAOlF;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAO7D"}
|
|
@@ -10,7 +10,7 @@ export * from "#h3/cell";
|
|
|
10
10
|
export * from "#h3/interior-cells";
|
|
11
11
|
export * from "#h3/polygon-cells";
|
|
12
12
|
/**
|
|
13
|
-
* Given a short cell address and the resolution it was captured at, return the
|
|
13
|
+
* Given a short cell address and the resolution it was captured at, return the center of that cell.
|
|
14
14
|
*/
|
|
15
15
|
export function shortCellToPoint(shortCell, resolution = 15) {
|
|
16
16
|
const cell = expandH3Cell(shortCell, resolution);
|
|
@@ -25,4 +25,4 @@ export function cellToPointLiteral(cell) {
|
|
|
25
25
|
coordinates: [longitude, latitude],
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
//# sourceMappingURL=
|
|
28
|
+
//# sourceMappingURL=h3.js.map
|
package/out/h3.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"h3.js","sourceRoot":"","sources":["../lib/h3.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,OAAO,EAAE,QAAQ,EAAqB,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAiC,YAAY,EAAE,MAAM,UAAU,CAAA;AAEtE,cAAc,UAAU,CAAA;AACxB,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AAEjC;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAsB,EAAE,UAAU,GAAG,EAAE;IACvE,MAAM,IAAI,GAAG,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;IAEhD,2DAA2D;IAC3D,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;IAEhD,OAAO,IAAI,QAAQ,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAA;AAC3C,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC9C,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;IAEhD,OAAO;QACN,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;KAClC,CAAA;AACF,CAAC"}
|
package/out/index.d.ts
CHANGED
|
@@ -9,13 +9,13 @@ export * from "#coordinate/bounds";
|
|
|
9
9
|
export * from "#distance";
|
|
10
10
|
export * from "#feature";
|
|
11
11
|
export * from "#open-location-code";
|
|
12
|
-
export * from "#geometries
|
|
13
|
-
export * from "#google
|
|
14
|
-
export * from "#h3
|
|
12
|
+
export * from "#geometries";
|
|
13
|
+
export * from "#google";
|
|
14
|
+
export * from "#h3";
|
|
15
15
|
export * from "#objects";
|
|
16
16
|
export * from "#osgb36";
|
|
17
17
|
export * from "#polyline";
|
|
18
18
|
export * from "#position";
|
|
19
|
-
export * from "#projection
|
|
20
|
-
export * from "#regions
|
|
19
|
+
export * from "#projection";
|
|
20
|
+
export * from "#regions";
|
|
21
21
|
//# sourceMappingURL=index.d.ts.map
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,OAAO,CAAA;AACrB,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,OAAO,CAAA;AACrB,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,KAAK,CAAA;AACnB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA"}
|
package/out/index.js
CHANGED
|
@@ -9,13 +9,13 @@ export * from "#coordinate/bounds";
|
|
|
9
9
|
export * from "#distance";
|
|
10
10
|
export * from "#feature";
|
|
11
11
|
export * from "#open-location-code";
|
|
12
|
-
export * from "#geometries
|
|
13
|
-
export * from "#google
|
|
14
|
-
export * from "#h3
|
|
12
|
+
export * from "#geometries";
|
|
13
|
+
export * from "#google";
|
|
14
|
+
export * from "#h3";
|
|
15
15
|
export * from "#objects";
|
|
16
16
|
export * from "#osgb36";
|
|
17
17
|
export * from "#polyline";
|
|
18
18
|
export * from "#position";
|
|
19
|
-
export * from "#projection
|
|
20
|
-
export * from "#regions
|
|
19
|
+
export * from "#projection";
|
|
20
|
+
export * from "#regions";
|
|
21
21
|
//# sourceMappingURL=index.js.map
|
package/out/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,OAAO,CAAA;AACrB,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,OAAO,CAAA;AACrB,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,KAAK,CAAA;AACnB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA"}
|
package/out/objects.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ export declare const GeometryType: {
|
|
|
24
24
|
/**
|
|
25
25
|
* The base GeoJSON object.
|
|
26
26
|
*
|
|
27
|
-
* The GeoJSON specification also allows foreign members
|
|
28
|
-
* included in the object.
|
|
27
|
+
* The GeoJSON specification also allows foreign members
|
|
28
|
+
* (https://tools.ietf.org/html/rfc7946#section-6.1) to be included in the object.
|
|
29
29
|
*
|
|
30
30
|
* @title Geo Object
|
|
31
31
|
* @public
|
|
@@ -37,14 +37,14 @@ export interface GeoObjectLiteral {
|
|
|
37
37
|
*/
|
|
38
38
|
type: GeometryType;
|
|
39
39
|
/**
|
|
40
|
-
* A unique identifier for the feature, such as a
|
|
40
|
+
* A unique identifier for the feature, such as a uuid, a serial number, or a name.
|
|
41
41
|
*/
|
|
42
42
|
id?: string | number | undefined | null;
|
|
43
43
|
/**
|
|
44
44
|
* A bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections.
|
|
45
45
|
*
|
|
46
|
-
* This is useful when defining the extent of a GeoJSON object, i.e. the minimum
|
|
47
|
-
* object's Geometries, Features, or Feature Collections.
|
|
46
|
+
* This is useful when defining the extent of a GeoJSON object, i.e. the minimum
|
|
47
|
+
* and maximum coordinates of the object's Geometries, Features, or Feature Collections.
|
|
48
48
|
*
|
|
49
49
|
* @see {@link https://tools.ietf.org/html/rfc7946#section-5 GeoJSON Bounding Boxes}
|
|
50
50
|
*/
|
|
@@ -61,7 +61,7 @@ export interface GeoObjectLiteral {
|
|
|
61
61
|
/**
|
|
62
62
|
* The name of the coordinate reference system.
|
|
63
63
|
*
|
|
64
|
-
* @default "
|
|
64
|
+
* @default "epsg:4326"
|
|
65
65
|
*/
|
|
66
66
|
name: string;
|
|
67
67
|
};
|
|
@@ -2,22 +2,10 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* Open Location Code (plus code) decode + nearest-recovery — the coordinate system Google Maps
|
|
7
|
-
* prints on every place card, which makes it a first-class user register in countries with sparse
|
|
8
|
-
* street addressing (the Nicaraguan board rows arrived exactly this way). Pure arithmetic over the
|
|
9
|
-
* published spec (https://github.com/google/open-location-code/blob/main/docs/specification.md);
|
|
10
|
-
* no dependency, no I/O.
|
|
11
|
-
*
|
|
12
|
-
* A FULL code (8 digits, a `+`, then 2–3 more) decodes directly. A SHORT code (2–6 leading digits
|
|
13
|
-
* removed, e.g. `VFQ6+92P`) is only meaningful near a reference point — the removed prefix is
|
|
14
|
-
* recovered from the reference, then the candidate cell is shifted by whole prefix-resolutions if
|
|
15
|
-
* a neighboring cell sits closer (the spec's `recoverNearest`). The reference in an address is the
|
|
16
|
-
* RESOLVED LOCALITY, which is why the geocode wiring recovers after the admin walk.
|
|
17
5
|
*/
|
|
18
6
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
7
|
+
* Describes a decoded plus-code cell by its center and its span in degrees, from
|
|
8
|
+
* which callers derive an uncertainty radius.
|
|
21
9
|
*/
|
|
22
10
|
export interface DecodedPlusCode {
|
|
23
11
|
lat: number;
|
|
@@ -26,23 +14,24 @@ export interface DecodedPlusCode {
|
|
|
26
14
|
lonSpanDeg: number;
|
|
27
15
|
}
|
|
28
16
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
17
|
+
* Returns true for a full plus code of exactly 8 digits, `+`, and 2 or 3 digits.
|
|
18
|
+
*
|
|
19
|
+
* It rejects the padded and longer forms the spec allows, since addresses use only the 10–11 digit form.
|
|
31
20
|
*/
|
|
32
21
|
export declare function isFullPlusCode(token: string): boolean;
|
|
33
22
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
23
|
+
* Returns true for a short plus code with 2, 4 or 6 digits before the `+`,
|
|
24
|
+
* such as the `VFQ6+92P` form Google prints on place cards.
|
|
36
25
|
*/
|
|
37
26
|
export declare function isShortPlusCode(token: string): boolean;
|
|
38
27
|
/**
|
|
39
|
-
*
|
|
28
|
+
* Decodes a full plus code to its cell, returning null for anything {@link isFullPlusCode} rejects.
|
|
40
29
|
*/
|
|
41
30
|
export declare function decodePlusCode(code: string): DecodedPlusCode | null;
|
|
42
31
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
32
|
+
* Recovers a short plus code to the matching cell nearest a reference coordinate,
|
|
33
|
+
* following the spec's `recoverNearest`.
|
|
34
|
+
* It returns null for an invalid short code.
|
|
46
35
|
*/
|
|
47
36
|
export declare function recoverNearestPlusCode(shortCode: string, refLat: number, refLon: number): DecodedPlusCode | null;
|
|
48
37
|
//# sourceMappingURL=open-location-code.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-location-code.d.ts","sourceRoot":"","sources":["../lib/open-location-code.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"open-location-code.d.ts","sourceRoot":"","sources":["../lib/open-location-code.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CAClB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAmCnE;AAuBD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CA2BhH"}
|