@mailwoman/spatial 9.1.0 → 9.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 (49) hide show
  1. package/bbox.ts +51 -0
  2. package/coordinate-bounds.ts +41 -0
  3. package/coordinate-formats.ts +13 -2
  4. package/distance.ts +84 -0
  5. package/geometries/polygon.ts +87 -7
  6. package/index.ts +3 -0
  7. package/open-location-code.ts +168 -0
  8. package/out/bbox.d.ts +21 -0
  9. package/out/bbox.d.ts.map +1 -1
  10. package/out/bbox.js +31 -0
  11. package/out/bbox.js.map +1 -1
  12. package/out/coordinate-bounds.d.ts +32 -0
  13. package/out/coordinate-bounds.d.ts.map +1 -0
  14. package/out/coordinate-bounds.js +36 -0
  15. package/out/coordinate-bounds.js.map +1 -0
  16. package/out/coordinate-formats.d.ts +8 -0
  17. package/out/coordinate-formats.d.ts.map +1 -1
  18. package/out/coordinate-formats.js +12 -2
  19. package/out/coordinate-formats.js.map +1 -1
  20. package/out/distance.d.ts +46 -0
  21. package/out/distance.d.ts.map +1 -0
  22. package/out/distance.js +70 -0
  23. package/out/distance.js.map +1 -0
  24. package/out/geometries/polygon.d.ts +53 -0
  25. package/out/geometries/polygon.d.ts.map +1 -1
  26. package/out/geometries/polygon.js +40 -7
  27. package/out/geometries/polygon.js.map +1 -1
  28. package/out/index.d.ts +3 -0
  29. package/out/index.d.ts.map +1 -1
  30. package/out/index.js +3 -0
  31. package/out/index.js.map +1 -1
  32. package/out/open-location-code.d.ts +48 -0
  33. package/out/open-location-code.d.ts.map +1 -0
  34. package/out/open-location-code.js +137 -0
  35. package/out/open-location-code.js.map +1 -0
  36. package/out/polyline.js +1 -1
  37. package/out/position.d.ts +4 -61
  38. package/out/position.d.ts.map +1 -1
  39. package/out/position.js +14 -126
  40. package/out/position.js.map +1 -1
  41. package/out/sdk/well-known-text.d.ts +1 -1
  42. package/out/sdk/well-known-text.d.ts.map +1 -1
  43. package/out/sdk/well-known-text.js.map +1 -1
  44. package/out/tsconfig.test.tsbuildinfo +1 -1
  45. package/out/tsconfig.tsbuildinfo +1 -1
  46. package/package.json +66 -6
  47. package/polyline.ts +1 -1
  48. package/position.ts +15 -144
  49. package/sdk/well-known-text.ts +2 -1
@@ -0,0 +1,137 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Open Location Code (plus code) decode + nearest-recovery — the coordinate system Google Maps
7
+ * prints on every place card, which makes it a first-class user register in countries with sparse
8
+ * street addressing (the Nicaraguan board rows arrived exactly this way). Pure arithmetic over the
9
+ * published spec (https://github.com/google/open-location-code/blob/main/docs/specification.md);
10
+ * no dependency, no I/O.
11
+ *
12
+ * A FULL code (8 digits, a `+`, then 2–3 more) decodes directly. A SHORT code (2–6 leading digits
13
+ * removed, e.g. `VFQ6+92P`) is only meaningful near a reference point — the removed prefix is
14
+ * recovered from the reference, then the candidate cell is shifted by whole prefix-resolutions if
15
+ * a neighboring cell sits closer (the spec's `recoverNearest`). The reference in an address is the
16
+ * RESOLVED LOCALITY, which is why the geocode wiring recovers after the admin walk.
17
+ */
18
+ /**
19
+ * The 20-character OLC digit set. Deliberately excludes letters that read as words or digits (no A/E/I/L/N/O/S/T…), so
20
+ * a matched token is very unlikely to be ordinary text.
21
+ */
22
+ const OLC_ALPHABET = "23456789CFGHJMPQRVWX";
23
+ const OLC_DIGIT_VALUE = new Map([...OLC_ALPHABET].map((c, i) => [c, i]));
24
+ /**
25
+ * Degree width of each pair-position, most significant first: the pair at index i spans `20^(2-i)` degrees. Ten pair
26
+ * digits (five lat/lon pairs) take a cell to 1/400° ≈ 275 m; grid digits refine further.
27
+ */
28
+ const PAIR_RESOLUTIONS = [20, 1, 1 / 20, 1 / 400, 1 / 8000];
29
+ /**
30
+ * Grid refinement past ten digits: each digit subdivides the cell into 4 columns × 5 rows.
31
+ */
32
+ const GRID_COLUMNS = 4;
33
+ const GRID_ROWS = 5;
34
+ /**
35
+ * A syntactically-valid FULL plus code: exactly 8 digits, `+`, then 2 or 3 digits. (The spec allows padded and longer
36
+ * forms; addresses carry the 10–11 digit register, which is all this reader accepts.)
37
+ */
38
+ export function isFullPlusCode(token) {
39
+ return /^[23456789CFGHJMPQRVWX]{8}\+[23456789CFGHJMPQRVWX]{2,3}$/i.test(token);
40
+ }
41
+ /**
42
+ * A syntactically-valid SHORT plus code: 2, 4, or 6 leading digits removed — so 6, 4, or 2 digits before the `+`. The
43
+ * 4-before-`+` form (`VFQ6+92P`) is the one Google prints on place cards.
44
+ */
45
+ export function isShortPlusCode(token) {
46
+ return /^[23456789CFGHJMPQRVWX]{2,6}\+[23456789CFGHJMPQRVWX]{2,3}$/i.test(token) && token.indexOf("+") % 2 === 0;
47
+ }
48
+ /**
49
+ * Decode a FULL plus code to its cell. Returns null on anything `isFullPlusCode` rejects.
50
+ */
51
+ export function decodePlusCode(code) {
52
+ if (!isFullPlusCode(code))
53
+ return null;
54
+ const digits = code.toUpperCase().replace("+", "");
55
+ let latLo = -90;
56
+ let lonLo = -180;
57
+ let latSpan = 400;
58
+ let lonSpan = 400;
59
+ // The first ten digits arrive in (lat, lon) pairs.
60
+ const pairCount = Math.min(digits.length, 10);
61
+ for (let i = 0; i < pairCount; i += 2) {
62
+ const resolution = PAIR_RESOLUTIONS[i / 2];
63
+ latLo += OLC_DIGIT_VALUE.get(digits[i]) * resolution;
64
+ lonLo += OLC_DIGIT_VALUE.get(digits[i + 1]) * resolution;
65
+ latSpan = resolution;
66
+ lonSpan = resolution;
67
+ }
68
+ // Grid refinement: each further digit indexes a 4×5 (columns × rows) subdivision.
69
+ for (let i = 10; i < digits.length; i++) {
70
+ const value = OLC_DIGIT_VALUE.get(digits[i]);
71
+ latSpan /= GRID_ROWS;
72
+ lonSpan /= GRID_COLUMNS;
73
+ latLo += Math.floor(value / GRID_COLUMNS) * latSpan;
74
+ lonLo += (value % GRID_COLUMNS) * lonSpan;
75
+ }
76
+ return {
77
+ lat: latLo + latSpan / 2,
78
+ lon: lonLo + lonSpan / 2,
79
+ latSpanDeg: latSpan,
80
+ lonSpanDeg: lonSpan,
81
+ };
82
+ }
83
+ /**
84
+ * Encode the pair digits of a coordinate to `length` digits (length ≤ 10, even) — the prefix machinery
85
+ * {@link recoverNearestPlusCode} needs; not a general encoder.
86
+ */
87
+ function encodePairDigits(lat, lon, length) {
88
+ let latVal = Math.min(Math.max(lat + 90, 0), 180 - 1e-12);
89
+ let lonVal = lon + 180;
90
+ lonVal -= Math.floor(lonVal / 360) * 360;
91
+ let out = "";
92
+ for (let i = 0; i < length / 2; i++) {
93
+ const resolution = PAIR_RESOLUTIONS[i];
94
+ const latDigit = Math.min(Math.floor(latVal / resolution), 19);
95
+ const lonDigit = Math.min(Math.floor(lonVal / resolution), 19);
96
+ out += OLC_ALPHABET[latDigit] + OLC_ALPHABET[lonDigit];
97
+ latVal -= latDigit * resolution;
98
+ lonVal -= lonDigit * resolution;
99
+ }
100
+ return out;
101
+ }
102
+ /**
103
+ * Recover a SHORT plus code against a reference coordinate, per the spec's `recoverNearest`: prepend the reference's
104
+ * prefix at the missing precision, then shift the candidate cell by whole prefix-resolutions when a neighboring cell
105
+ * center sits closer to the reference. Returns the decoded nearest cell, or null for an invalid short code.
106
+ */
107
+ export function recoverNearestPlusCode(shortCode, refLat, refLon) {
108
+ if (!isShortPlusCode(shortCode))
109
+ return null;
110
+ const upper = shortCode.toUpperCase();
111
+ const missing = 8 - upper.indexOf("+");
112
+ const prefix = encodePairDigits(refLat, refLon, missing);
113
+ const candidate = decodePlusCode(prefix + upper);
114
+ if (!candidate)
115
+ return null;
116
+ // The prefix pins the cell modulo its own resolution; the nearest bearer of the short code may sit
117
+ // one prefix-cell away (the reference near a cell edge). Shift by whole prefix-resolutions, never
118
+ // past the poles.
119
+ const LAT_MIN = -90;
120
+ const LAT_MAX = 90;
121
+ const prefixResolution = PAIR_RESOLUTIONS[missing / 2 - 1];
122
+ const result = { ...candidate };
123
+ if (refLat + prefixResolution / 2 < result.lat && result.lat - prefixResolution >= LAT_MIN) {
124
+ result.lat -= prefixResolution;
125
+ }
126
+ else if (refLat - prefixResolution / 2 > result.lat && result.lat + prefixResolution <= LAT_MAX) {
127
+ result.lat += prefixResolution;
128
+ }
129
+ if (refLon + prefixResolution / 2 < result.lon) {
130
+ result.lon -= prefixResolution;
131
+ }
132
+ else if (refLon - prefixResolution / 2 > result.lon) {
133
+ result.lon += prefixResolution;
134
+ }
135
+ return result;
136
+ }
137
+ //# sourceMappingURL=open-location-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-location-code.js","sourceRoot":"","sources":["../open-location-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;GAGG;AACH,MAAM,YAAY,GAAG,sBAAsB,CAAA;AAE3C,MAAM,eAAe,GAAG,IAAI,GAAG,CAAiB,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;AAExF;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,IAAI,CAAU,CAAA;AAEpE;;GAEG;AACH,MAAM,YAAY,GAAG,CAAC,CAAA;AACtB,MAAM,SAAS,GAAG,CAAC,CAAA;AAanB;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC3C,OAAO,2DAA2D,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAC/E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC5C,OAAO,6DAA6D,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;AACjH,CAAC;AAED;;GAEG;AAC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AM,CAAC,GAAG,IAAI,gBAAgB,CAAA;IAC/B,CAAC;SAAM,IAAI,MAAM,GAAG,gBAAgB,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;QACvD,MAAM,CAAC,GAAG,IAAI,gBAAgB,CAAA;IAC/B,CAAC;IAED,OAAO,MAAM,CAAA;AACd,CAAC"}
package/out/polyline.js CHANGED
@@ -11,7 +11,7 @@
11
11
  * `docs/src/shared/httpvfs-street.ts` — under a header telling both to be kept in lockstep by hand.
12
12
  * The geometry never differed between them; only the I/O around it did.
13
13
  */
14
- import { haversineKm } from "./position.js";
14
+ import { haversineKm } from "./distance.js";
15
15
  /**
16
16
  * Clamp a fraction into `[0, 1]`.
17
17
  *
package/out/position.d.ts CHANGED
@@ -6,24 +6,7 @@
6
6
  * This file contains types and utilities for working with geographic positions.
7
7
  */
8
8
  import type { LatLngLiteral } from "@googlemaps/google-maps-services-js";
9
- import { type GeoPointInput } from "@mailwoman/spatial";
10
- /**
11
- * Whether a number is a latitude a point can actually sit at: finite, and within [-90, 90] inclusive (the poles count).
12
- * Distinct from {@link clampLatitude}, which folds an out-of-range value onto the nearest pole — clamping is right for a
13
- * viewport edge and wrong for a coordinate, where an out-of-range value means the input was malformed and the repaired
14
- * point is fiction.
15
- *
16
- * @category Position
17
- */
18
- export declare function isValidLatitude(value: number): boolean;
19
- /**
20
- * Whether a number is a longitude a point can actually sit at: finite, and within [-180, 180] inclusive. Same
21
- * distinction from {@link wrapLongitude} that {@link isValidLatitude} draws from `clampLatitude` — wrapping 190° to -170°
22
- * is correct for a pan gesture and a silent relocation for a parsed coordinate.
23
- *
24
- * @category Position
25
- */
26
- export declare function isValidLongitude(value: number): boolean;
9
+ export { isValidLatitude, isValidLongitude } from "./coordinate-bounds.ts";
27
10
  /**
28
11
  * An ordered pair of coordinates in the form of [longitude, latitude].
29
12
  *
@@ -69,23 +52,10 @@ export declare function orderCoordPairToGeoJSON([latitude, longitude]: [number,
69
52
  */
70
53
  export declare function orderGeoJSONToCoordPair([longitude, latitude]: Coordinates2D): [number, number];
71
54
  /**
72
- * Given an input which appears to be reversed GeoJSON coordinates (i.e. [latitude, longitude]), returns the coordinates
73
- * in the correct order of [longitude, latitude].
74
- *
75
- * **This cannot do what its name promises, and nothing in this repo calls it.** The only signal it has is the [-90, 90]
76
- * latitude range, so it transposes a pair only when the SECOND magnitude falls outside that range — i.e. only where
77
- * |longitude| > 90. It is therefore inert across every longitude in [-90, 90]: all of Europe and Africa, western
78
- * Russia, the Middle East, India, and the Atlantic. A caller who hands it `[latitude, longitude]` gets the pair
79
- * repaired in Dallas and left corrupted in Berlin, from one code path, decided by the data. That is why `GeoPoint`
80
- * stopped calling it on 2026-08-05 (recorded in `e9bfd139`; `registry/tools/geocoder-vs-provided-coords.ts` had already
81
- * routed around it) and now reads a 2-tuple as GeoJSON [longitude, latitude], full stop.
55
+ * Infers GeoJSON `[longitude, latitude]` order from coordinate bounds.
82
56
  *
83
- * Retained as an explicit, opt-in escape hatch for a caller who knows their source is lat-first AND North American. If
84
- * you know the axis order, use {@link orderCoordPairToGeoJSON}; if you do not, no function can tell you.
85
- *
86
- * @deprecated Axis order is metadata, not something a magnitude can recover. Prefer `orderCoordPairToGeoJSON`.
87
- * @category GeoJSON
88
- * @category Position
57
+ * @returns The coordinates ordered as [longitude, latitude] when exactly one possible ordering is valid.
58
+ * @throws {RangeError} When axis order is ambiguous or coordinates are invalid.
89
59
  */
90
60
  export declare function inferGeoJSONCoordOrder([coordA, coordB]: [number, number]): Coordinates2D;
91
61
  /**
@@ -174,31 +144,4 @@ export declare function wrapLongitude(longitude: number): number;
174
144
  * @param value The latitude value to clamp.
175
145
  */
176
146
  export declare function clampLatitude(value: number): number;
177
- /**
178
- * Conversion factors for converting between degrees and radians.
179
- *
180
- * @category Position
181
- * @see {@link https://en.wikipedia.org/wiki/Radian Wikipedia: Radian}
182
- * @see {@link https://en.wikipedia.org/wiki/Degree_(angle) Wikipedia: Degree (angle)}
183
- */
184
- export declare const ConversionFactor: {
185
- readonly DegreesToRadians: 0.01745329251;
186
- readonly RadiansToDegrees: 57.2957795131;
187
- };
188
- /**
189
- * Available conversion units for the radius of the Earth.
190
- */
191
- export type EarthRadiusUnit = "km" | "miles" | "meters";
192
- export declare function haversine(point1: GeoPointInput, point2: GeoPointInput, unit?: EarthRadiusUnit): number;
193
- /**
194
- * Great-circle distance in kilometres between two lat/lon pairs given as raw scalars. The formula's one true home —
195
- * every resolver + eval consumer of the `(aLat, aLon, bLat, bLon)` shape imports this instead of re-declaring it.
196
- *
197
- * Unlike {@link haversine}, this is pure math with NO Null-Island sentinel: `(0, 0)` is the Gulf of Guinea — a real
198
- * point, not "missing coordinate". That sentinel convention belongs to the `GeoPointInput` object form (where a 0/0
199
- * input means "no coordinate"), not to a raw scalar distance.
200
- *
201
- * @category Position
202
- */
203
- export declare function haversineKm(aLat: number, aLon: number, bLat: number, bLon: number): number;
204
147
  //# sourceMappingURL=position.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../position.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAsBjE;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvD;AAYD;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B;;;;;OAKG;IACH,SAAS,EAAE,MAAM;IACjB;;;;;OAKG;IACH,QAAQ,EAAE,MAAM;CAChB,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GA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,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;;;OAKG;IACH,CAAC,EAAE,MAAM,CAAA;IACT;;;;;OAKG;IACH,CAAC,EAAE,MAAM,CAAA;CACT;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAMvG;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAMhF;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,wBAAwB,CAQ3F;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD"}
package/out/position.js CHANGED
@@ -5,44 +5,8 @@
5
5
  *
6
6
  * This file contains types and utilities for working with geographic positions.
7
7
  */
8
- import { GeoPoint } from "@mailwoman/spatial";
9
- /**
10
- * Southern limit of latitude in WGS84 degrees. Outside it a value cannot be a latitude.
11
- */
12
- const LATITUDE_MIN = -90;
13
- /**
14
- * Northern limit of latitude in WGS84 degrees.
15
- */
16
- const LATITUDE_MAX = 90;
17
- /**
18
- * Western limit of longitude in WGS84 degrees (the antimeridian, which is itself a valid longitude).
19
- */
20
- const LONGITUDE_MIN = -180;
21
- /**
22
- * Eastern limit of longitude in WGS84 degrees.
23
- */
24
- const LONGITUDE_MAX = 180;
25
- /**
26
- * Whether a number is a latitude a point can actually sit at: finite, and within [-90, 90] inclusive (the poles count).
27
- * Distinct from {@link clampLatitude}, which folds an out-of-range value onto the nearest pole — clamping is right for a
28
- * viewport edge and wrong for a coordinate, where an out-of-range value means the input was malformed and the repaired
29
- * point is fiction.
30
- *
31
- * @category Position
32
- */
33
- export function isValidLatitude(value) {
34
- return Number.isFinite(value) && value >= LATITUDE_MIN && value <= LATITUDE_MAX;
35
- }
36
- /**
37
- * Whether a number is a longitude a point can actually sit at: finite, and within [-180, 180] inclusive. Same
38
- * distinction from {@link wrapLongitude} that {@link isValidLatitude} draws from `clampLatitude` — wrapping 190° to -170°
39
- * is correct for a pan gesture and a silent relocation for a parsed coordinate.
40
- *
41
- * @category Position
42
- */
43
- export function isValidLongitude(value) {
44
- return Number.isFinite(value) && value >= LONGITUDE_MIN && value <= LONGITUDE_MAX;
45
- }
8
+ import { isValidLatitude, isValidLongitude } from "./coordinate-bounds.js";
9
+ export { isValidLatitude, isValidLongitude } from "./coordinate-bounds.js";
46
10
  /**
47
11
  * Arity of a `[lon, lat]` coordinate tuple.
48
12
  */
@@ -74,39 +38,24 @@ export function orderGeoJSONToCoordPair([longitude, latitude]) {
74
38
  return [latitude, longitude];
75
39
  }
76
40
  /**
77
- * Given an input which appears to be reversed GeoJSON coordinates (i.e. [latitude, longitude]), returns the coordinates
78
- * in the correct order of [longitude, latitude].
41
+ * Infers GeoJSON `[longitude, latitude]` order from coordinate bounds.
79
42
  *
80
- * **This cannot do what its name promises, and nothing in this repo calls it.** The only signal it has is the [-90, 90]
81
- * latitude range, so it transposes a pair only when the SECOND magnitude falls outside that range — i.e. only where
82
- * |longitude| > 90. It is therefore inert across every longitude in [-90, 90]: all of Europe and Africa, western
83
- * Russia, the Middle East, India, and the Atlantic. A caller who hands it `[latitude, longitude]` gets the pair
84
- * repaired in Dallas and left corrupted in Berlin, from one code path, decided by the data. That is why `GeoPoint`
85
- * stopped calling it on 2026-08-05 (recorded in `e9bfd139`; `registry/tools/geocoder-vs-provided-coords.ts` had already
86
- * routed around it) and now reads a 2-tuple as GeoJSON [longitude, latitude], full stop.
87
- *
88
- * Retained as an explicit, opt-in escape hatch for a caller who knows their source is lat-first AND North American. If
89
- * you know the axis order, use {@link orderCoordPairToGeoJSON}; if you do not, no function can tell you.
90
- *
91
- * @deprecated Axis order is metadata, not something a magnitude can recover. Prefer `orderCoordPairToGeoJSON`.
92
- * @category GeoJSON
93
- * @category Position
43
+ * @returns The coordinates ordered as [longitude, latitude] when exactly one possible ordering is valid.
44
+ * @throws {RangeError} When axis order is ambiguous or coordinates are invalid.
94
45
  */
95
46
  export function inferGeoJSONCoordOrder([coordA, coordB]) {
96
- // Latitude values typically range from -90 to 90
97
- const isCoordALat = coordA >= LATITUDE_MIN && coordA <= LATITUDE_MAX;
98
- const isCoordBLat = coordB >= LATITUDE_MIN && coordB <= LATITUDE_MAX;
99
- if (isCoordALat && !isCoordBLat) {
100
- // coordA is latitude, coordB is longitude
47
+ const geoJSONIsValid = isValidLongitude(coordA) && isValidLatitude(coordB);
48
+ const latLonIsValid = isValidLatitude(coordA) && isValidLongitude(coordB);
49
+ if (geoJSONIsValid && !latLonIsValid) {
50
+ return [coordA, coordB];
51
+ }
52
+ if (latLonIsValid && !geoJSONIsValid) {
101
53
  return [coordB, coordA];
102
54
  }
103
- if (!isCoordALat && isCoordBLat) {
104
- // coordB is latitude, coordA is longitude
105
- return [coordA, coordB];
55
+ if (geoJSONIsValid && latLonIsValid) {
56
+ throw new RangeError(`Cannot infer coordinate order: [${coordA}, ${coordB}] is valid in both axis orders.`);
106
57
  }
107
- // In case both appear to be latitudes (unlikely) or longitudes (out of range for US),
108
- // assume coordA is longitude and coordB is latitude as default.
109
- return [coordA, coordB];
58
+ throw new RangeError(`Invalid coordinate pair: [${coordA}, ${coordB}].`);
110
59
  }
111
60
  /**
112
61
  * Type-predicate to determine if the given input is a GeoJSON Point geometry.
@@ -172,65 +121,4 @@ export function wrapLongitude(longitude) {
172
121
  export function clampLatitude(value) {
173
122
  return Math.min(90, Math.max(-90, value));
174
123
  }
175
- /**
176
- * Conversion factors for converting between degrees and radians.
177
- *
178
- * @category Position
179
- * @see {@link https://en.wikipedia.org/wiki/Radian Wikipedia: Radian}
180
- * @see {@link https://en.wikipedia.org/wiki/Degree_(angle) Wikipedia: Degree (angle)}
181
- */
182
- export const ConversionFactor = {
183
- DegreesToRadians: (Math.PI / 180),
184
- RadiansToDegrees: (180 / Math.PI),
185
- };
186
- /**
187
- * Radius of the Earth in various units
188
- */
189
- const RADII = {
190
- km: 6371,
191
- miles: 3958.8,
192
- meters: 6_371_000,
193
- };
194
- /**
195
- * Calculate the distance between two points on the Earth's surface.
196
- *
197
- * @category Position
198
- * @param point1 The first point to calculate the distance from.
199
- * @param point2 The second point to calculate the distance to.
200
- * @param unit The unit of measurement to return the distance in.
201
- *
202
- * @returns The distance between the two points in the specified unit.
203
- */
204
- /**
205
- * Shared great-circle math (no sentinel handling). `unit` selects the Earth radius.
206
- */
207
- function greatCircle(lat1, lon1, lat2, lon2, unit) {
208
- const dLat = (lat2 - lat1) * ConversionFactor.DegreesToRadians;
209
- const dLon = (lon2 - lon1) * ConversionFactor.DegreesToRadians;
210
- const a = Math.pow(Math.sin(dLat / 2), 2) +
211
- Math.cos(lat1 * ConversionFactor.DegreesToRadians) *
212
- Math.cos(lat2 * ConversionFactor.DegreesToRadians) *
213
- Math.pow(Math.sin(dLon / 2), 2);
214
- return RADII[unit] * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
215
- }
216
- export function haversine(point1, point2, unit = "km") {
217
- const p1 = GeoPoint.from(point1);
218
- const p2 = GeoPoint.from(point2);
219
- if (!p1 || !p2)
220
- return Number.NaN;
221
- return greatCircle(p1.latitude, p1.longitude, p2.latitude, p2.longitude, unit);
222
- }
223
- /**
224
- * Great-circle distance in kilometres between two lat/lon pairs given as raw scalars. The formula's one true home —
225
- * every resolver + eval consumer of the `(aLat, aLon, bLat, bLon)` shape imports this instead of re-declaring it.
226
- *
227
- * Unlike {@link haversine}, this is pure math with NO Null-Island sentinel: `(0, 0)` is the Gulf of Guinea — a real
228
- * point, not "missing coordinate". That sentinel convention belongs to the `GeoPointInput` object form (where a 0/0
229
- * input means "no coordinate"), not to a raw scalar distance.
230
- *
231
- * @category Position
232
- */
233
- export function haversineKm(aLat, aLon, bLat, bLon) {
234
- return greatCircle(aLat, aLon, bLat, bLon, "km");
235
- }
236
124
  //# sourceMappingURL=position.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"position.js","sourceRoot":"","sources":["../position.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,QAAQ,EAAsB,MAAM,oBAAoB,CAAA;AAEjE;;GAEG;AACH,MAAM,YAAY,GAAG,CAAC,EAAE,CAAA;AAExB;;GAEG;AACH,MAAM,YAAY,GAAG,EAAE,CAAA;AAEvB;;GAEG;AACH,MAAM,aAAa,GAAG,CAAC,GAAG,CAAA;AAE1B;;GAEG;AACH,MAAM,aAAa,GAAG,GAAG,CAAA;AAEzB;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC5C,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,YAAY,IAAI,KAAK,IAAI,YAAY,CAAA;AAChF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC7C,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,aAAa,IAAI,KAAK,IAAI,aAAa,CAAA;AAClF,CAAC;AAED;;GAEG;AACH,MAAM,iBAAiB,GAAG,CAAC,CAAA;AAE3B;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAA;AA6B7B;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAmB;IAC9E,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;AAC7B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAgB;IAC3E,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;AAC7B,CAAC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C,KAAK,QAAQ,CAAA;AAClE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,SAAiB;IAC9C,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA;AACvD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa;IAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAA;AAC1C,CAAC"}
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Provides functions for parsing and converting extended Well-Known text and binary data.
7
7
  */
8
- import type { GeometryCollection, GeometryLiteral } from "@mailwoman/spatial";
8
+ import type { GeometryCollection, GeometryLiteral } from "#index";
9
9
  /**
10
10
  * Given an extended Well-Known Binary (EWKB) buffer, parse it into a GeoJSON geometry object.
11
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"well-known-text.d.ts","sourceRoot":"","sources":["../../sdk/well-known-text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAG7E;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,GAAG,eAAe,EAAE,uBAAuB,EAAE,MAAM,GAAG,CAAC,CAAA;AACnG;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,GAAG,eAAe,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC,CAAA;AACzF;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,GAAG,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAA;AAM1F;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,GAAG,kBAAkB,2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C,CAAA;AACF,CAAC"}
1
+ {"version":3,"file":"well-known-text.js","sourceRoot":"","sources":["../../sdk/well-known-text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,GAAG,MAAM,KAAK,CAAA;AAuBrB,MAAM,UAAU,0BAA0B,CAAsB,KAAsB;IACrF,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,SAAS,EAAO,CAAA;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,QAA8C;IAC3E,OAAO,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,CAAA;AACnD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,QAA8C;IAC5E,OAAO,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAA;AACpD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,QAA8C;IAC5E,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,QAA8C;IAC3E,OAAO,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,CAAA;AACnD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAiD,QAA8B;IAC3G,OAAO,GAAG,EAAE;QACX,IAAI,CAAC,QAAQ;YAAE,OAAO,MAAM,CAAA;QAE5B,OAAO,SAAS,CAAC,iBAAiB,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAA;IAC/D,CAAC,CAAA;AACF,CAAC"}
@@ -1 +1 @@
1
- {"root":["../bbox.test.ts","../coordinate-formats.test.ts","../osgb36.test.ts","../position.test.ts","../geometries/point.test.ts","../geometries/polygon.test.ts","../google/place-id.test.ts","../h3/cell.test.ts","../sdk/well-known-text.test.ts"],"version":"6.0.3"}
1
+ {"root":["../test/unit/bbox.test.ts","../test/unit/coordinate-formats.test.ts","../test/unit/open-location-code.test.ts","../test/unit/osgb36.test.ts","../test/unit/position.test.ts","../test/unit/geometries/point.test.ts","../test/unit/geometries/polygon.test.ts","../test/unit/google/place-id.test.ts","../test/unit/h3/cell.test.ts","../test/unit/sdk/well-known-text.test.ts"],"version":"6.0.3"}