@mailwoman/spatial 10.0.0 → 10.2.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 (148) 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 +21 -33
  5. package/lib/distance.ts +56 -28
  6. package/lib/feature.ts +2 -2
  7. package/lib/geometries/point.ts +42 -35
  8. package/lib/geometries/polygon.ts +27 -135
  9. package/lib/geometries/ring-blob.ts +35 -132
  10. package/lib/google/place-id.ts +4 -2
  11. package/lib/h3/cell.ts +23 -78
  12. package/lib/h3/coverage.ts +13 -9
  13. package/lib/h3/interior-cells.ts +13 -34
  14. package/lib/h3/polygon-cells.ts +61 -167
  15. package/lib/{h3/index.ts → h3.ts} +1 -1
  16. package/lib/index.ts +6 -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 +39 -20
  22. package/lib/projection/transform.ts +43 -44
  23. package/lib/{projection/index.ts → projection.ts} +1 -1
  24. package/lib/well-known-text.ts +9 -9
  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 +17 -16
  32. package/out/coordinate/formats.d.ts.map +1 -1
  33. package/out/coordinate/formats.js +20 -32
  34. package/out/coordinate/formats.js.map +1 -1
  35. package/out/distance.d.ts +51 -26
  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 +37 -30
  44. package/out/geometries/point.js.map +1 -1
  45. package/out/geometries/polygon.d.ts +27 -126
  46. package/out/geometries/polygon.d.ts.map +1 -1
  47. package/out/geometries/polygon.js +14 -42
  48. package/out/geometries/polygon.js.map +1 -1
  49. package/out/geometries/ring-blob.d.ts +24 -110
  50. package/out/geometries/ring-blob.d.ts.map +1 -1
  51. package/out/geometries/ring-blob.js +30 -116
  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 +22 -65
  67. package/out/h3/cell.js.map +1 -1
  68. package/out/h3/coverage.d.ts +12 -8
  69. package/out/h3/coverage.d.ts.map +1 -1
  70. package/out/h3/coverage.js +12 -8
  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 +50 -148
  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 +6 -5
  85. package/out/index.d.ts.map +1 -1
  86. package/out/index.js +6 -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 +36 -20
  102. package/out/position.d.ts.map +1 -1
  103. package/out/position.js +0 -1
  104. package/out/position.js.map +1 -1
  105. package/out/projection/transform.d.ts +33 -30
  106. package/out/projection/transform.d.ts.map +1 -1
  107. package/out/projection/transform.js +15 -17
  108. package/out/projection/transform.js.map +1 -1
  109. package/out/{projection/index.d.ts → projection.d.ts} +2 -2
  110. package/out/projection.d.ts.map +1 -0
  111. package/out/{projection/index.js → projection.js} +2 -2
  112. package/out/projection.js.map +1 -0
  113. package/out/{regions/index.js → regions.d.ts} +1 -1
  114. package/out/regions.d.ts.map +1 -0
  115. package/out/{regions/index.d.ts → regions.js} +1 -1
  116. package/out/regions.js.map +1 -0
  117. package/out/tools/ogr/stream.d.ts +21 -11
  118. package/out/tools/ogr/stream.d.ts.map +1 -1
  119. package/out/tools/ogr/stream.js +17 -10
  120. package/out/tools/ogr/stream.js.map +1 -1
  121. package/out/tools/{ogr/index.d.ts → ogr.d.ts} +25 -15
  122. package/out/tools/ogr.d.ts.map +1 -0
  123. package/out/tools/{ogr/index.js → ogr.js} +25 -21
  124. package/out/tools/ogr.js.map +1 -0
  125. package/out/tools/tsconfig.tsbuildinfo +1 -0
  126. package/out/tsconfig.test.tsbuildinfo +1 -1
  127. package/out/well-known-text.d.ts +9 -9
  128. package/out/well-known-text.d.ts.map +1 -1
  129. package/out/well-known-text.js +7 -7
  130. package/out/well-known-text.js.map +1 -1
  131. package/package.json +37 -129
  132. package/{lib/tools → tools}/ogr/stream.ts +26 -15
  133. package/{lib/tools/ogr/index.ts → tools/ogr.ts} +44 -30
  134. package/out/geometries/index.d.ts.map +0 -1
  135. package/out/geometries/index.js.map +0 -1
  136. package/out/google/index.d.ts.map +0 -1
  137. package/out/google/index.js.map +0 -1
  138. package/out/h3/index.d.ts.map +0 -1
  139. package/out/h3/index.js.map +0 -1
  140. package/out/projection/index.d.ts.map +0 -1
  141. package/out/projection/index.js.map +0 -1
  142. package/out/regions/index.d.ts.map +0 -1
  143. package/out/regions/index.js.map +0 -1
  144. package/out/tools/ogr/index.d.ts.map +0 -1
  145. package/out/tools/ogr/index.js.map +0 -1
  146. /package/lib/{geometries/index.ts → geometries.ts} +0 -0
  147. /package/lib/{google/index.ts → google.ts} +0 -0
  148. /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,42 +55,28 @@ 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) {
117
77
  throw new Error(`${context}: the coverage layer holds no cells — there is no resolution to recover`);
118
78
  }
119
- let recovered;
79
+ let recovered = null;
120
80
  for (const cell of cells) {
121
81
  const short = BigInt(cell).toString(16).padStart(SHORT_CELL_HEX_LENGTH, "0");
122
82
  const valid = [];
@@ -126,15 +86,14 @@ 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) {
134
93
  throw new Error(`${context}: coverage cell ${cell} expands at ${valid.length} resolutions (${valid.join(", ") || "none"}) — it is not a short H3 cell this layer can be probed by`);
135
94
  }
136
95
  const resolution = valid[0];
137
- if (recovered === undefined) {
96
+ if (recovered === null) {
138
97
  recovered = resolution;
139
98
  continue;
140
99
  }
@@ -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,QAA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AAE,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,14 +19,18 @@ 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
+ * It is `null` 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;
30
34
  resolution: number;
31
- }) | undefined;
35
+ }) | null;
32
36
  //# sourceMappingURL=coverage.d.ts.map
@@ -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,IAAI,CAQrE"}
@@ -4,24 +4,28 @@
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
+ * It is `null` 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);
25
- return toCoverageCell(select.get(shortCellToInt(coverageCell)), coverageCell, coverageResolution);
29
+ return toCoverageCell(select.get(shortCellToInt(coverageCell)) ?? null, coverageCell, coverageResolution);
26
30
  }
27
31
  //# sourceMappingURL=coverage.js.map
@@ -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,CACnB,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,CAA6B,IAAI,IAAI,EAC7E,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)));
@@ -1 +1 @@
1
- {"version":3,"file":"interior-cells.js","sourceRoot":"","sources":["../../lib/h3/interior-cells.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAEhE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAA0C,MAAM,qBAAqB,CAAA;AAC7G,OAAO,EAAE,cAAc,EAAe,MAAM,UAAU,CAAA;AAEtD;;;;GAIG;AACH,SAAS,UAAU,CAAC,QAAwB;IAC3C,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;IAExC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACd,qEAAqE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC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