@mailwoman/spatial 9.4.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.
Files changed (156) hide show
  1. package/README.md +2 -2
  2. package/lib/bbox.ts +41 -34
  3. package/lib/{coordinate-bounds.ts → coordinate/bounds.ts} +2 -2
  4. package/lib/{coordinate-formats.ts → coordinate/formats.ts} +11 -28
  5. package/lib/distance.ts +53 -27
  6. package/lib/feature.ts +2 -2
  7. package/lib/geometries/point.ts +41 -33
  8. package/lib/geometries/polygon.ts +24 -128
  9. package/lib/geometries/ring-blob.ts +33 -130
  10. package/lib/google/place-id.ts +4 -2
  11. package/lib/h3/cell.ts +21 -76
  12. package/lib/h3/coverage.ts +11 -7
  13. package/lib/h3/interior-cells.ts +13 -34
  14. package/lib/h3/polygon-cells.ts +59 -165
  15. package/lib/{h3/index.ts → h3.ts} +1 -1
  16. package/lib/index.ts +6 -6
  17. package/lib/objects.ts +6 -6
  18. package/lib/open-location-code.ts +11 -42
  19. package/lib/osgb36.ts +28 -187
  20. package/lib/polyline.ts +5 -3
  21. package/lib/position.ts +20 -4
  22. package/lib/projection/transform.ts +114 -0
  23. package/lib/projection.ts +1 -1
  24. package/lib/well-known-text.ts +8 -8
  25. package/out/bbox.d.ts +16 -13
  26. package/out/bbox.d.ts.map +1 -1
  27. package/out/bbox.js +32 -23
  28. package/out/bbox.js.map +1 -1
  29. package/out/{coordinate-bounds.d.ts → coordinate/bounds.d.ts} +3 -3
  30. package/out/coordinate/bounds.d.ts.map +1 -0
  31. package/out/{coordinate-bounds.js → coordinate/bounds.js} +3 -3
  32. package/out/coordinate/bounds.js.map +1 -0
  33. package/out/{coordinate-formats.d.ts → coordinate/formats.d.ts} +9 -12
  34. package/out/coordinate/formats.d.ts.map +1 -0
  35. package/out/{coordinate-formats.js → coordinate/formats.js} +12 -29
  36. package/out/coordinate/formats.js.map +1 -0
  37. package/out/distance.d.ts +48 -25
  38. package/out/distance.d.ts.map +1 -1
  39. package/out/distance.js +53 -27
  40. package/out/distance.js.map +1 -1
  41. package/out/feature.d.ts +2 -2
  42. package/out/feature.d.ts.map +1 -1
  43. package/out/geometries/point.d.ts +30 -22
  44. package/out/geometries/point.d.ts.map +1 -1
  45. package/out/geometries/point.js +35 -29
  46. package/out/geometries/point.js.map +1 -1
  47. package/out/geometries/polygon.d.ts +23 -122
  48. package/out/geometries/polygon.d.ts.map +1 -1
  49. package/out/geometries/polygon.js +13 -41
  50. package/out/geometries/polygon.js.map +1 -1
  51. package/out/geometries/ring-blob.d.ts +23 -109
  52. package/out/geometries/ring-blob.d.ts.map +1 -1
  53. package/out/geometries/ring-blob.js +29 -115
  54. package/out/geometries/ring-blob.js.map +1 -1
  55. package/out/{geometries/index.js → geometries.d.ts} +1 -1
  56. package/out/geometries.d.ts.map +1 -0
  57. package/out/{geometries/index.d.ts → geometries.js} +1 -1
  58. package/out/geometries.js.map +1 -0
  59. package/out/google/place-id.d.ts +4 -2
  60. package/out/google/place-id.d.ts.map +1 -1
  61. package/out/google/place-id.js.map +1 -1
  62. package/out/{google/index.d.ts → google.d.ts} +1 -1
  63. package/out/google.d.ts.map +1 -0
  64. package/out/{google/index.js → google.js} +1 -1
  65. package/out/google.js.map +1 -0
  66. package/out/h3/cell.d.ts +19 -73
  67. package/out/h3/cell.d.ts.map +1 -1
  68. package/out/h3/cell.js +20 -63
  69. package/out/h3/cell.js.map +1 -1
  70. package/out/h3/coverage.d.ts +11 -7
  71. package/out/h3/coverage.d.ts.map +1 -1
  72. package/out/h3/coverage.js +11 -7
  73. package/out/h3/coverage.js.map +1 -1
  74. package/out/h3/interior-cells.d.ts +9 -28
  75. package/out/h3/interior-cells.d.ts.map +1 -1
  76. package/out/h3/interior-cells.js +13 -32
  77. package/out/h3/interior-cells.js.map +1 -1
  78. package/out/h3/polygon-cells.d.ts +28 -120
  79. package/out/h3/polygon-cells.d.ts.map +1 -1
  80. package/out/h3/polygon-cells.js +48 -146
  81. package/out/h3/polygon-cells.js.map +1 -1
  82. package/out/{h3/index.d.ts → h3.d.ts} +2 -2
  83. package/out/h3.d.ts.map +1 -0
  84. package/out/{h3/index.js → h3.js} +2 -2
  85. package/out/h3.js.map +1 -0
  86. package/out/index.d.ts +6 -6
  87. package/out/index.d.ts.map +1 -1
  88. package/out/index.js +6 -6
  89. package/out/index.js.map +1 -1
  90. package/out/objects.d.ts +6 -6
  91. package/out/objects.d.ts.map +1 -1
  92. package/out/open-location-code.d.ts +11 -22
  93. package/out/open-location-code.d.ts.map +1 -1
  94. package/out/open-location-code.js +9 -40
  95. package/out/open-location-code.js.map +1 -1
  96. package/out/osgb36.d.ts +21 -97
  97. package/out/osgb36.d.ts.map +1 -1
  98. package/out/osgb36.js +12 -165
  99. package/out/osgb36.js.map +1 -1
  100. package/out/polyline.d.ts +5 -3
  101. package/out/polyline.d.ts.map +1 -1
  102. package/out/polyline.js +5 -3
  103. package/out/polyline.js.map +1 -1
  104. package/out/position.d.ts +17 -3
  105. package/out/position.d.ts.map +1 -1
  106. package/out/position.js +2 -2
  107. package/out/position.js.map +1 -1
  108. package/out/projection/transform.d.ts +70 -0
  109. package/out/projection/transform.d.ts.map +1 -0
  110. package/out/{projection-transform.js → projection/transform.js} +15 -17
  111. package/out/projection/transform.js.map +1 -0
  112. package/out/projection.d.ts +1 -1
  113. package/out/projection.d.ts.map +1 -1
  114. package/out/projection.js +1 -1
  115. package/out/regions/codes.d.ts.map +1 -1
  116. package/out/{regions/index.js → regions.d.ts} +1 -1
  117. package/out/regions.d.ts.map +1 -0
  118. package/out/{regions/index.d.ts → regions.js} +1 -1
  119. package/out/regions.js.map +1 -0
  120. package/out/tools/ogr/stream.d.ts +44 -0
  121. package/out/tools/ogr/stream.d.ts.map +1 -0
  122. package/out/tools/{ogr-stream.js → ogr/stream.js} +17 -10
  123. package/out/tools/ogr/stream.js.map +1 -0
  124. package/out/tools/ogr.d.ts +13 -10
  125. package/out/tools/ogr.d.ts.map +1 -1
  126. package/out/tools/ogr.js +18 -14
  127. package/out/tools/ogr.js.map +1 -1
  128. package/out/tools/tsconfig.tsbuildinfo +1 -0
  129. package/out/tsconfig.test.tsbuildinfo +1 -1
  130. package/out/well-known-text.d.ts +8 -8
  131. package/out/well-known-text.js +7 -7
  132. package/package.json +35 -127
  133. package/{lib/tools/ogr-stream.ts → tools/ogr/stream.ts} +25 -14
  134. package/{lib/tools → tools}/ogr.ts +26 -20
  135. package/lib/projection-transform.ts +0 -115
  136. package/out/coordinate-bounds.d.ts.map +0 -1
  137. package/out/coordinate-bounds.js.map +0 -1
  138. package/out/coordinate-formats.d.ts.map +0 -1
  139. package/out/coordinate-formats.js.map +0 -1
  140. package/out/geometries/index.d.ts.map +0 -1
  141. package/out/geometries/index.js.map +0 -1
  142. package/out/google/index.d.ts.map +0 -1
  143. package/out/google/index.js.map +0 -1
  144. package/out/h3/index.d.ts.map +0 -1
  145. package/out/h3/index.js.map +0 -1
  146. package/out/projection-transform.d.ts +0 -67
  147. package/out/projection-transform.d.ts.map +0 -1
  148. package/out/projection-transform.js.map +0 -1
  149. package/out/regions/index.d.ts.map +0 -1
  150. package/out/regions/index.js.map +0 -1
  151. package/out/tools/ogr-stream.d.ts +0 -34
  152. package/out/tools/ogr-stream.d.ts.map +0 -1
  153. package/out/tools/ogr-stream.js.map +0 -1
  154. /package/lib/{geometries/index.ts → geometries.ts} +0 -0
  155. /package/lib/{google/index.ts → google.ts} +0 -0
  156. /package/lib/{regions/index.ts → regions.ts} +0 -0
@@ -3,108 +3,43 @@
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 — the conversion SCOPE invariant 6 asks
7
- * for, done once at build time so the runtime probes structure instead of geometry.
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 type { MultiPolygonRings } from "#geometries/polygon";
62
10
  import { type H3Cell } from "#h3/cell";
63
11
  /**
64
- * The largest bounding-box cell estimate a single polyfill may reserve.
65
- *
66
- * H3-js allocates its output buffer from the polygon's bounding box before walking, so this is a memory ceiling rather
67
- * than a limit on real output: two million cells is sixteen megabytes of `uint64`, comfortably inside the WASM heap,
68
- * and the largest EA flood features exceed it by orders of magnitude at resolution 9 (the run that established this
69
- * failed with `Memory allocation failed (code: 13)`).
12
+ * The largest bounding-box cell estimate a single polyfill may reserve, a memory ceiling
13
+ * because h3-js allocates its output buffer from the polygon's bounding box before walking.
70
14
  */
71
15
  export declare const CELL_ESTIMATE_BUDGET = 2000000;
72
16
  /**
73
- * The coarsest resolution a feature may be pushed down to. Below this a "cell" is tens of thousands of square
74
- * kilometres and the index stops summarizing anything.
17
+ * The coarsest resolution a feature may be pushed down to, below which a cell is tens
18
+ * of thousands of square kilometers and the index stops summarizing anything.
75
19
  */
76
20
  export declare const MIN_INDEX_RESOLUTION = 4;
77
21
  /**
78
- * A rectangle in degrees, the shape every helper here prefilters on.
79
- */
80
- export interface DegreeBox {
81
- minLat: number;
82
- minLon: number;
83
- maxLat: number;
84
- maxLon: number;
85
- }
86
- /**
87
- * The two cell sets one feature produces, and the resolution they came out at.
22
+ * The two cell sets produced by one feature.
23
+ * The record also stores their resolution.
88
24
  */
89
25
  export interface FeatureCells {
90
26
  /**
91
- * The resolution this feature was indexed at — the target, or coarser where the target's estimate did not fit.
27
+ * The resolution this feature was indexed at — the target, or coarser
28
+ * where the target's estimate did not fit.
92
29
  */
93
30
  resolution: number;
94
31
  /**
95
- * Cells lying entirely inside the feature. A point in one of these is inside without a geometry read.
32
+ * Cells lying entirely inside the feature, so a point in one is inside without a geometry read.
96
33
  */
97
34
  whole: H3Cell[];
98
35
  /**
99
- * Cells the feature reaches but does not fill. A point in one of these needs the ray cast.
36
+ * Cells the feature reaches but does not fill, so a point in one needs the ray cast.
100
37
  */
101
38
  partial: H3Cell[];
102
39
  }
103
40
  /**
104
- * How many cells at `resolution` the feature's bounding box spans.
105
- *
106
- * The same quantity h3 reserves its buffer from, computed here so an oversized polyfill is never issued. Approximate on
107
- * purpose: it decides which resolution to ask for, not what the answer is.
41
+ * How many cells at `resolution` the feature's bounding box spans — the same quantity
42
+ * h3 reserves its buffer from, approximate on purpose.
108
43
  */
109
44
  export declare function estimateCellCount(polygons: MultiPolygonRings, resolution: number): number;
110
45
  /**
@@ -112,51 +47,30 @@ export declare function estimateCellCount(polygons: MultiPolygonRings, resolutio
112
47
  */
113
48
  export declare function resolutionForFeature(polygons: MultiPolygonRings, target: number): number;
114
49
  /**
115
- * Classify one feature's cells, at `targetResolution` or the coarsest resolution its bounding box allows.
116
- *
117
- * @param layerLabel Names the layer in every message, so a build log says which artifact refused rather than only which
118
- * feature.
119
- * @throws {Error} When the feature reaches no cell at all. That cannot happen with overlapping containment on a valid
120
- * ring, so it means the geometry is degenerate — and a silently skipped feature is an invented absence.
50
+ * Classify one feature's cells at `targetResolution` or the coarsest resolution its
51
+ * bounding box allows, throwing when the feature reaches no cell at all.
121
52
  */
122
53
  export declare function classifyFeatureCells(polygons: MultiPolygonRings, targetResolution: number, featureID: string, layerLabel?: string): FeatureCells;
123
54
  /**
124
- * Split a cell set into same-resolution groups — what `compactCells` requires, and what an adaptively-indexed layer
125
- * cannot assume it already has.
126
- *
127
- * Pooling mixed resolutions throws inside h3; compacting only the target-resolution group would silently drop every
128
- * coarsened feature's interior, which is the shape of failure that still produces an artifact.
55
+ * Split a cell set into same-resolution groups — what `compactCells` requires
56
+ * and an adaptively-indexed layer cannot assume it already has.
129
57
  */
130
58
  export declare function groupCellsByResolution(cells: Iterable<string>): string[][];
131
59
  /**
132
- * Compact a cell set that may span several resolutions.
60
+ * Compact a cell set that spans several resolutions by grouping its cells first.
133
61
  *
134
- * `compactCells` takes one resolution at a time, and an adaptively-indexed layer's coarsened features sit at another —
135
- * so the set is grouped before compaction rather than pooled. Pooling would throw; compacting only the
136
- * target-resolution group would silently drop every coarsened feature's interior, which is the shape of failure that
137
- * still produces an artifact.
62
+ * Cells from different resolutions cause h3 to throw when pooled.
138
63
  */
139
64
  export declare function compactAcrossResolutions(cells: Iterable<string>): string[];
140
65
  /**
141
- * The cells a probe walks for one index cell: the cell itself at the index resolution, and its parent at every other
142
- * resolution the layer stores.
66
+ * The probe visits the index cell at its own resolution.
143
67
  *
144
- * The stored rows sit at SEVERAL resolutions — each feature's whole tier is compacted parent-ward, and a polygon too
145
- * large for h3's allocator at the index resolution was indexed coarser — so a point is answered by walking its own
146
- * ancestor chain over every resolution the layer stores.
68
+ * At every other resolution stored by the layer, it visits the parent cell.
147
69
  */
148
70
  export declare function ancestorChainCells(indexCell: H3Cell, indexResolution: number, resolutions: readonly number[]): H3Cell[];
149
71
  /**
150
- * One classified feature's cell rows, ready for insertion — the whole set compacted, the partial set left at its own
151
- * resolution.
152
- *
153
- * SHARED BY EVERY POLYGON LAYER WHOSE CELL ROW NAMES A POLYGON rather than a class accumulated across features. There
154
- * is no product knowledge in it: compaction, the short-cell encoding and the belt-and-braces subtraction below are h3
155
- * and blob arithmetic, and a second copy is a second place for the subtraction to stop happening.
156
- *
157
- * COMPACTION IS PER FEATURE, which is what keeps a build's memory flat in row count with no temporary table: a row that
158
- * names one polygon is final the moment that polygon is classified. Only the WHOLE set is compacted — compacting the
159
- * fringe would claim it covers ground it does not.
72
+ * One classified feature's cell rows, ready for insertion — the whole set compacted,
73
+ * the partial set left at its own resolution.
160
74
  */
161
75
  export declare function featureCellRows(cells: FeatureCells): Array<{
162
76
  h3Cell: number;
@@ -164,19 +78,13 @@ export declare function featureCellRows(cells: FeatureCells): Array<{
164
78
  containment: "whole" | "partial";
165
79
  }>;
166
80
  /**
167
- * The coverage cell a row at `cell` belongs to.
168
- *
169
- * `cellToParent` of the finer cell, never a fresh `latLngToCell` at the coarse resolution: every existing reader in
170
- * 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
171
- * representative point would put a fringe row in a neighbouring coverage cell.
81
+ * The coverage cell a row at `cell` belongs to, derived with `cellToParent` rather than a
82
+ * fresh `latLngToCell` so a fringe row does not land in a neighboring coverage cell.
172
83
  */
173
84
  export declare function coverageCellFor(cell: H3Cell, coverageResolution: number): H3Cell;
174
85
  /**
175
- * Record the coverage cells one index cell falls in.
176
- *
177
- * An adaptively-coarsened cell can be COARSER than the coverage resolution, in which case it spans several coverage
178
- * cells and every one of them is recorded: a coarse cell counted against one arbitrary child would leave the others
179
- * reading as empty.
86
+ * Record the coverage cells one index cell falls in, so an adaptively-coarsened cell coarser
87
+ * than the coverage resolution counts against every child rather than one arbitrary child.
180
88
  */
181
89
  export declare function addCoverageCells(into: Set<number>, cell: H3Cell, cellResolution: number, coverageResolution: number): void;
182
90
  //# sourceMappingURL=polygon-cells.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"polygon-cells.d.ts","sourceRoot":"","sources":["../../lib/h3/polygon-cells.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAeH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtD;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,UAAY,CAAA;AAE7C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAA;AAErC;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACd;AAuDD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,CAAA;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAA;CACjB;AAED;;;;;GAKG;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;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CACnC,QAAQ,E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AAkB,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"}
@@ -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 — the conversion SCOPE invariant 6 asks
7
- * for, done once at build time so the runtime probes structure instead of geometry.
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. Below this a "cell" is tens of thousands of square
76
- * kilometres and the index stops summarizing anything.
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 metres, longitude scaled at the box's mid-latitude so the two are comparable.
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 more than one.
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, at `targetResolution` or the coarsest resolution its bounding box allows.
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
- // THE BUDGET IS A PREDICTION AND THE RETRY IS WHAT MAKES IT NON-FATAL. `estimateCellCount` is a bounding-box
164
- // approximation of what h3 will reserve, and h3's own reservation depends on the polygon's shape and on what the WASM
165
- // heap already holds — measured over the EA product, a run that had classified 350,000 features threw `Memory
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]`, which is the order an ingest emits. Converting
176
- // instead would put a transposition between the geometry and the index that nothing downstream could see.
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 PART THAT FITS INSIDE ONE CELL IS ANSWERED WITHOUT THE ALLOCATOR, and that is a fact rather than an
181
- // approximation: an H3 cell is convex, so a rectangle whose four corners all fall in one cell lies entirely
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
- // AN EMPTY ANSWER FOR A REAL PART IS AN ALLOCATOR FAILURE WEARING A RESULT'S CLOTHES, and it has to be caught
189
- // HERE rather than after the whole feature. h3-js sizes its output buffer with `_calloc`, and a `_calloc`
190
- // that fails returns the null pointer — which in WASM is ordinary writable memory, so the call reports
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, so its `full` set is empty and asking for it
201
- // is pure cost. Erring towards asking is safe — a missed whole cell becomes a partial one and the ray cast
202
- // still answers correctly — so the comparison is the permissive one.
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} — ${String(error.message)}`);
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 another; full wins, because the point
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, and what an adaptively-indexed layer
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 may span several resolutions.
174
+ * Compact a cell set that spans several resolutions by grouping its cells first.
254
175
  *
255
- * `compactCells` takes one resolution at a time, and an adaptively-indexed layer's coarsened features sit at another —
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 cells a probe walks for one index cell: the cell itself at the index resolution, and its parent at every other
269
- * resolution the layer stores.
186
+ * The probe visits the index cell at its own resolution.
270
187
  *
271
- * The stored rows sit at SEVERAL resolutions — each feature's whole tier is compacted parent-ward, and a polygon too
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, the partial set left at its own
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; the classifier already subtracts the whole set, and this is belt and braces
302
- // against a compaction that produced a parent the partial set also names.
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A;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 centre of that cell.
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=index.d.ts.map
16
+ //# sourceMappingURL=h3.d.ts.map
@@ -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 centre of that cell.
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=index.js.map
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"}