@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
package/lib/osgb36.ts CHANGED
@@ -2,223 +2,76 @@
2
2
  * @copyright Sister Software.
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
- *
6
- * OSGB36 / British National Grid (EPSG:27700) → WGS84 (EPSG:4326).
7
- *
8
- * Ordnance Survey ships its open products in eastings/northings on the National Grid, not in
9
- * degrees — Code-Point Open, OS Open UPRN, OS Open Names all do. Nothing else in the repo speaks
10
- * that coordinate system, so this module is the one place that converts it, and it lives in
11
- * `@mailwoman/spatial` because that is the math home (`projection.ts` names the datums; this file
12
- * moves between two of them).
13
- *
14
- * Two steps, both from OS's own "A Guide to Coordinate Systems in Great Britain":
15
- *
16
- * 1. **Inverse transverse Mercator (Redfearn's series)** — National Grid E/N → OSGB36 geodetic
17
- * lat/lon on the Airy 1830 ellipsoid. This step is EXACT to well below a millimetre; it is
18
- * plain map-projection algebra with no empirical content, and {@link osgb36GridToAiryLatLon}
19
- * reproduces the guide's Annexe C.2 worked example to **1.3e-5 arc-seconds (~0.4 mm)**, which
20
- * is that example's own published rounding rather than our error.
21
- * 2. **Seven-parameter Helmert** — Airy-1830 geodetic → geocentric cartesian → rotate/scale/shift
22
- * → WGS84 (GRS80) geodetic. This step is APPROXIMATE, and that is the whole accuracy story
23
- * below. Against the guide's own Annexe D Helmert worked example — which uses this same
24
- * transform, so it tests the implementation and not the approximation — the round trip lands
25
- * **8.4 mm** out, i.e. the published DMS rounding plus the ignored ellipsoidal height.
26
- *
27
- * ## Accuracy: ±5 m, measured, and why we accept it
28
- *
29
- * OSGB36 is a 1936 theodolite triangulation, not a geocentric datum. Its distortions relative to
30
- * WGS84 are irregular across GB — a couple of metres of local warp that no rigid-body transform can
31
- * absorb. OS's exact answer is **OSTN15**, a published ~1.5 MB grid of per-cell E/N shifts; the
32
- * seven-parameter Helmert implemented here is OS's own documented approximation to it, which the
33
- * guide rates at "up to 3.5 m (95%)".
34
- *
35
- * MEASURED against OS's official 40-point OSTN15/OSGM15 test set (`OSTN15_OSGM15_TestInput_*`, the
36
- * developer-pack vectors, joining each point's published OSGB36 E/N to its published ETRS89 lat/lon):
37
- *
38
- * | p50 | p90 | p95 | max | mean |
39
- * | ------ | ------ | ------ | ------ | ------ |
40
- * | 1.74 m | 3.23 m | 4.18 m | 4.91 m | 1.94 m |
41
- *
42
- * All 40 land under 5 m. The worst are exactly where OS warns the datum thins out — TP31 St Kilda
43
- * (4.91 m), TP01 Scilly (4.72 m), TP32 Outer Hebrides (4.18 m); the mainland points sit near 1–2 m.
44
- * p95 runs a little above the guide's 3.5 m because we discard ellipsoidal height (see
45
- * {@link osgb36AiryToWGS84}), and because two of the three worst points are offshore rocks where
46
- * "OSGB36 does not exist" in OS's own words.
47
- *
48
- * We take that error deliberately, because of what the coordinates are FOR. A Code-Point Open
49
- * centroid is the mean position of a postcode unit's delivery points snapped to the nearest real
50
- * address — the unit itself spans tens to hundreds of metres, and the resolver uses the centroid to
51
- * pick a locality and rank candidates within a few hundred metres. A 2 m datum error is one to two
52
- * orders of magnitude below the quantity being represented. Nothing downstream reads a postcode
53
- * centroid at metre precision.
54
- *
55
- * **Do not use this module for anything that does.** Surveying, cadastral work, or any consumer
56
- * comparing our coordinates against another OSGB36-derived dataset at sub-10 m tolerance needs
57
- * OSTN15, which means shipping the shift grid. If that day comes, the swap point is
58
- * {@link osgb36AiryToWGS84} — swap the Helmert for a grid interpolation and the projection step
59
- * above it is unchanged.
60
- *
61
- * @see https://www.ordnancesurvey.co.uk/documents/resources/guide-coordinate-systems-great-britain.pdf
62
5
  */
63
6
 
64
- import type { Coordinates2D } from "#position"
7
+ import type { Coordinates2D, GeoCoordinate } from "#position"
65
8
 
66
- /**
67
- * Semi-major axis of the Airy 1830 ellipsoid, in metres — the figure of the Earth OSGB36 is referenced to.
68
- */
69
9
  const AIRY_1830_A = 6_377_563.396
70
10
 
71
- /**
72
- * Semi-minor axis of the Airy 1830 ellipsoid, in metres.
73
- */
74
11
  const AIRY_1830_B = 6_356_256.909
75
12
 
76
- /**
77
- * Semi-major axis of the GRS80 ellipsoid, in metres. WGS84's own semi-major axis is identical; the two ellipsoids
78
- * differ only in the flattening's last digits (~0.1 mm at the pole), far below this module's error budget.
79
- */
80
13
  const GRS80_A = 6_378_137
81
14
 
82
- /**
83
- * Semi-minor axis of the GRS80 ellipsoid, in metres.
84
- */
85
15
  const GRS80_B = 6_356_752.3141
86
16
 
87
- /**
88
- * Scale factor on the National Grid's central meridian.
89
- */
90
17
  const NATIONAL_GRID_F0 = 0.9996012717
91
18
 
92
- /**
93
- * Latitude of the National Grid's true origin, 49° N, in radians.
94
- */
95
19
  const NATIONAL_GRID_LAT0 = (49 * Math.PI) / 180
96
20
 
97
- /**
98
- * Longitude of the National Grid's true origin, 2° W, in radians.
99
- */
100
21
  const NATIONAL_GRID_LON0 = (-2 * Math.PI) / 180
101
22
 
102
- /**
103
- * Easting of the National Grid's true origin (the "false easting"), in metres.
104
- */
105
23
  const NATIONAL_GRID_E0 = 400_000
106
24
 
107
- /**
108
- * Northing of the National Grid's true origin (the "false northing"), in metres. Negative because the true origin sits
109
- * south-west of the grid's own zero.
110
- */
111
25
  const NATIONAL_GRID_N0 = -100_000
112
26
 
113
- /**
114
- * Arc-seconds → radians. The Helmert rotations are published in arc-seconds.
115
- */
116
27
  const ARCSEC_TO_RAD = Math.PI / (180 * 3600)
117
28
 
118
- /**
119
- * Parts-per-million → unitless scale. The Helmert scale factor is published in ppm.
120
- */
121
29
  const PPM = 1e-6
122
30
 
123
- /**
124
- * Convergence threshold for the meridional-arc iteration in {@link osgb36GridToAiryLatLon}, in METRES of northing. OS's
125
- * guide specifies 0.01 mm; this is that figure. It bounds the northing residual, not the latitude, which is why it is
126
- * expressed in metres and compared against `northing - N0 - M`.
127
- */
128
31
  const MERIDIONAL_ARC_TOLERANCE_M = 1e-5
129
32
 
130
- /**
131
- * Convergence threshold for the cartesian→geodetic latitude iteration in {@link osgb36AiryToWGS84}, in RADIANS. 1e-13
132
- * rad is ~0.6 µm on the ground — far below anything this module claims, and reached in four or five passes at GB
133
- * latitudes.
134
- */
135
33
  const GEODETIC_LATITUDE_TOLERANCE_RAD = 1e-13
136
34
 
137
- /**
138
- * The seven-parameter Helmert transformation taking OSGB36 (Airy 1830) geocentric cartesian coordinates to WGS84.
139
- *
140
- * OS publishes this transform in the ETRS89/WGS84 → OSGB36 direction (guide table 4), as `tx = -446.448, ty = +125.157,
141
- * tz = -542.060, s = +20.4894 ppm, rx = -0.1502", ry = -0.2470", rz = -0.8421"`. We need the OTHER direction, so every
142
- * parameter is negated — valid to well inside the transform's own metre-scale error because the rotations are
143
- * microradian-scale and the second-order terms of a proper inversion are sub-millimetre.
144
- *
145
- * The rotation convention is **Position Vector** (EPSG method 1033), NOT Coordinate Frame Rotation (EPSG 1032). The two
146
- * differ only in the sign of the three rotations, which is why citing the method code matters more than it looks: paste
147
- * these numbers into a library expecting 1032 and every result moves by roughly 20 m with no error raised.
148
- *
149
- * Getting a sign wrong here does not produce a subtly worse answer; it produces a coordinate tens to hundreds of metres
150
- * out, in a consistent direction — which reads as a plausible coordinate. That is what the Annexe D test is for.
151
- */
152
35
  const OSGB36_TO_WGS84_HELMERT = {
153
- /**
154
- * X translation, metres.
155
- */
156
36
  tx: 446.448,
157
- /**
158
- * Y translation, metres.
159
- */
37
+
160
38
  ty: -125.157,
161
- /**
162
- * Z translation, metres.
163
- */
39
+
164
40
  tz: 542.06,
165
- /**
166
- * Scale correction, parts per million.
167
- */
41
+
168
42
  scalePPM: -20.4894,
169
- /**
170
- * Rotation about the X axis, arc-seconds.
171
- */
43
+
172
44
  rx: 0.1502,
173
- /**
174
- * Rotation about the Y axis, arc-seconds.
175
- */
45
+
176
46
  ry: 0.247,
177
- /**
178
- * Rotation about the Z axis, arc-seconds.
179
- */
47
+
180
48
  rz: 0.8421,
181
49
  } as const
182
50
 
183
51
  /**
184
- * A geodetic position on an unspecified ellipsoid, in degrees. Which ellipsoid is the caller's business — the whole
185
- * point of this module is that the same numbers mean different places on Airy 1830 and on GRS80.
186
- */
187
- export interface GeodeticLatLon {
188
- /**
189
- * Latitude in decimal degrees, positive north.
190
- */
191
- latitude: number
192
- /**
193
- * Longitude in decimal degrees, positive east.
194
- */
195
- longitude: number
196
- }
197
-
198
- /**
199
- * A position on the British National Grid, in metres.
52
+ * A position on the British National Grid, in meters.
200
53
  */
201
54
  export interface NationalGridPoint {
202
55
  /**
203
- * Easting in metres. Valid GB values run roughly 0…700,000.
56
+ * Distance east in meters.
57
+ * Valid GB values run roughly from 0 to 700,000.
204
58
  */
205
59
  easting: number
60
+
206
61
  /**
207
- * Northing in metres. Valid GB values run roughly 0…1,300,000.
62
+ * Distance north in meters.
63
+ * Valid GB values run roughly from 0 to 1,300,000.
208
64
  */
209
65
  northing: number
210
66
  }
211
67
 
212
68
  /**
213
- * Convert National Grid eastings/northings to OSGB36 geodetic lat/lon on the Airy 1830 ellipsoid, by Redfearn's inverse
214
- * transverse Mercator series.
69
+ * Converts a National Grid easting and northing to OSGB36 latitude and longitude
70
+ * on the Airy 1830 ellipsoid, without a datum shift.
215
71
  *
216
- * This is the EXACT half of the pipeline — pure projection algebra, no datum shift. The result is still on Airy 1830,
217
- * so it is NOT a WGS84 coordinate and must not be handed to anything expecting one; feed it to
218
- * {@link osgb36AiryToWGS84}. Exported separately so the projection can be tested against OS's worked example
219
- * independently of the Helmert, which is the only way to tell a projection bug from a datum-shift bug.
72
+ * Pass the result to {@link osgb36AiryToWGS84} to get WGS84 coordinates.
220
73
  */
221
- export function osgb36GridToAiryLatLon({ easting, northing }: NationalGridPoint): GeodeticLatLon {
74
+ export function osgb36GridToAiryLatLon({ easting, northing }: NationalGridPoint): GeoCoordinate {
222
75
  const a = AIRY_1830_A
223
76
  const b = AIRY_1830_B
224
77
  const f0 = NATIONAL_GRID_F0
@@ -227,14 +80,11 @@ export function osgb36GridToAiryLatLon({ easting, northing }: NationalGridPoint)
227
80
  const e0 = NATIONAL_GRID_E0
228
81
  const n0 = NATIONAL_GRID_N0
229
82
 
230
- // Eccentricity squared of the Airy ellipsoid, and the `n` series parameter.
231
83
  const e2 = (a * a - b * b) / (a * a)
232
84
  const n = (a - b) / (a + b)
233
85
  const n2 = n * n
234
86
  const n3 = n2 * n
235
87
 
236
- // Iterate latitude until the meridional arc `M` matches the northing. OS's guide specifies a 0.01 mm
237
- // threshold; it converges in three or four passes anywhere in GB.
238
88
  let lat = lat0
239
89
  let m = 0
240
90
 
@@ -260,7 +110,6 @@ export function osgb36GridToAiryLatLon({ easting, northing }: NationalGridPoint)
260
110
  const tan4 = tan2 * tan2
261
111
  const tan6 = tan4 * tan2
262
112
 
263
- // `nu` = transverse radius of curvature; `rho` = meridional radius; `eta2` = their ratio less one.
264
113
  const nu = a * f0 * (1 - e2 * sinLat * sinLat) ** -0.5
265
114
  const rho = a * f0 * (1 - e2) * (1 - e2 * sinLat * sinLat) ** -1.5
266
115
  const eta2 = nu / rho - 1
@@ -292,17 +141,14 @@ export function osgb36GridToAiryLatLon({ easting, northing }: NationalGridPoint)
292
141
  }
293
142
 
294
143
  /**
295
- * Convert OSGB36 geodetic lat/lon (Airy 1830) to WGS84 lat/lon (GRS80) via the seven-parameter Helmert.
144
+ * Converts OSGB36 latitude and longitude on Airy 1830 to WGS84 with the seven-parameter
145
+ * Helmert transform, accurate to about 5 m.
296
146
  *
297
- * This is the APPROXIMATE half — see the module docstring for the ±5 m budget and when it stops being acceptable.
298
- * Heights are not modelled: the input is treated as sitting on the Airy ellipsoid and the output's ellipsoidal height
299
- * is discarded. For a horizontal postcode centroid that costs well under a metre; for anything vertical it is wrong by
300
- * the ~50 m geoid–ellipsoid separation over GB, so this function does not pretend to return a height.
147
+ * The transform ignores height, so use the result for horizontal positions only.
301
148
  */
302
- export function osgb36AiryToWGS84({ latitude, longitude }: GeodeticLatLon): GeodeticLatLon {
149
+ export function osgb36AiryToWGS84({ latitude, longitude }: GeoCoordinate): GeoCoordinate {
303
150
  const { tx, ty, tz, scalePPM, rx, ry, rz } = OSGB36_TO_WGS84_HELMERT
304
151
 
305
- // --- Airy 1830 geodetic → geocentric cartesian.
306
152
  const phi = (latitude * Math.PI) / 180
307
153
  const lambda = (longitude * Math.PI) / 180
308
154
  const sinPhi = Math.sin(phi)
@@ -314,7 +160,6 @@ export function osgb36AiryToWGS84({ latitude, longitude }: GeodeticLatLon): Geod
314
160
  const y1 = nuAiry * cosPhi * Math.sin(lambda)
315
161
  const z1 = (1 - e2Airy) * nuAiry * sinPhi
316
162
 
317
- // --- Helmert: rotate, scale, translate.
318
163
  const s = 1 + scalePPM * PPM
319
164
  const rxRad = rx * ARCSEC_TO_RAD
320
165
  const ryRad = ry * ARCSEC_TO_RAD
@@ -324,14 +169,12 @@ export function osgb36AiryToWGS84({ latitude, longitude }: GeodeticLatLon): Geod
324
169
  const y2 = ty + rzRad * x1 + s * y1 - rxRad * z1
325
170
  const z2 = tz - ryRad * x1 + rxRad * y1 + s * z1
326
171
 
327
- // --- GRS80 geocentric cartesian → geodetic, by the standard iteration on latitude.
328
172
  const e2GRS = (GRS80_A * GRS80_A - GRS80_B * GRS80_B) / (GRS80_A * GRS80_A)
329
173
  const p = Math.sqrt(x2 * x2 + y2 * y2)
330
174
 
331
175
  let phi2 = Math.atan2(z2, p * (1 - e2GRS))
332
176
  let phiPrev = 2 * Math.PI
333
177
 
334
- // Converges in a handful of passes at GB latitudes; the guard bounds it regardless.
335
178
  for (let i = 0; i < 100 && Math.abs(phi2 - phiPrev) > GEODETIC_LATITUDE_TOLERANCE_RAD; i++) {
336
179
  phiPrev = phi2
337
180
 
@@ -348,21 +191,19 @@ export function osgb36AiryToWGS84({ latitude, longitude }: GeodeticLatLon): Geod
348
191
  }
349
192
 
350
193
  /**
351
- * Convert a British National Grid (EPSG:27700) easting/northing straight to WGS84 (EPSG:4326) lat/lon — the composition
352
- * of {@link osgb36GridToAiryLatLon} and {@link osgb36AiryToWGS84}, and the function callers actually want.
194
+ * Converts a British National Grid (EPSG:27700) easting and northing to WGS84
195
+ * (EPSG:4326) latitude and longitude, accurate to about 5 m across GB.
353
196
  *
354
- * Accurate to about ±5 m across GB (see the module docstring). Does NOT validate that the input lies within the grid's
355
- * GB extent: `{easting: 0, northing: 0}` is a real point in the Atlantic south-west of the Scillies, and Code-Point
356
- * Open uses exactly that to mean "no coordinate available" (its 865 positional-quality-90 rows). Callers must filter
357
- * those rows themselves — a zero here is a legitimate coordinate, so this module cannot tell the difference.
197
+ * It converts `{ easting: 0, northing: 0 }` like any other point, so callers must
198
+ * filter out Code-Point Open's zero placeholder rows.
358
199
  */
359
- export function osgb36ToWGS84(point: NationalGridPoint): GeodeticLatLon {
200
+ export function osgb36ToWGS84(point: NationalGridPoint): GeoCoordinate {
360
201
  return osgb36AiryToWGS84(osgb36GridToAiryLatLon(point))
361
202
  }
362
203
 
363
204
  /**
364
- * {@link osgb36ToWGS84} in GeoJSON axis order — `[longitude, latitude]`, matching {@link Coordinates2D} and every
365
- * geometry helper in this package.
205
+ * Converts a National Grid point to WGS84 in GeoJSON `[longitude, latitude]` order,
206
+ * matching {@link Coordinates2D}.
366
207
  */
367
208
  export function osgb36ToCoordinates2D(point: NationalGridPoint): Coordinates2D {
368
209
  const { latitude, longitude } = osgb36ToWGS84(point)
package/lib/polyline.ts CHANGED
@@ -17,8 +17,9 @@ import { haversineKm } from "#distance"
17
17
  /**
18
18
  * Clamp a fraction into `[0, 1]`.
19
19
  *
20
- * NaN passes through, which is deliberate: an interpolation whose inputs were not numbers should produce NaN
21
- * coordinates a caller can detect, not silently snap to a segment's start.
20
+ * NaN passes through deliberately.
21
+ * An interpolation whose inputs were not numbers should produce NaN coordinates a
22
+ * caller can detect rather than silently snap to a segment's start.
22
23
  */
23
24
  export function clampFraction(t: number): number {
24
25
  return t < 0 ? 0 : Math.min(1, t)
@@ -27,7 +28,8 @@ export function clampFraction(t: number): number {
27
28
  /**
28
29
  * The point at fraction `t` of a polyline's total arc length (haversine), plus that total in km.
29
30
  *
30
- * `t` is assumed clamped to `[0, 1]`. A zero-length polyline yields its first vertex and a length of 0, so a degenerate
31
+ * `t` is assumed clamped to `[0, 1]`.
32
+ * A zero-length polyline yields its first vertex and a length of 0, so a degenerate
31
33
  * segment still produces a usable coordinate rather than NaN.
32
34
  */
33
35
  export function pointAlong(
package/lib/position.ts CHANGED
@@ -8,9 +8,25 @@
8
8
 
9
9
  import type { LatLngLiteral } from "@googlemaps/google-maps-services-js"
10
10
 
11
- import { isValidLatitude, isValidLongitude } from "#coordinate-bounds"
11
+ import { isValidLatitude, isValidLongitude } from "#coordinate/bounds"
12
12
 
13
- export { isValidLatitude, isValidLongitude } from "#coordinate-bounds"
13
+ export { isValidLatitude, isValidLongitude } from "#coordinate/bounds"
14
+
15
+ /**
16
+ * A point in decimal degrees under the `latitude` and `longitude` keys.
17
+ */
18
+ export interface GeoCoordinate {
19
+ latitude: number
20
+ longitude: number
21
+ }
22
+
23
+ /**
24
+ * A point in decimal degrees under the `lat` and `lon` keys.
25
+ */
26
+ export interface LatLon {
27
+ lat: number
28
+ lon: number
29
+ }
14
30
 
15
31
  /**
16
32
  * Arity of a `[lon, lat]` coordinate tuple.
@@ -25,8 +41,8 @@ const COORD_TRIPLE_LENGTH = 3
25
41
  /**
26
42
  * An ordered pair of coordinates in the form of [longitude, latitude].
27
43
  *
28
- * Note that unlike the typical order, GeoJSON coordinates are in the order of [longitude, latitude] to match the order
29
- * of [x, y] in Cartesian coordinates.
44
+ * Note that unlike the typical order, GeoJSON coordinates are in the order of
45
+ * [longitude, latitude] to match the order of [x, y] in Cartesian coordinates.
30
46
  *
31
47
  * @category Position
32
48
  * @category GeoJSON
@@ -0,0 +1,114 @@
1
+ import { runFile } from "@mailwoman/core/process"
2
+ import { TextSpliterator } from "spliterator"
3
+
4
+ /**
5
+ * @copyright Sister Software
6
+ * @license AGPL-3.0
7
+ * @author Teffen Ellis, et al.
8
+ *
9
+ * Ask PROJ which datum transformation it would choose. Refuse a ballpark operation.
10
+ *
11
+ * PROJ silently substitutes a ballpark datum shift when the accurate grid is absent. On the EA flood product,
12
+ * `ogr2ogr` placed the first feature's first vertex at `1.698151293, 52.648130027` without the OSGB36→WGS84 grid.
13
+ * With `uk_os_OSTN15_NTv2_OSGBtoETRS.tif` present, it placed the vertex at `1.698174628, 52.648157259`, a distance
14
+ * of 3.4 m. Both coordinates look like ordinary WGS84 values and pass a bounding-box check. The layer is offset.
15
+ * The check found eight disagreements among 59 points against the authority's OGC service. Each point fell into a
16
+ * neighboring sliver.
17
+ *
18
+ * GDAL 3.8 does not pass `--config PROJ_NETWORK on` through to PROJ. Tests also showed that `PROJ_ONLY_BEST=on`
19
+ * does not refuse a ballpark shift. `projinfo` provides the usable check. Its output identifies the best candidate
20
+ * operation and reports a missing grid.
21
+ *
22
+ * The check runs even when a source needs no transformation. A source already in EPSG:4326 returns
23
+ * `Null geographic offset from WGS 84 to WGS 84, 0 m, World.` This operation is usable. The check costs one process.
24
+ * A skipped case would leave a later source's required grid unchecked.
25
+ *
26
+ * Every vector ingest shares this check because the failure comes from PROJ rather than from a particular product.
27
+ * Output parsing is separate from process execution so tests can use captured output. The two output states came from the
28
+ * same command on the same machine before and after grid installation. One produced a meter-accurate layer. The
29
+ * other produced a 3 m offset.
30
+ */
31
+
32
+ /**
33
+ * Reports the operation PROJ would choose and whether it can run it.
34
+ */
35
+ export interface DatumTransformationVerdict {
36
+ /**
37
+ * The candidate operation string returned by PROJ, verbatim.
38
+ *
39
+ * Absent when PROJ returned no candidate operation.
40
+ */
41
+ best?: string
42
+ usable: boolean
43
+ reason: string
44
+ }
45
+
46
+ /**
47
+ * Reads `projinfo --summary` output.
48
+ *
49
+ * It reports which operation PROJ would choose and whether it can run it.
50
+ */
51
+ export function assessDatumTransformation(summary: string): DatumTransformationVerdict {
52
+ // The first line naming a candidate operation is the one PROJ will choose.
53
+ // Earlier lines are headers.
54
+ // The `Note:` line about `--spatial-test` also describes no candidate operation.
55
+ // The reader trims each line.
56
+ const best = TextSpliterator.from(summary).find(
57
+ (line) => line.includes(", ") && !line.startsWith("Note:") && !line.startsWith("Candidate operations")
58
+ )
59
+
60
+ if (!best) return { usable: false, reason: "projinfo named no candidate operation" }
61
+
62
+ if (best.includes("grid missing")) return { best, usable: false, reason: "its grid is not installed" }
63
+
64
+ if (best.toLowerCase().includes("ballpark")) return { best, usable: false, reason: "it is a ballpark offset" }
65
+
66
+ return { best, usable: true, reason: "the best operation is available" }
67
+ }
68
+
69
+ /**
70
+ * The target every layer ingest reprojects to.
71
+ * H3 takes WGS84 latitude and longitude.
72
+ */
73
+ export const WGS84_EPSG = 4326
74
+
75
+ export interface AssertDatumTransformationOptions {
76
+ /**
77
+ * Identifies the caller in the refusal, so a build log reports which ingest stopped.
78
+ */
79
+ context: string
80
+ targetEPSG?: number
81
+ /**
82
+ * The area-of-use to name in the `projsync` action the message prints.
83
+ */
84
+ areaOfUse?: string
85
+ }
86
+
87
+ /**
88
+ * Refuse an ingest whose best available datum transformation is a ballpark one, or is missing its grid.
89
+ *
90
+ * @throws {Error} When proj names no candidate, would use a ballpark offset,
91
+ * or would use an operation whose grid is not installed.
92
+ */
93
+ export async function assertDatumTransformationAvailable(
94
+ sourceEPSG: number,
95
+ options: AssertDatumTransformationOptions
96
+ ): Promise<DatumTransformationVerdict> {
97
+ const targetEPSG = options.targetEPSG ?? WGS84_EPSG
98
+
99
+ const { stdout } = await runFile("projinfo", ["-s", `EPSG:${sourceEPSG}`, "-t", `EPSG:${targetEPSG}`, "--summary"])
100
+
101
+ const verdict = assessDatumTransformation(stdout)
102
+
103
+ if (verdict.usable) return verdict
104
+
105
+ const remedy = options.areaOfUse
106
+ ? `Install the grid with \`projsync --area-of-use "${options.areaOfUse}"\` and re-run.`
107
+ : "Install the grid with `projsync` for the source's area of use and re-run."
108
+
109
+ throw new Error(
110
+ `${options.context}: the best EPSG:${sourceEPSG} → EPSG:${targetEPSG} transformation is unusable — ${verdict.reason} ` +
111
+ `(${verdict.best ?? "projinfo named no candidate"}). PROJ falls back to a ballpark datum shift, which is meters ` +
112
+ `wrong and looks exactly like a correct answer. ${remedy}`
113
+ )
114
+ }
package/lib/projection.ts CHANGED
@@ -17,7 +17,7 @@ export const CoordinateProjection = {
17
17
  */
18
18
  WGS84: "4326",
19
19
  /**
20
- * North American Datum 1983, a geodetic reference system used in the TIGER/Line data.
20
+ * North American Datum 1983, a geodetic reference system used in the tiger/Line data.
21
21
  */
22
22
  NAD83: "4269",
23
23
  } as const
@@ -11,7 +11,7 @@ import wkx from "wkx"
11
11
  import type { GeometryCollection, GeometryLiteral } from "#index"
12
12
 
13
13
  /**
14
- * Given an extended Well-Known Binary (EWKB) buffer, parse it into a GeoJSON geometry object.
14
+ * Given an extended Well-Known Binary (ewkb) buffer, parse it into a GeoJSON geometry object.
15
15
  *
16
16
  * @category Geo
17
17
  */
@@ -34,40 +34,40 @@ export function wellKnownGeometryToGeoJSON<T = GeometryLiteral>(input: Buffer |
34
34
  }
35
35
 
36
36
  /**
37
- * Given a GeoJSON geometry object, convert it to an well-known binary (EWKB) buffer.
37
+ * Given a GeoJSON geometry object, convert it to an well-known binary (ewkb) buffer.
38
38
  *
39
39
  * @category Geo
40
40
  *
41
- * @returns A hex-encoded EWKB string or WKB buffer.
41
+ * @returns A hex-encoded ewkb string or WKB buffer.
42
42
  */
43
43
  export function geometryToWKB(geometry: GeometryLiteral | GeometryCollection) {
44
44
  return wkx.Geometry.parseGeoJSON(geometry).toWkb()
45
45
  }
46
46
 
47
47
  /**
48
- * Given a GeoJSON geometry object, convert it to an extended well-known binary (EWKB) buffer.
48
+ * Given a GeoJSON geometry object, convert it to an extended well-known binary (ewkb) buffer.
49
49
  *
50
50
  * @category Geo
51
51
  *
52
- * @returns A buffer representing the EWKB.
52
+ * @returns A buffer representing the ewkb.
53
53
  */
54
54
  export function geometryToEWKB(geometry: GeometryLiteral | GeometryCollection) {
55
55
  return wkx.Geometry.parseGeoJSON(geometry).toEwkb()
56
56
  }
57
57
 
58
58
  /**
59
- * Given a GeoJSON geometry object, convert it to an extended well-known binary (EWKB) buffer.
59
+ * Given a GeoJSON geometry object, convert it to an extended well-known binary (ewkb) buffer.
60
60
  *
61
61
  * @category Geo
62
62
  *
63
- * @returns A hex-encoded string representing the EWKB.
63
+ * @returns A hex-encoded string representing the ewkb.
64
64
  */
65
65
  export function geometryToEWKH(geometry: GeometryLiteral | GeometryCollection) {
66
66
  return geometryToEWKB(geometry).toString("hex")
67
67
  }
68
68
 
69
69
  /**
70
- * Given a GeoJSON geometry object, convert it to an extended well-known text (EWKT) string.
70
+ * Given a GeoJSON geometry object, convert it to an extended well-known text (ewkt) string.
71
71
  *
72
72
  * @category Geo
73
73
  */
package/out/bbox.d.ts CHANGED
@@ -48,7 +48,8 @@ export type BBox2DLiteral = [
48
48
  maxLatitude: number
49
49
  ];
50
50
  /**
51
- * A 3-dimensional rectangular area that can be determined by two longitudes, two latitudes, and two altitudes.
51
+ * A 3-dimensional rectangular area bounded by two longitudes and two latitudes.
52
+ * Two altitudes set its vertical bounds.
52
53
  *
53
54
  * @category GeoJSON
54
55
  * @category Bounding Box
@@ -122,8 +123,8 @@ export declare function isBBox(input: unknown): input is BBox2DLiteral | BBox3DL
122
123
  /**
123
124
  * Type-predicate to determine if the given input is a GeoBoundingBox instance.
124
125
  *
125
- * Note that this function only checks if the input is an instance of the GeoBoundingBox class. `instanceof` checks are
126
- * not reliable in JavaScript, so this function should be used with caution.
126
+ * Note that this function only checks if the input is an instance of the GeoBoundingBox class.
127
+ * `instanceof` checks are not reliable in JavaScript, so this function should be used with caution.
127
128
  *
128
129
  * @category GeoJSON
129
130
  */
@@ -135,8 +136,8 @@ export type GeoBoundingBoxInput = BBox2DLiteral | BBox3DLiteral | GeoBoundingBox
135
136
  /**
136
137
  * A bounding box to represent the coordinate range of a GeoJSON object.
137
138
  *
138
- * This is useful when defining the extent of a GeoJSON object, such as the minimum and maximum coordinates of the
139
- * object's Geometries, Features, or Feature Collections.
139
+ * This is useful when defining the extent of a GeoJSON object, such as the minimum
140
+ * and maximum coordinates of the object's Geometries, Features, or Feature Collections.
140
141
  */
141
142
  export declare class GeoBoundingBox {
142
143
  #private;
@@ -202,10 +203,7 @@ export declare class GeoBoundingBox {
202
203
  to2DEWKT(): string;
203
204
  }
204
205
  /**
205
- * A flat latitude/longitude range, as a query filter rather than a model.
206
- *
207
- * Distinct from {@linkcode GeoBoundingBox} on purpose: that is a class carrying a projection and private state, which an
208
- * SQL row cannot be. This is the plain shape a spatial-index query is built from — four numbers, no behaviour.
206
+ * Plain latitude and longitude bounds in decimal degrees.
209
207
  */
210
208
  export interface LatLonBounds {
211
209
  minLat: number;
@@ -216,10 +214,15 @@ export interface LatLonBounds {
216
214
  /**
217
215
  * Approximate bounds `radiusKM` in each direction around a point.
218
216
  *
219
- * The spherical-Earth equirectangular approximation: 1° latitude ≈ 111 km globally, 1° longitude ≈ 111 km × cos(lat).
220
- * It is a FILTER, not an answer — it over-selects near the poles and along a long east-west span, and a caller is
221
- * expected to re-check survivors with an exact haversine distance. That is what makes the approximation safe: it may
222
- * admit a point it should not, and never excludes one it should keep.
217
+ * The spherical-Earth equirectangular approximation: 1° latitude ≈ 111 km globally,
218
+ * 1° longitude ≈ 111 km × cos(lat).
219
+ * It is a filter rather than an answer.
220
+ *
221
+ * It over-selects near the poles and along a long east-west span.
222
+ * Callers must re-check survivors with an exact haversine distance.
223
+ *
224
+ * The approximation may admit points outside the radius.
225
+ * It includes every point within the radius.
223
226
  */
224
227
  export declare function bboxAround(lat: number, lon: number, radiusKM: number): LatLonBounds;
225
228
  //# sourceMappingURL=bbox.d.ts.map
package/out/bbox.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bbox.d.ts","sourceRoot":"","sources":["../lib/bbox.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,qBAAqB,CAAA;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAwBlD;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B;;;;;OAKG;IACH,YAAY,EAAE,MAAM;IACpB;;;;;OAKG;IACH,WAAW,EAAE,MAAM;IACnB;;;;;OAKG;IACH,YAAY,EAAE,MAAM;IACpB;;;;;OAKG;IACH,WAAW,EAAE,MAAM;CACnB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B;;;;;OAKG;IACH,YAAY,EAAE,MAAM;IACpB;;;;;OAKG;IACH,WAAW,EAAE,MAAM;IAEnB;;OAEG;IACH,WAAW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