@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.
Files changed (145) hide show
  1. package/README.md +2 -2
  2. package/lib/bbox.ts +41 -34
  3. package/lib/coordinate/bounds.ts +2 -2
  4. package/lib/coordinate/formats.ts +10 -27
  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 +5 -5
  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 +18 -2
  22. package/lib/projection/transform.ts +39 -40
  23. package/lib/{projection/index.ts → projection.ts} +1 -1
  24. package/lib/well-known-text.ts +8 -8
  25. package/out/bbox.d.ts +17 -14
  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 +2 -2
  30. package/out/coordinate/bounds.js +2 -2
  31. package/out/coordinate/formats.d.ts +8 -11
  32. package/out/coordinate/formats.d.ts.map +1 -1
  33. package/out/coordinate/formats.js +10 -27
  34. package/out/coordinate/formats.js.map +1 -1
  35. package/out/distance.d.ts +48 -25
  36. package/out/distance.d.ts.map +1 -1
  37. package/out/distance.js +53 -27
  38. package/out/distance.js.map +1 -1
  39. package/out/feature.d.ts +2 -2
  40. package/out/feature.d.ts.map +1 -1
  41. package/out/geometries/point.d.ts +30 -22
  42. package/out/geometries/point.d.ts.map +1 -1
  43. package/out/geometries/point.js +35 -29
  44. package/out/geometries/point.js.map +1 -1
  45. package/out/geometries/polygon.d.ts +23 -122
  46. package/out/geometries/polygon.d.ts.map +1 -1
  47. package/out/geometries/polygon.js +13 -41
  48. package/out/geometries/polygon.js.map +1 -1
  49. package/out/geometries/ring-blob.d.ts +23 -109
  50. package/out/geometries/ring-blob.d.ts.map +1 -1
  51. package/out/geometries/ring-blob.js +29 -115
  52. package/out/geometries/ring-blob.js.map +1 -1
  53. package/out/{geometries/index.js → geometries.d.ts} +1 -1
  54. package/out/geometries.d.ts.map +1 -0
  55. package/out/{geometries/index.d.ts → geometries.js} +1 -1
  56. package/out/geometries.js.map +1 -0
  57. package/out/google/place-id.d.ts +4 -2
  58. package/out/google/place-id.d.ts.map +1 -1
  59. package/out/google/place-id.js.map +1 -1
  60. package/out/{google/index.d.ts → google.d.ts} +1 -1
  61. package/out/google.d.ts.map +1 -0
  62. package/out/{google/index.js → google.js} +1 -1
  63. package/out/google.js.map +1 -0
  64. package/out/h3/cell.d.ts +19 -73
  65. package/out/h3/cell.d.ts.map +1 -1
  66. package/out/h3/cell.js +20 -63
  67. package/out/h3/cell.js.map +1 -1
  68. package/out/h3/coverage.d.ts +11 -7
  69. package/out/h3/coverage.d.ts.map +1 -1
  70. package/out/h3/coverage.js +11 -7
  71. package/out/h3/coverage.js.map +1 -1
  72. package/out/h3/interior-cells.d.ts +9 -28
  73. package/out/h3/interior-cells.d.ts.map +1 -1
  74. package/out/h3/interior-cells.js +13 -32
  75. package/out/h3/interior-cells.js.map +1 -1
  76. package/out/h3/polygon-cells.d.ts +28 -120
  77. package/out/h3/polygon-cells.d.ts.map +1 -1
  78. package/out/h3/polygon-cells.js +48 -146
  79. package/out/h3/polygon-cells.js.map +1 -1
  80. package/out/{h3/index.d.ts → h3.d.ts} +2 -2
  81. package/out/h3.d.ts.map +1 -0
  82. package/out/{h3/index.js → h3.js} +2 -2
  83. package/out/h3.js.map +1 -0
  84. package/out/index.d.ts +5 -5
  85. package/out/index.d.ts.map +1 -1
  86. package/out/index.js +5 -5
  87. package/out/index.js.map +1 -1
  88. package/out/objects.d.ts +6 -6
  89. package/out/open-location-code.d.ts +11 -22
  90. package/out/open-location-code.d.ts.map +1 -1
  91. package/out/open-location-code.js +9 -40
  92. package/out/open-location-code.js.map +1 -1
  93. package/out/osgb36.d.ts +21 -97
  94. package/out/osgb36.d.ts.map +1 -1
  95. package/out/osgb36.js +12 -165
  96. package/out/osgb36.js.map +1 -1
  97. package/out/polyline.d.ts +5 -3
  98. package/out/polyline.d.ts.map +1 -1
  99. package/out/polyline.js +5 -3
  100. package/out/polyline.js.map +1 -1
  101. package/out/position.d.ts +16 -2
  102. package/out/position.d.ts.map +1 -1
  103. package/out/position.js.map +1 -1
  104. package/out/projection/transform.d.ts +30 -27
  105. package/out/projection/transform.d.ts.map +1 -1
  106. package/out/projection/transform.js +14 -16
  107. package/out/projection/transform.js.map +1 -1
  108. package/out/{projection/index.d.ts → projection.d.ts} +2 -2
  109. package/out/projection.d.ts.map +1 -0
  110. package/out/{projection/index.js → projection.js} +2 -2
  111. package/out/projection.js.map +1 -0
  112. package/out/{regions/index.js → regions.d.ts} +1 -1
  113. package/out/regions.d.ts.map +1 -0
  114. package/out/{regions/index.d.ts → regions.js} +1 -1
  115. package/out/regions.js.map +1 -0
  116. package/out/tools/ogr/stream.d.ts +21 -11
  117. package/out/tools/ogr/stream.d.ts.map +1 -1
  118. package/out/tools/ogr/stream.js +16 -9
  119. package/out/tools/ogr/stream.js.map +1 -1
  120. package/out/tools/{ogr/index.d.ts → ogr.d.ts} +14 -11
  121. package/out/tools/ogr.d.ts.map +1 -0
  122. package/out/tools/{ogr/index.js → ogr.js} +18 -14
  123. package/out/tools/ogr.js.map +1 -0
  124. package/out/tools/tsconfig.tsbuildinfo +1 -0
  125. package/out/tsconfig.test.tsbuildinfo +1 -1
  126. package/out/well-known-text.d.ts +8 -8
  127. package/out/well-known-text.js +7 -7
  128. package/package.json +35 -127
  129. package/{lib/tools → tools}/ogr/stream.ts +25 -14
  130. package/{lib/tools/ogr/index.ts → tools/ogr.ts} +25 -19
  131. package/out/geometries/index.d.ts.map +0 -1
  132. package/out/geometries/index.js.map +0 -1
  133. package/out/google/index.d.ts.map +0 -1
  134. package/out/google/index.js.map +0 -1
  135. package/out/h3/index.d.ts.map +0 -1
  136. package/out/h3/index.js.map +0 -1
  137. package/out/projection/index.d.ts.map +0 -1
  138. package/out/projection/index.js.map +0 -1
  139. package/out/regions/index.d.ts.map +0 -1
  140. package/out/regions/index.js.map +0 -1
  141. package/out/tools/ogr/index.d.ts.map +0 -1
  142. package/out/tools/ogr/index.js.map +0 -1
  143. /package/lib/{geometries/index.ts → geometries.ts} +0 -0
  144. /package/lib/{google/index.ts → google.ts} +0 -0
  145. /package/lib/{regions/index.ts → regions.ts} +0 -0
package/out/h3/cell.js CHANGED
@@ -3,29 +3,23 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  * @file H3 cell primitives — the index types and the widen/shorten conversions.
6
- *
7
- * Split out from `./index.ts` because these carry no dependency on `GeoPoint`, while the
8
- * point-valued helpers there do. `geometries/point.ts` needs the primitives and is itself imported
9
- * by `./index.ts`, so keeping them together closed an import cycle.
6
+
10
7
  */
11
8
  import { cellToParent, isValidCell } from "h3-js";
12
9
  /**
13
- * The finest resolution H3 defines. Resolutions run `[0, H3_MAX_RESOLUTION]`.
10
+ * The finest resolution H3 defines.
11
+ * Resolutions run `[0, H3_MAX_RESOLUTION]`.
14
12
  */
15
13
  export const H3_MAX_RESOLUTION = 15;
16
14
  /**
17
- * Is `value` a real H3 cell index?
18
- *
19
- * Delegates to h3-js rather than testing the surface shape. The shape is necessary but nowhere near sufficient —
20
- * `000000000000000`, `fffffffffffffff` and `123456789abcdef` are all fifteen lowercase hex characters and none of them
21
- * is a cell. A guard that returns `value is H3Cell` on those hands the caller a branded type it has not earned, and the
22
- * error surfaces later inside h3-js with no reference to where the bad value entered.
15
+ * Is `value` a real H3 cell index, delegating to h3-js because the hex surface
16
+ * shape is necessary but not sufficient.
23
17
  */
24
18
  export function isH3Cell(value) {
25
19
  return isValidCell(value);
26
20
  }
27
21
  /**
28
- * Number of hex characters in the short form. 52 bits: a 7-bit base cell followed by fifteen 3-bit digits.
22
+ * Number of hex characters in the short form: 52 bits, a 7-bit base cell followed by fifteen 3-bit digits.
29
23
  */
30
24
  const SHORT_CELL_HEX_LENGTH = 13;
31
25
  /**
@@ -33,15 +27,8 @@ const SHORT_CELL_HEX_LENGTH = 13;
33
27
  */
34
28
  const SHORT_CELL_MASK = 0xfffffffffffffn;
35
29
  /**
36
- * Strip the mode and resolution nibbles off a full H3 cell index, keeping the base cell and the whole digit path.
37
- *
38
- * The digits past the cell's own resolution are all `7` in a valid index, so nothing is discarded and nothing is
39
- * inferred: the short form carries the cell losslessly for every resolution, and {@link expandH3Cell} reverses it
40
- * exactly once you tell it which resolution the cell was captured at.
41
- *
42
- * Zero-padded to a fixed 13 characters, so the hex form orders and compares the same way the integer
43
- * {@link shortCellToInt} packs does. Base cells 0-7 leave the leading nibble zero, and an unpadded string would both
44
- * mis-sort and mis-expand.
30
+ * Strip the mode and resolution nibbles off a full H3 cell index, keeping the base cell
31
+ * and the whole digit path, zero-padded to a fixed 13 characters so hex order matches integer order.
45
32
  */
46
33
  export function shortenH3Cell(cell) {
47
34
  const cellBigInt = BigInt(`0x${cell}`);
@@ -49,21 +36,8 @@ export function shortenH3Cell(cell) {
49
36
  return h3CellShortBigInt.toString(16).padStart(SHORT_CELL_HEX_LENGTH, "0");
50
37
  }
51
38
  /**
52
- * Rebuild a full H3 cell index from a short cell captured at `resolution`.
53
- *
54
- * The short form drops only the mode and resolution nibbles, so reconstruction is a straight concatenation: `"8"` (cell
55
- * mode) + the resolution nibble + the 52 bits verbatim. The result is the identical index `latLngToCell` would have
56
- * produced at that resolution.
57
- *
58
- * `resolution` is a required piece of external knowledge — a short cell does not name its own resolution, so the caller
59
- * has to supply the one the cell was shortened at. Supplying the wrong one is caught rather than tolerated: a mismatch
60
- * leaves digits past the stated resolution set to something other than `7`, which H3 rejects, and this throws instead
61
- * of returning an index that downstream `cellToParent` calls would refuse with `Cell arguments had incompatible
62
- * resolutions`.
63
- *
64
- * @throws {RangeError} If `resolution` is not an integer in `[0, 15]`, or `h3CellShort` is wider than 13 hex
65
- * characters.
66
- * @throws {Error} If the short cell and resolution do not together name a valid H3 cell.
39
+ * Rebuild a full H3 cell index from a short cell captured at `resolution`, throwing
40
+ * when the resolution is out of range or the pair does not name a valid cell.
67
41
  */
68
42
  export function expandH3Cell(h3CellShort, resolution = H3_MAX_RESOLUTION) {
69
43
  if (!Number.isInteger(resolution) || resolution < 0 || resolution > H3_MAX_RESOLUTION) {
@@ -81,36 +55,22 @@ export function expandH3Cell(h3CellShort, resolution = H3_MAX_RESOLUTION) {
81
55
  return cell;
82
56
  }
83
57
  /**
84
- * The full H3 index for a short cell held as an integer, stored at `resolution`.
85
- *
86
- * Through {@link expandH3Cell} rather than a string concatenation, because it VALIDATES: a short cell that does not name
87
- * a valid cell at the stated resolution throws here instead of reaching `compactCells` as a plausible-looking index.
58
+ * The full H3 index for a short cell held as an integer, stored at `resolution`,
59
+ * through {@link expandH3Cell} so an invalid pair throws rather than reaching `compactCells`.
88
60
  */
89
61
  export function expandShortCellInt(shortCell, resolution) {
90
62
  return expandH3Cell(shortCell.toString(16).padStart(SHORT_CELL_HEX_LENGTH, "0"), resolution);
91
63
  }
92
64
  /**
93
- * Pack an H3 cell into the short-cell integer used as a clustered B-tree key across layer databases (poi.db, bdc.db,
94
- * address-id). 52 bits, so it stays inside `Number.MAX_SAFE_INTEGER` and SQLite's signed 64-bit integer column alike.
65
+ * Pack an H3 cell into the short-cell integer used as a clustered B-tree key across layer databases —
66
+ * 52 bits, inside `Number.MAX_SAFE_INTEGER` and SQLite's signed 64-bit integer column.
95
67
  */
96
68
  export function shortCellToInt(cell) {
97
69
  return Number(BigInt(`0x${shortenH3Cell(cell)}`));
98
70
  }
99
71
  /**
100
- * The one resolution a set of stored short cells was captured at.
101
- *
102
- * A short cell drops the resolution nibble, so a table of them does not say what resolution it is keyed at — and every
103
- * `layer_coverage` reader needs that number to derive a probe's coverage cell. It is recoverable because
104
- * {@link expandH3Cell} validates: a short cell expands to a valid index at EXACTLY ONE resolution, so trying all
105
- * sixteen and keeping the one that survives is an exact answer rather than an inference.
106
- *
107
- * SHARED RATHER THAN COPIED, because both failure modes it names are silent in a second copy. A table that mixes
108
- * resolutions read at one of them reports every cell at the other as unsurveyed, and an empty table read as "resolution
109
- * 0" puts every probe in the same cell. `packages/mailwoman/lib/observations/absence-route.ts` re-exports this under
110
- * its own name; `@mailwoman/coastal` calls it directly.
111
- *
112
- * @param context Names the caller in both messages, so a failure says which reader refused.
113
- * @throws {Error} When `cells` is empty, when a value is not a short cell, or when the set mixes resolutions.
72
+ * The one resolution a set of stored short cells was captured at, recovered by keeping
73
+ * the resolution at which a short cell expands to a valid index.
114
74
  */
115
75
  export function recoverShortCellResolution(cells, context = "layer coverage") {
116
76
  if (!cells.length) {
@@ -126,8 +86,7 @@ export function recoverShortCellResolution(cells, context = "layer coverage") {
126
86
  valid.push(resolution);
127
87
  }
128
88
  catch {
129
- // A resolution the short cell does not expand at. Every cell expands at exactly one, so this is the
130
- // ordinary case for fifteen of the sixteen probes.
89
+ // A resolution the short cell does not expand at — every cell expands at exactly one.
131
90
  }
132
91
  }
133
92
  if (valid.length !== 1) {
@@ -145,11 +104,9 @@ export function recoverShortCellResolution(cells, context = "layer coverage") {
145
104
  return recovered;
146
105
  }
147
106
  /**
148
- * Reconstruct a short-cell int's ancestor at a coarser resolution WITHOUT going through a centroid.
149
- *
150
- * The centroid is the wrong input: re-deriving a parent from a stored cell's center can land in a different parent than
151
- * the original cell belonged to (measured at ~6% of CONUS blocks between res 9 and res 6), so a coverage read and the
152
- * build that wrote it disagree on a fraction of cells. Reconstructing from the stored cell itself is exact.
107
+ * Reconstruct a short-cell int's ancestor at a coarser resolution from the
108
+ * stored cell itself rather than a centroid.
109
+ * A centroid can land in a different parent.
153
110
  */
154
111
  export function shortCellToParentInt(shortCell, from, to) {
155
112
  return shortCellToInt(cellToParent(expandShortCellInt(shortCell, from), to));
@@ -1 +1 @@
1
- {"version":3,"file":"cell.js","sourceRoot":"","sources":["../../lib/h3/cell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAGjD;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAenC;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa;IACrC,OAAO,WAAW,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC;AAWD;;GAEG;AACH,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAEhC;;GAEG;AACH,MAAM,eAAe,GAAG,gBAAsB,CAAA;AAE9C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACzC,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IACtC,MAAM,iBAAiB,GAAG,UAAU,GAAG,eAAe,CAAA;IAEtD,OAAO,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,qBAAqB,EAAE,GAAG,CAAgB,CAAA;AAC1F,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAC,WAAwB,EAAE,UAAU,GAAG,iBAAiB;IACpF,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,GAAG,iBAAiB,EAAE,CAAC;QACvF,MAAM,IAAI,UAAU,CAAC,2CAA2C,iBAAiB,eAAe,UAAU,GAAG,CAAC,CAAA;IAC/G,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,GAAG,qBAAqB,EAAE,CAAC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B,CAAC;YAAC,MAAM,CAAC;gBACR,sFAAsF;YACvF,CAAC;QACF,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACd,GAAG,OAAO,mBAAmB,IAAI,eAAe,KAAK,CAAC,MAAM,iBAAiB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,2DAA2D,CAClK,CAAA;QACF,CAAC;QAED,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;QAE5B,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC7B,SAAS,GAAG,UAAU,CAAA;YAEtB,SAAQ;QACT,CAAC;QAED,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACd,GAAG,OAAO,2CAA2C,SAAS,QAAQ,UAAU,2FAA2F,CAC3K,CAAA;QACF,CAAC;IACF,CAAC;IAED,OAAO,SAAU,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAiB,EAAE,IAAY,EAAE,EAAU;IAC/E,OAAO,cAAc,CAAC,YAAY,CAAC,kBAAkB,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE,CAAW,CAAC,CAAA;AACvF,CAAC"}
@@ -4,10 +4,10 @@
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
6
  * The coverage probe every polygon layer's reader repeats: an index cell's parent at the coverage
7
- * resolution, read through the layer contract's shared row mapping.
7
+ * resolution, read through the layer interface's shared row mapping.
8
8
  *
9
- * NOT exported from this package's main barrel on purpose — it reaches `@mailwoman/core/layers`, and the
10
- * barrel serves browser bundles that must not carry the layer contract's Kysely graph. Import it from the
9
+ * Not exported from this package's main barrel on purpose — it reaches `@mailwoman/core/layers`, and the
10
+ * barrel serves browser bundles that must not include the layer interface's Kysely graph. Import it from the
11
11
  * `@mailwoman/spatial/h3/coverage` subpath.
12
12
  */
13
13
  import { type CoverageCell } from "@mailwoman/core/layers";
@@ -19,11 +19,15 @@ export interface CoverageRowProbe {
19
19
  get(shortCell: number): unknown;
20
20
  }
21
21
  /**
22
- * The coverage row for `indexCell`'s parent at the coverage resolution, or `undefined` when the cell was never surveyed
23
- * — which a caller must read as UNKNOWN, never as `{completeness: 0}`.
22
+ * The coverage row for `indexCell`'s parent at the coverage resolution,
23
+ * or `undefined` when the cell was never surveyed.
24
24
  *
25
- * The NULL-basis rule lives in the shared mapping: a NULL column is an artifact built before `basis` existed, and it
26
- * was recording source presence — never a stronger basis than the builder actually had.
25
+ * A caller must treat it as an unknown value, separate from `{completeness: 0}`.
26
+ *
27
+ * The shared mapping owns the NULL-basis rule.
28
+ * A NULL column means the artifact predates `basis`.
29
+ *
30
+ * It recorded source presence and no stronger basis than the builder had.
27
31
  */
28
32
  export declare function readCoverageAt(select: CoverageRowProbe, indexCell: H3Cell, coverageResolution: number): (CoverageCell & {
29
33
  h3CellIndex: string;
@@ -1 +1 @@
1
- {"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../lib/h3/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAkB,KAAK,YAAY,EAAoB,MAAM,wBAAwB,CAAA;AAG5F,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAA;CAC/B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,GACxB,CAAC,YAAY,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,CAQ1E"}
1
+ {"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../lib/h3/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAkB,KAAK,YAAY,EAAoB,MAAM,wBAAwB,CAAA;AAG5F,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAA;CAC/B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,GACxB,CAAC,YAAY,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,CAQ1E"}
@@ -4,21 +4,25 @@
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
6
  * The coverage probe every polygon layer's reader repeats: an index cell's parent at the coverage
7
- * resolution, read through the layer contract's shared row mapping.
7
+ * resolution, read through the layer interface's shared row mapping.
8
8
  *
9
- * NOT exported from this package's main barrel on purpose — it reaches `@mailwoman/core/layers`, and the
10
- * barrel serves browser bundles that must not carry the layer contract's Kysely graph. Import it from the
9
+ * Not exported from this package's main barrel on purpose — it reaches `@mailwoman/core/layers`, and the
10
+ * barrel serves browser bundles that must not include the layer interface's Kysely graph. Import it from the
11
11
  * `@mailwoman/spatial/h3/coverage` subpath.
12
12
  */
13
13
  import { toCoverageCell } from "@mailwoman/core/layers";
14
14
  import { cellToParent } from "h3-js";
15
15
  import { shortCellToInt } from "#h3/cell";
16
16
  /**
17
- * The coverage row for `indexCell`'s parent at the coverage resolution, or `undefined` when the cell was never surveyed
18
- * — which a caller must read as UNKNOWN, never as `{completeness: 0}`.
17
+ * The coverage row for `indexCell`'s parent at the coverage resolution,
18
+ * or `undefined` when the cell was never surveyed.
19
19
  *
20
- * The NULL-basis rule lives in the shared mapping: a NULL column is an artifact built before `basis` existed, and it
21
- * was recording source presence — never a stronger basis than the builder actually had.
20
+ * A caller must treat it as an unknown value, separate from `{completeness: 0}`.
21
+ *
22
+ * The shared mapping owns the NULL-basis rule.
23
+ * A NULL column means the artifact predates `basis`.
24
+ *
25
+ * It recorded source presence and no stronger basis than the builder had.
22
26
  */
23
27
  export function readCoverageAt(select, indexCell, coverageResolution) {
24
28
  const coverageCell = cellToParent(indexCell, coverageResolution);
@@ -1 +1 @@
1
- {"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../lib/h3/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,cAAc,EAAuC,MAAM,wBAAwB,CAAA;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,OAAO,EAAE,cAAc,EAAe,MAAM,UAAU,CAAA;AAStD;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC7B,MAAwB,EACxB,SAAiB,EACjB,kBAA0B;IAE1B,MAAM,YAAY,GAAG,YAAY,CAAC,SAAS,EAAE,kBAAkB,CAAW,CAAA;IAE1E,OAAO,cAAc,CACpB,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,CAA4B,EACnE,YAAY,EACZ,kBAAkB,CAClB,CAAA;AACF,CAAC"}
1
+ {"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../lib/h3/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,cAAc,EAAuC,MAAM,wBAAwB,CAAA;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,OAAO,EAAE,cAAc,EAAe,MAAM,UAAU,CAAA;AAStD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAC7B,MAAwB,EACxB,SAAiB,EACjB,kBAA0B;IAE1B,MAAM,YAAY,GAAG,YAAY,CAAC,SAAS,EAAE,kBAAkB,CAAW,CAAA;IAE1E,OAAO,cAAc,CACpB,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,CAA4B,EACnE,YAAY,EACZ,kBAAkB,CAClB,CAAA;AACF,CAAC"}
@@ -3,32 +3,14 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Turn an outline into the H3 cell set a coverage claim may be keyed to.
7
- *
8
- * Polyfilling a rectangle is right for a rectangular extract and wrong for a region: a region is
9
- * clipped to a polygon, so a rectangle polyfilled over it claims survey across whatever the rectangle
10
- * overhangs. These helpers answer the narrower question — which cells lie wholly INSIDE the outline —
11
- * and they answer conservatively, because the cells they return are the ones a completeness claim will
12
- * be written to.
13
- *
14
- * Interior is two tests, both required. A cell must have its whole `gridDisk(cell, 1)` inside the
15
- * outline's own polyfill, and all six of its boundary vertices inside the polygon. The first removes the
16
- * polyfill's edge ring (H3's polyfill keeps a cell whose CENTRE is inside, so an edge cell can be half
17
- * outside); the second catches a boundary that re-enters between two neighbours. Neither test alone is
18
- * sufficient, and the cost of being wrong is asymmetric — a cell wrongly called interior claims a survey
19
- * over ground the source never covered.
20
- *
21
- * Measured on the Île-de-France région (OSM relation 8649, admin_level 4) at res 6: 371 polyfilled
22
- * cells, 290 interior, holding 3,248 of the extract's 3,308 `amenity=pharmacy` features.
6
+ * Turn an outline into the H3 cell set a coverage claim may be keyed to, conservatively: a cell
7
+ * must have its whole `gridDisk(cell, 1)` and all six boundary vertices inside the outline.
23
8
  */
24
9
  import { type ParsedGeometry } from "#geometries/polygon";
25
10
  import { type H3Cell } from "#h3/cell";
26
11
  /**
27
- * The outline's bounding rectangle, for pre-clipping a reference inventory that can only be probed by range.
28
- *
29
- * A coarse filter and nothing more — it CONTAINS the outline and is never the outline. The exact clip is
30
- * {@link interiorCoverageCellSet}; using this rectangle as the region would claim survey over every corner the outline
31
- * does not reach.
12
+ * The outline's bounding rectangle, for pre-clipping a reference inventory that can only
13
+ * be probed by range — a coarse filter that contains the outline and is never the outline.
32
14
  */
33
15
  export declare function geometryBBox(geometry: ParsedGeometry): {
34
16
  minLon: number;
@@ -37,18 +19,17 @@ export declare function geometryBBox(geometry: ParsedGeometry): {
37
19
  maxLat: number;
38
20
  };
39
21
  /**
40
- * Every cell whose CENTRE falls inside `geometry`, at `resolution`. The raw polyfill — {@link interiorCoverageCells}
41
- * narrows it.
22
+ * Every cell whose center falls inside `geometry`, at `resolution` — the raw
23
+ * polyfill that {@link interiorCoverageCells} narrows.
42
24
  */
43
25
  export declare function regionCoverageCells(geometry: ParsedGeometry, resolution: number): H3Cell[];
44
26
  /**
45
- * The cells of {@link regionCoverageCells} that lie wholly inside `geometry` — see the module docstring for why both
46
- * tests are applied.
27
+ * The cells of {@link regionCoverageCells} that lie wholly inside `geometry`.
47
28
  */
48
29
  export declare function interiorCoverageCells(geometry: ParsedGeometry, resolution: number): H3Cell[];
49
30
  /**
50
- * The 48-bit short-cell form of {@link interiorCoverageCells}, as a membership set — the shape both a row clipper and a
51
- * coverage writer probe.
31
+ * The 48-bit short-cell form of {@link interiorCoverageCells}, as a membership set —
32
+ * the shape both a row clipper and a coverage writer probe.
52
33
  */
53
34
  export declare function interiorCoverageCellSet(geometry: ParsedGeometry, resolution: number): Set<number>;
54
35
  //# sourceMappingURL=interior-cells.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interior-cells.d.ts","sourceRoot":"","sources":["../../lib/h3/interior-cells.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,EAAmC,KAAK,cAAc,EAAqB,MAAM,qBAAqB,CAAA;AAC7G,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAmBtD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG;IACvD,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACd,CA+BA;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAa1F;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAe5F;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAEjG"}
1
+ {"version":3,"file":"interior-cells.d.ts","sourceRoot":"","sources":["../../lib/h3/interior-cells.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAAmC,KAAK,cAAc,EAAqB,MAAM,qBAAqB,CAAA;AAC7G,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAgBtD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG;IACvD,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACd,CA+BA;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAa1F;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAe5F;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAEjG"}
@@ -3,45 +3,27 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Turn an outline into the H3 cell set a coverage claim may be keyed to.
7
- *
8
- * Polyfilling a rectangle is right for a rectangular extract and wrong for a region: a region is
9
- * clipped to a polygon, so a rectangle polyfilled over it claims survey across whatever the rectangle
10
- * overhangs. These helpers answer the narrower question — which cells lie wholly INSIDE the outline —
11
- * and they answer conservatively, because the cells they return are the ones a completeness claim will
12
- * be written to.
13
- *
14
- * Interior is two tests, both required. A cell must have its whole `gridDisk(cell, 1)` inside the
15
- * outline's own polyfill, and all six of its boundary vertices inside the polygon. The first removes the
16
- * polyfill's edge ring (H3's polyfill keeps a cell whose CENTRE is inside, so an edge cell can be half
17
- * outside); the second catches a boundary that re-enters between two neighbours. Neither test alone is
18
- * sufficient, and the cost of being wrong is asymmetric — a cell wrongly called interior claims a survey
19
- * over ground the source never covered.
20
- *
21
- * Measured on the Île-de-France région (OSM relation 8649, admin_level 4) at res 6: 371 polyfilled
22
- * cells, 290 interior, holding 3,248 of the extract's 3,308 `amenity=pharmacy` features.
6
+ * Turn an outline into the H3 cell set a coverage claim may be keyed to, conservatively: a cell
7
+ * must have its whole `gridDisk(cell, 1)` and all six boundary vertices inside the outline.
23
8
  */
9
+ import { stringifyJSON } from "@mailwoman/core/json";
24
10
  import { cellToBoundary, gridDisk, polygonToCells } from "h3-js";
25
11
  import { arealPolygons, geometryContains } from "#geometries/polygon";
26
12
  import { shortCellToInt } from "#h3/cell";
27
13
  /**
28
- * The rings a polyfill walks: every polygon's OUTER ring. Holes are deliberately not subtracted here — a hole would
29
- * only ever remove cells, and the interior test below re-checks every returned cell's vertices against the full
30
- * geometry (holes included), so a hole cannot survive into the result.
14
+ * The rings a polyfill walks: every polygon's outer ring, with holes deliberately not
15
+ * subtracted because the interior test re-checks vertices against the full geometry.
31
16
  */
32
17
  function outerRings(geometry) {
33
18
  const polygons = arealPolygons(geometry);
34
19
  if (!polygons) {
35
- throw new Error(`coverage region: expected a Polygon or MultiPolygon geometry, got ${JSON.stringify(geometry.type)}`);
20
+ throw new Error(`coverage region: expected a Polygon or MultiPolygon geometry, got ${stringifyJSON(geometry.type)}`);
36
21
  }
37
22
  return polygons.filter((rings) => rings.length).map((rings) => rings[0]);
38
23
  }
39
24
  /**
40
- * The outline's bounding rectangle, for pre-clipping a reference inventory that can only be probed by range.
41
- *
42
- * A coarse filter and nothing more — it CONTAINS the outline and is never the outline. The exact clip is
43
- * {@link interiorCoverageCellSet}; using this rectangle as the region would claim survey over every corner the outline
44
- * does not reach.
25
+ * The outline's bounding rectangle, for pre-clipping a reference inventory that can only
26
+ * be probed by range — a coarse filter that contains the outline and is never the outline.
45
27
  */
46
28
  export function geometryBBox(geometry) {
47
29
  let minLon = Infinity;
@@ -70,8 +52,8 @@ export function geometryBBox(geometry) {
70
52
  return { minLon, minLat, maxLon, maxLat };
71
53
  }
72
54
  /**
73
- * Every cell whose CENTRE falls inside `geometry`, at `resolution`. The raw polyfill — {@link interiorCoverageCells}
74
- * narrows it.
55
+ * Every cell whose center falls inside `geometry`, at `resolution` — the raw
56
+ * polyfill that {@link interiorCoverageCells} narrows.
75
57
  */
76
58
  export function regionCoverageCells(geometry, resolution) {
77
59
  const cells = new Set();
@@ -85,8 +67,7 @@ export function regionCoverageCells(geometry, resolution) {
85
67
  return [...cells];
86
68
  }
87
69
  /**
88
- * The cells of {@link regionCoverageCells} that lie wholly inside `geometry` — see the module docstring for why both
89
- * tests are applied.
70
+ * The cells of {@link regionCoverageCells} that lie wholly inside `geometry`.
90
71
  */
91
72
  export function interiorCoverageCells(geometry, resolution) {
92
73
  const polyfilled = new Set(regionCoverageCells(geometry, resolution));
@@ -102,8 +83,8 @@ export function interiorCoverageCells(geometry, resolution) {
102
83
  return interior;
103
84
  }
104
85
  /**
105
- * The 48-bit short-cell form of {@link interiorCoverageCells}, as a membership set — the shape both a row clipper and a
106
- * coverage writer probe.
86
+ * The 48-bit short-cell form of {@link interiorCoverageCells}, as a membership set —
87
+ * the shape both a row clipper and a coverage writer probe.
107
88
  */
108
89
  export function interiorCoverageCellSet(geometry, resolution) {
109
90
  return new Set(interiorCoverageCells(geometry, resolution).map((cell) => shortCellToInt(cell)));
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AAC;YAAE,SAAQ;QAErF,QAAQ,CAAC,IAAI,CAAC,IAAc,CAAC,CAAA;IAC9B,CAAC;IAED,OAAO,QAAQ,CAAA;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAwB,EAAE,UAAkB;IACnF,OAAO,IAAI,GAAG,CAAC,qBAAqB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAChG,CAAC"}
@@ -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