@mailwoman/spatial 10.0.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/bbox.ts +41 -34
- package/lib/coordinate/bounds.ts +2 -2
- package/lib/coordinate/formats.ts +10 -27
- package/lib/distance.ts +53 -27
- package/lib/feature.ts +2 -2
- package/lib/geometries/point.ts +41 -33
- package/lib/geometries/polygon.ts +24 -128
- package/lib/geometries/ring-blob.ts +33 -130
- package/lib/google/place-id.ts +4 -2
- package/lib/h3/cell.ts +21 -76
- package/lib/h3/coverage.ts +11 -7
- package/lib/h3/interior-cells.ts +13 -34
- package/lib/h3/polygon-cells.ts +59 -165
- package/lib/{h3/index.ts → h3.ts} +1 -1
- package/lib/index.ts +5 -5
- package/lib/objects.ts +6 -6
- package/lib/open-location-code.ts +11 -42
- package/lib/osgb36.ts +28 -187
- package/lib/polyline.ts +5 -3
- package/lib/position.ts +18 -2
- package/lib/projection/transform.ts +39 -40
- package/lib/{projection/index.ts → projection.ts} +1 -1
- package/lib/well-known-text.ts +8 -8
- package/out/bbox.d.ts +17 -14
- package/out/bbox.d.ts.map +1 -1
- package/out/bbox.js +32 -23
- package/out/bbox.js.map +1 -1
- package/out/coordinate/bounds.d.ts +2 -2
- package/out/coordinate/bounds.js +2 -2
- package/out/coordinate/formats.d.ts +8 -11
- package/out/coordinate/formats.d.ts.map +1 -1
- package/out/coordinate/formats.js +10 -27
- package/out/coordinate/formats.js.map +1 -1
- package/out/distance.d.ts +48 -25
- package/out/distance.d.ts.map +1 -1
- package/out/distance.js +53 -27
- package/out/distance.js.map +1 -1
- package/out/feature.d.ts +2 -2
- package/out/feature.d.ts.map +1 -1
- package/out/geometries/point.d.ts +30 -22
- package/out/geometries/point.d.ts.map +1 -1
- package/out/geometries/point.js +35 -29
- package/out/geometries/point.js.map +1 -1
- package/out/geometries/polygon.d.ts +23 -122
- package/out/geometries/polygon.d.ts.map +1 -1
- package/out/geometries/polygon.js +13 -41
- package/out/geometries/polygon.js.map +1 -1
- package/out/geometries/ring-blob.d.ts +23 -109
- package/out/geometries/ring-blob.d.ts.map +1 -1
- package/out/geometries/ring-blob.js +29 -115
- package/out/geometries/ring-blob.js.map +1 -1
- package/out/{geometries/index.js → geometries.d.ts} +1 -1
- package/out/geometries.d.ts.map +1 -0
- package/out/{geometries/index.d.ts → geometries.js} +1 -1
- package/out/geometries.js.map +1 -0
- package/out/google/place-id.d.ts +4 -2
- package/out/google/place-id.d.ts.map +1 -1
- package/out/google/place-id.js.map +1 -1
- package/out/{google/index.d.ts → google.d.ts} +1 -1
- package/out/google.d.ts.map +1 -0
- package/out/{google/index.js → google.js} +1 -1
- package/out/google.js.map +1 -0
- package/out/h3/cell.d.ts +19 -73
- package/out/h3/cell.d.ts.map +1 -1
- package/out/h3/cell.js +20 -63
- package/out/h3/cell.js.map +1 -1
- package/out/h3/coverage.d.ts +11 -7
- package/out/h3/coverage.d.ts.map +1 -1
- package/out/h3/coverage.js +11 -7
- package/out/h3/coverage.js.map +1 -1
- package/out/h3/interior-cells.d.ts +9 -28
- package/out/h3/interior-cells.d.ts.map +1 -1
- package/out/h3/interior-cells.js +13 -32
- package/out/h3/interior-cells.js.map +1 -1
- package/out/h3/polygon-cells.d.ts +28 -120
- package/out/h3/polygon-cells.d.ts.map +1 -1
- package/out/h3/polygon-cells.js +48 -146
- package/out/h3/polygon-cells.js.map +1 -1
- package/out/{h3/index.d.ts → h3.d.ts} +2 -2
- package/out/h3.d.ts.map +1 -0
- package/out/{h3/index.js → h3.js} +2 -2
- package/out/h3.js.map +1 -0
- package/out/index.d.ts +5 -5
- package/out/index.d.ts.map +1 -1
- package/out/index.js +5 -5
- package/out/index.js.map +1 -1
- package/out/objects.d.ts +6 -6
- package/out/open-location-code.d.ts +11 -22
- package/out/open-location-code.d.ts.map +1 -1
- package/out/open-location-code.js +9 -40
- package/out/open-location-code.js.map +1 -1
- package/out/osgb36.d.ts +21 -97
- package/out/osgb36.d.ts.map +1 -1
- package/out/osgb36.js +12 -165
- package/out/osgb36.js.map +1 -1
- package/out/polyline.d.ts +5 -3
- package/out/polyline.d.ts.map +1 -1
- package/out/polyline.js +5 -3
- package/out/polyline.js.map +1 -1
- package/out/position.d.ts +16 -2
- package/out/position.d.ts.map +1 -1
- package/out/position.js.map +1 -1
- package/out/projection/transform.d.ts +30 -27
- package/out/projection/transform.d.ts.map +1 -1
- package/out/projection/transform.js +14 -16
- package/out/projection/transform.js.map +1 -1
- package/out/{projection/index.d.ts → projection.d.ts} +2 -2
- package/out/projection.d.ts.map +1 -0
- package/out/{projection/index.js → projection.js} +2 -2
- package/out/projection.js.map +1 -0
- package/out/{regions/index.js → regions.d.ts} +1 -1
- package/out/regions.d.ts.map +1 -0
- package/out/{regions/index.d.ts → regions.js} +1 -1
- package/out/regions.js.map +1 -0
- package/out/tools/ogr/stream.d.ts +21 -11
- package/out/tools/ogr/stream.d.ts.map +1 -1
- package/out/tools/ogr/stream.js +16 -9
- package/out/tools/ogr/stream.js.map +1 -1
- package/out/tools/{ogr/index.d.ts → ogr.d.ts} +14 -11
- package/out/tools/ogr.d.ts.map +1 -0
- package/out/tools/{ogr/index.js → ogr.js} +18 -14
- package/out/tools/ogr.js.map +1 -0
- package/out/tools/tsconfig.tsbuildinfo +1 -0
- package/out/tsconfig.test.tsbuildinfo +1 -1
- package/out/well-known-text.d.ts +8 -8
- package/out/well-known-text.js +7 -7
- package/package.json +35 -127
- package/{lib/tools → tools}/ogr/stream.ts +25 -14
- package/{lib/tools/ogr/index.ts → tools/ogr.ts} +25 -19
- package/out/geometries/index.d.ts.map +0 -1
- package/out/geometries/index.js.map +0 -1
- package/out/google/index.d.ts.map +0 -1
- package/out/google/index.js.map +0 -1
- package/out/h3/index.d.ts.map +0 -1
- package/out/h3/index.js.map +0 -1
- package/out/projection/index.d.ts.map +0 -1
- package/out/projection/index.js.map +0 -1
- package/out/regions/index.d.ts.map +0 -1
- package/out/regions/index.js.map +0 -1
- package/out/tools/ogr/index.d.ts.map +0 -1
- package/out/tools/ogr/index.js.map +0 -1
- /package/lib/{geometries/index.ts → geometries.ts} +0 -0
- /package/lib/{google/index.ts → google.ts} +0 -0
- /package/lib/{regions/index.ts → regions.ts} +0 -0
package/out/distance.js
CHANGED
|
@@ -27,8 +27,12 @@ const RADII = {
|
|
|
27
27
|
meters: 6_371_000,
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
* Mean radii in
|
|
31
|
-
*
|
|
30
|
+
* Mean radii in kilometers.
|
|
31
|
+
*
|
|
32
|
+
* Earth's is the value `radii` scales to its units.
|
|
33
|
+
* The Moon's and Mars's are the IAU mean radii the usgs planetary products reference
|
|
34
|
+
* (the Moon as a sphere. Mars's mean radius, its DEM being on the areoid).
|
|
35
|
+
*
|
|
32
36
|
* A distance on a body other than Earth is meaningless without one of these.
|
|
33
37
|
*/
|
|
34
38
|
export const BODY_RADII_KM = {
|
|
@@ -37,7 +41,9 @@ export const BODY_RADII_KM = {
|
|
|
37
41
|
mars: 3389.5,
|
|
38
42
|
};
|
|
39
43
|
/**
|
|
40
|
-
* Shared great-circle math with no sentinel handling.
|
|
44
|
+
* Shared great-circle math with no sentinel handling.
|
|
45
|
+
*
|
|
46
|
+
* `unit` selects the Earth radius.
|
|
41
47
|
*/
|
|
42
48
|
function greatCircle(lat1, lon1, lat2, lon2, unit) {
|
|
43
49
|
const dLat = (lat2 - lat1) * ConversionFactor.DegreesToRadians;
|
|
@@ -66,8 +72,10 @@ export function haversine(point1, point2, unit = "km") {
|
|
|
66
72
|
return greatCircle(p1.latitude, p1.longitude, p2.latitude, p2.longitude, unit);
|
|
67
73
|
}
|
|
68
74
|
/**
|
|
69
|
-
* Great-circle distance on the
|
|
70
|
-
*
|
|
75
|
+
* Great-circle distance on the selected body. {@link haversine} is this function on Earth.
|
|
76
|
+
* A caller with a body passes it here.
|
|
77
|
+
*
|
|
78
|
+
* The Null-Island sentinel of the object form applies: a `(0, 0)` input answers `NaN`.
|
|
71
79
|
*
|
|
72
80
|
* @category Position
|
|
73
81
|
*/
|
|
@@ -78,12 +86,15 @@ export function greatCircleDistance(point1, point2, options = {}) {
|
|
|
78
86
|
return haversine(point1, point2, unit) * scale;
|
|
79
87
|
}
|
|
80
88
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
89
|
+
* Returns the great-circle distance in kilometers between two coordinates on Earth.
|
|
90
|
+
*
|
|
91
|
+
* The formula's one true home — every resolver + eval consumer of the
|
|
92
|
+
* `(aLat, aLon, bLat, bLon)` shape imports this instead of re-declaring it.
|
|
83
93
|
*
|
|
84
|
-
* Unlike {@link haversine}, this is pure math with
|
|
85
|
-
*
|
|
86
|
-
*
|
|
94
|
+
* Unlike {@link haversine}, this is pure math with no Null-Island sentinel:
|
|
95
|
+
* `(0, 0)` is the Gulf of Guinea — a real point rather than "missing coordinate".
|
|
96
|
+
* That sentinel convention belongs to the `GeoPointInput` object form
|
|
97
|
+
* (where a 0/0 input means "no coordinate"), not to a raw scalar distance.
|
|
87
98
|
*
|
|
88
99
|
* @category Position
|
|
89
100
|
*/
|
|
@@ -91,24 +102,35 @@ export function haversineKm(aLat, aLon, bLat, bLon) {
|
|
|
91
102
|
return greatCircle(aLat, aLon, bLat, bLon, "km");
|
|
92
103
|
}
|
|
93
104
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
105
|
+
* Meters per degree of latitude.
|
|
106
|
+
*
|
|
107
|
+
* The scale used by {@link segmentDistanceMetres}.
|
|
108
|
+
* It is also the constant the bounding-box estimates in `#h3/polygon-cells` are built on.
|
|
96
109
|
*/
|
|
97
110
|
export const METRES_PER_DEGREE = 111_320;
|
|
98
111
|
/**
|
|
99
|
-
* Square
|
|
112
|
+
* Square meters in a square kilometer.
|
|
113
|
+
*
|
|
114
|
+
* The conversion every polygon layer's area receipt reports through.
|
|
100
115
|
*/
|
|
101
116
|
export const M2_PER_KM2 = 1_000_000;
|
|
102
117
|
/**
|
|
103
|
-
*
|
|
118
|
+
* Meters from a point to a line segment, with longitude scaled for the latitude
|
|
119
|
+
* so the two axes are comparable.
|
|
120
|
+
*
|
|
121
|
+
* Measure TO the edge rather than TO the nearest vertex.
|
|
122
|
+
* A point a centimeter from a long edge can be meters from every vertex of it,
|
|
123
|
+
* so a vertex distance overstates the gap without bound.
|
|
124
|
+
*
|
|
125
|
+
* Measured on the flood layer's verification, one near-miss read 1.58 m to vertices
|
|
126
|
+
* and 0.009 m to edges, a 9 mm difference overstated 175-fold.
|
|
104
127
|
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* near-miss read 1.58 m to vertices and 0.009 m to edges, a 9 mm difference overstated 175-fold. That is the difference
|
|
108
|
-
* between "two channels rendered the same edge slightly differently" and "the conversion is wrong".
|
|
128
|
+
* That is the difference between "two channels rendered the same edge slightly
|
|
129
|
+
* differently" and "the conversion is wrong".
|
|
109
130
|
*
|
|
110
|
-
* The longitude scaling matters at the same scale: comparing raw degrees treats
|
|
111
|
-
*
|
|
131
|
+
* The longitude scaling matters at the same scale: comparing raw degrees treats
|
|
132
|
+
* a degree of longitude as a degree of latitude.
|
|
133
|
+
* At 54°N, this overstates east-west distance by 70%.
|
|
112
134
|
*
|
|
113
135
|
* @category Position
|
|
114
136
|
*/
|
|
@@ -119,18 +141,22 @@ export function segmentDistanceMetres(lon, lat, from, to) {
|
|
|
119
141
|
const vx = (to[0] - from[0]) * scale;
|
|
120
142
|
const vy = to[1] - from[1];
|
|
121
143
|
const lengthSquared = vx * vx + vy * vy;
|
|
122
|
-
// A zero-length segment is a repeated vertex
|
|
144
|
+
// A zero-length segment is a repeated vertex.
|
|
145
|
+
// The distance to it is the distance to the point.
|
|
123
146
|
const t = lengthSquared === 0 ? 0 : Math.max(0, Math.min(1, (px * vx + py * vy) / lengthSquared));
|
|
124
147
|
return Math.hypot(px - t * vx, py - t * vy) * METRES_PER_DEGREE;
|
|
125
148
|
}
|
|
126
149
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
150
|
+
* Meters from a point to the nearest ring edge of an areal geometry.
|
|
151
|
+
*
|
|
152
|
+
* `Infinity` when the geometry bounds no area or contains no segment.
|
|
153
|
+
*
|
|
154
|
+
* To the edge rather than to the nearest vertex: a point a centimeter from a long edge can
|
|
155
|
+
* be meters from every vertex of it, so a vertex distance overstates the gap without bound.
|
|
156
|
+
* Measured on the flood layer's verification, one near-miss read 1.58 m to vertices
|
|
157
|
+
* and 0.009 m to edges, a 9 mm difference overstated 175-fold.
|
|
129
158
|
*
|
|
130
|
-
*
|
|
131
|
-
* so a vertex distance overstates the gap without bound — measured on the flood layer's verification, one near-miss
|
|
132
|
-
* read 1.58 m to vertices and 0.009 m to edges, a 9 mm difference overstated 175-fold. Every polygon layer's two-path
|
|
133
|
-
* verification measures its boundary tolerance with this.
|
|
159
|
+
* Every polygon layer's two-path verification measures its boundary tolerance with this.
|
|
134
160
|
*
|
|
135
161
|
* @category Position
|
|
136
162
|
*/
|
package/out/distance.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distance.js","sourceRoot":"","sources":["../lib/distance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAsB,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,gBAAgB,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG;IAC/B,gBAAgB,EAAE,GAAG,GAAG,IAAI,CAAC,EAAE;CACtB,CAAA;AAOV;;GAEG;AACH,MAAM,KAAK,GAAG;IACb,EAAE,EAAE,IAAI;IACR,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,SAAS;CACkC,CAAA;AAIpD
|
|
1
|
+
{"version":3,"file":"distance.js","sourceRoot":"","sources":["../lib/distance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE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QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;IAExC,IAAI,OAAO,GAAG,QAAQ,CAAA;IAEtB,IAAI,CAAC,QAAQ;QAAE,OAAO,OAAO,CAAA;IAE7B,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;QAC9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;gBAClD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAE,EAAE,IAAI,CAAC,KAAK,CAAE,CAAC,CAAA;gBAE3F,IAAI,QAAQ,GAAG,OAAO,EAAE,CAAC;oBACxB,OAAO,GAAG,QAAQ,CAAA;gBACnB,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,OAAO,CAAA;AACf,CAAC"}
|
package/out/feature.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*/
|
|
6
|
-
import type { GeometryLiteral } from "#geometries
|
|
6
|
+
import type { GeometryLiteral } from "#geometries";
|
|
7
7
|
export interface IdentifiableGeoFeature {
|
|
8
8
|
GEOID: string | number;
|
|
9
9
|
}
|
|
@@ -24,7 +24,7 @@ export interface GeoFeature<G = GeometryLiteral, P extends object | null = never
|
|
|
24
24
|
*/
|
|
25
25
|
geometry: G;
|
|
26
26
|
/**
|
|
27
|
-
* A unique identifier for the feature, such as a
|
|
27
|
+
* A unique identifier for the feature, such as a uuid, a serial number, or a name.
|
|
28
28
|
*/
|
|
29
29
|
id?: P extends IdentifiableGeoFeature ? P["GEOID"] : never;
|
|
30
30
|
/**
|
package/out/feature.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../lib/feature.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../lib/feature.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,MAAM,WAAW,sBAAsB;IACtC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,eAAe,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,KAAK;IAC/E;;OAEG;IACH,IAAI,EAAE,SAAS,CAAA;IACf;;;;OAIG;IACH,QAAQ,EAAE,CAAC,CAAA;IAEX;;OAEG;IACH,EAAE,CAAC,EAAE,CAAC,SAAS,sBAAsB,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,KAAK,CAAA;IAE1D;;OAEG;IACH,UAAU,EAAE,CAAC,CAAA;CACb;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAEnF;;GAEG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAErF;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,eAAe,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACpH;;OAEG;IACH,IAAI,EAAE,mBAAmB,CAAA;IAEzB;;OAEG;IACH,QAAQ,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;CAC5B;AAED;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,CAAC,CAAC,IACtC,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GACnC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC1B,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,GACvC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC1B,KAAK,CAAA;AAEV;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAAC,SAAS,oBAAoB,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAE5F;;GAEG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,UAAU,IAAI,oBAAoB,CAC/E,mBAAmB,CAAC,CAAC,CAAC,EACtB,qBAAqB,CAAC,CAAC,CAAC,CACxB,CAAA"}
|
|
@@ -10,7 +10,8 @@ import { type H3Cell } from "#h3/cell";
|
|
|
10
10
|
import { type GeoObjectLiteral } from "#objects";
|
|
11
11
|
import { type InternalPointCoordinates, type Coordinates2D as Point2DCoordinates, type Coordinates3D as Point3DCoordinates } from "#position";
|
|
12
12
|
/**
|
|
13
|
-
* A JSON-
|
|
13
|
+
* A JSON-serializable single point geometry, such as a specific location,
|
|
14
|
+
* address, or longitude, latitude pair.
|
|
14
15
|
*
|
|
15
16
|
* ```js
|
|
16
17
|
* {
|
|
@@ -49,8 +50,8 @@ export interface GeolocationCoordinatesLike {
|
|
|
49
50
|
altitude: number;
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
52
|
-
* Type-predicate to determine if the given input appears to be a {@linkcode GeolocationCoordinatesLike}
|
|
53
|
-
* shape the browser's `GeolocationCoordinates` presents, without depending on the DOM type.
|
|
53
|
+
* Type-predicate to determine if the given input appears to be a {@linkcode GeolocationCoordinatesLike}
|
|
54
|
+
* object — the shape the browser's `GeolocationCoordinates` presents, without depending on the DOM type.
|
|
54
55
|
*/
|
|
55
56
|
export declare function isGeolocationCoordinatesLike(input: unknown): input is GeolocationCoordinatesLike;
|
|
56
57
|
export type GeoPointInput = PointLiteral | Point2DCoordinates | Point3DCoordinates | GeolocationCoordinatesLike | InternalPointCoordinates | LatLngLiteral | LatLng;
|
|
@@ -81,9 +82,10 @@ export declare class GeoPoint implements PointLiteral {
|
|
|
81
82
|
set bbox(bbox: BBox2DLiteral | BBox3DLiteral | undefined);
|
|
82
83
|
get coordinates(): Point2DCoordinates | Point3DCoordinates;
|
|
83
84
|
/**
|
|
84
|
-
* Assigns the pair as GeoJSON [longitude, latitude(, altitude)] — the axis order is the
|
|
85
|
-
* the magnitudes — and
|
|
86
|
-
*
|
|
85
|
+
* Assigns the pair as GeoJSON [longitude, latitude(, altitude)] — the axis order is the interface,
|
|
86
|
+
* never inferred from the magnitudes — and rejects a coordinate that is not on the globe.
|
|
87
|
+
*
|
|
88
|
+
* See {@link GeoPoint.from} for why both halves of that sentence are required.
|
|
87
89
|
*
|
|
88
90
|
* @throws {RangeError} When longitude is outside [-180, 180] or latitude is outside [-90, 90].
|
|
89
91
|
*/
|
|
@@ -130,7 +132,8 @@ export declare class GeoPoint implements PointLiteral {
|
|
|
130
132
|
*/
|
|
131
133
|
constructor(geoLocationCoordinates: GeolocationCoordinatesLike, bbox?: BBox2DLiteral | BBox3DLiteral | GeoBoundingBox);
|
|
132
134
|
/**
|
|
133
|
-
* Creates a new GeoPoint instance from a Google Maps API
|
|
135
|
+
* Creates a new GeoPoint instance from a Google Maps API
|
|
136
|
+
* {@linkcode google.LatLngLiteral | LatLngLiteral} object.
|
|
134
137
|
*/
|
|
135
138
|
constructor(latLngLiteral: google.LatLngLiteral, bbox?: BBox2DLiteral | BBox3DLiteral | GeoBoundingBox);
|
|
136
139
|
/**
|
|
@@ -150,23 +153,28 @@ export declare class GeoPoint implements PointLiteral {
|
|
|
150
153
|
*/
|
|
151
154
|
constructor(input: GeoPointInput, bbox?: BBox2DLiteral | BBox3DLiteral | GeoBoundingBox);
|
|
152
155
|
/**
|
|
153
|
-
* Attempts to create a new GeoPoint instance from the given input, returning `null`
|
|
154
|
-
* input is not a coordinate this class will stand behind.
|
|
156
|
+
* Attempts to create a new GeoPoint instance from the given input, returning `null`
|
|
157
|
+
* rather than throwing when the input is not a coordinate this class will stand behind.
|
|
155
158
|
*
|
|
156
|
-
* Two rules, both of which this constructor got wrong until 2026-08-05
|
|
157
|
-
* routed around rather than fixed):
|
|
159
|
+
* Two rules, both of which this constructor got wrong until 2026-08-05
|
|
160
|
+
* (the defect was recorded in `e9bfd139` and routed around rather than fixed):
|
|
158
161
|
*
|
|
159
|
-
* 1. **A 2-tuple is GeoJSON [longitude, latitude].
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
162
|
+
* 1. **A 2-tuple is GeoJSON [longitude, latitude].
|
|
163
|
+
* The axis order is never inferred.** The old path ran the pair through
|
|
164
|
+
* `inferGeoJSONCoordOrder`, whose only signal is the [-90, 90] latitude range,
|
|
165
|
+
* so it transposed a pair exactly when |the second magnitude| > 90.
|
|
166
|
+
* A caller handing it `[latitude, longitude]` therefore got the pair repaired in Dallas
|
|
167
|
+
* and left corrupted in Berlin — behavior selected by the data, from one code path.
|
|
168
|
+
* This change is a no-op for every well-formed input: a valid `[longitude, latitude]` pair
|
|
169
|
+
* can never have an out-of-range second element, so the heuristic never fired on one.
|
|
170
|
+
* 2. **An out-of-range magnitude is rejected rather than repaired.** `[999, 999]`
|
|
171
|
+
* used to produce a GeoPoint reporting latitude 999.
|
|
172
|
+
* It now returns `null` here and throws a `RangeError` from the constructor.
|
|
173
|
+
* Note the deliberate asymmetry with the scalar `longitude` / `latitude` setters.
|
|
174
|
+
* which still wrap and clamp: mutating a point is a pan gesture, where 190°.
|
|
175
|
+
* This means -170° is right.
|
|
176
|
+
* A parse result is a claim about the world.
|
|
177
|
+
* An impossible magnitude means the input was malformed and any repair invents a location.
|
|
170
178
|
*
|
|
171
179
|
* A 0/0 result is treated as the "missing coordinate" sentinel (Null Island) and also returns `null`.
|
|
172
180
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../lib/geometries/point.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AAKhF,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,cAAc,EAAU,MAAM,OAAO,CAAA;AACtF,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,KAAK,gBAAgB,EAAgB,MAAM,UAAU,CAAA;AAC9D,OAAO,EACN,KAAK,wBAAwB,EAC7B,KAAK,aAAa,IAAI,kBAAkB,EACxC,KAAK,aAAa,IAAI,kBAAkB,EAQxC,MAAM,WAAW,CAAA;AAElB
|
|
1
|
+
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../lib/geometries/point.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AAKhF,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,cAAc,EAAU,MAAM,OAAO,CAAA;AACtF,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,KAAK,gBAAgB,EAAgB,MAAM,UAAU,CAAA;AAC9D,OAAO,EACN,KAAK,wBAAwB,EAC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I,YAAY,IAAI,OAAO,CAE7B;IAMM,MAAM,IAAI,YAAY,CAK5B;IAEM,eAAe,IAAI,kBAAkB,CAE3C;IAEM,eAAe,IAAI,kBAAkB,CAE3C;IAED;;OAEG;IACI,qBAAqB,IAAI,MAAM,CAAC,aAAa,CAKnD;IAED;;OAEG;IACI,KAAK,IAAI,MAAM,CAIrB;IAED;;OAEG;IACI,QAAQ,CAAC,UAAU,SAAK,UAI9B;IAED;;OAEG;IACI,aAAa,CAAC,UAAU,SAAK,kCAInC;IAEM,QAAQ,IAAI,MAAM,CAExB;IAGM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAE3C;CACD;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,kBAAkB,GAAG,kBAAkB,CAAC,CAAC,CAAA;AAExF;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IAC1D;;OAEG;IACH,IAAI,EAAE,YAAY,CAAA;IAClB;;;;OAIG;IACH,WAAW,EAAE,cAAc,CAAA;CAC3B"}
|
package/out/geometries/point.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*/
|
|
6
|
-
import { tryParsingJSON } from "@mailwoman/core/json";
|
|
6
|
+
import { tryParsingJSON, stringifyJSON } from "@mailwoman/core/json";
|
|
7
7
|
import { convert as convertCoords } from "geo-coordinates-parser";
|
|
8
8
|
import { latLngToCell } from "h3-js";
|
|
9
9
|
import { GeoBoundingBox, isBBox } from "#bbox";
|
|
@@ -25,8 +25,8 @@ export function isPointLiteral(input) {
|
|
|
25
25
|
return isCoordPairLiteral(input.coordinates);
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Type-predicate to determine if the given input appears to be a {@linkcode GeolocationCoordinatesLike}
|
|
29
|
-
* shape the browser's `GeolocationCoordinates` presents, without depending on the DOM type.
|
|
28
|
+
* Type-predicate to determine if the given input appears to be a {@linkcode GeolocationCoordinatesLike}
|
|
29
|
+
* object — the shape the browser's `GeolocationCoordinates` presents, without depending on the DOM type.
|
|
30
30
|
*/
|
|
31
31
|
export function isGeolocationCoordinatesLike(input) {
|
|
32
32
|
if (!input || typeof input !== "object")
|
|
@@ -39,12 +39,12 @@ export function isGeolocationCoordinatesLike(input) {
|
|
|
39
39
|
return false;
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
// #region GeoPoint
|
|
43
43
|
/**
|
|
44
44
|
* A single point geometry, such as a specific location, address, or longitude, latitude pair.
|
|
45
45
|
*/
|
|
46
46
|
export class GeoPoint {
|
|
47
|
-
|
|
47
|
+
// #region Properties
|
|
48
48
|
/**
|
|
49
49
|
* Declares the type of GeoJSON object as a `Point` geometry.
|
|
50
50
|
*/
|
|
@@ -76,9 +76,10 @@ export class GeoPoint {
|
|
|
76
76
|
return [this.#longitude, this.#latitude];
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
-
* Assigns the pair as GeoJSON [longitude, latitude(, altitude)] — the axis order is the
|
|
80
|
-
* the magnitudes — and
|
|
81
|
-
*
|
|
79
|
+
* Assigns the pair as GeoJSON [longitude, latitude(, altitude)] — the axis order is the interface,
|
|
80
|
+
* never inferred from the magnitudes — and rejects a coordinate that is not on the globe.
|
|
81
|
+
*
|
|
82
|
+
* See {@link GeoPoint.from} for why both halves of that sentence are required.
|
|
82
83
|
*
|
|
83
84
|
* @throws {RangeError} When longitude is outside [-180, 180] or latitude is outside [-90, 90].
|
|
84
85
|
*/
|
|
@@ -160,23 +161,28 @@ export class GeoPoint {
|
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
/**
|
|
163
|
-
* Attempts to create a new GeoPoint instance from the given input, returning `null`
|
|
164
|
-
* input is not a coordinate this class will stand behind.
|
|
164
|
+
* Attempts to create a new GeoPoint instance from the given input, returning `null`
|
|
165
|
+
* rather than throwing when the input is not a coordinate this class will stand behind.
|
|
165
166
|
*
|
|
166
|
-
* Two rules, both of which this constructor got wrong until 2026-08-05
|
|
167
|
-
* routed around rather than fixed):
|
|
167
|
+
* Two rules, both of which this constructor got wrong until 2026-08-05
|
|
168
|
+
* (the defect was recorded in `e9bfd139` and routed around rather than fixed):
|
|
168
169
|
*
|
|
169
|
-
* 1. **A 2-tuple is GeoJSON [longitude, latitude].
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
170
|
+
* 1. **A 2-tuple is GeoJSON [longitude, latitude].
|
|
171
|
+
* The axis order is never inferred.** The old path ran the pair through
|
|
172
|
+
* `inferGeoJSONCoordOrder`, whose only signal is the [-90, 90] latitude range,
|
|
173
|
+
* so it transposed a pair exactly when |the second magnitude| > 90.
|
|
174
|
+
* A caller handing it `[latitude, longitude]` therefore got the pair repaired in Dallas
|
|
175
|
+
* and left corrupted in Berlin — behavior selected by the data, from one code path.
|
|
176
|
+
* This change is a no-op for every well-formed input: a valid `[longitude, latitude]` pair
|
|
177
|
+
* can never have an out-of-range second element, so the heuristic never fired on one.
|
|
178
|
+
* 2. **An out-of-range magnitude is rejected rather than repaired.** `[999, 999]`
|
|
179
|
+
* used to produce a GeoPoint reporting latitude 999.
|
|
180
|
+
* It now returns `null` here and throws a `RangeError` from the constructor.
|
|
181
|
+
* Note the deliberate asymmetry with the scalar `longitude` / `latitude` setters.
|
|
182
|
+
* which still wrap and clamp: mutating a point is a pan gesture, where 190°.
|
|
183
|
+
* This means -170° is right.
|
|
184
|
+
* A parse result is a claim about the world.
|
|
185
|
+
* An impossible magnitude means the input was malformed and any repair invents a location.
|
|
180
186
|
*
|
|
181
187
|
* A 0/0 result is treated as the "missing coordinate" sentinel (Null Island) and also returns `null`.
|
|
182
188
|
*/
|
|
@@ -201,8 +207,8 @@ export class GeoPoint {
|
|
|
201
207
|
return null;
|
|
202
208
|
}
|
|
203
209
|
}
|
|
204
|
-
|
|
205
|
-
|
|
210
|
+
// #endregion
|
|
211
|
+
// #region Predicates
|
|
206
212
|
/**
|
|
207
213
|
* Whether the GeoPoint is 2-dimensional.
|
|
208
214
|
*/
|
|
@@ -221,8 +227,8 @@ export class GeoPoint {
|
|
|
221
227
|
isNullIsland() {
|
|
222
228
|
return this.#latitude === 0 && this.#longitude === 0;
|
|
223
229
|
}
|
|
224
|
-
|
|
225
|
-
|
|
230
|
+
// #endregion
|
|
231
|
+
// #region Conversion
|
|
226
232
|
toJSON() {
|
|
227
233
|
return {
|
|
228
234
|
type: this.type,
|
|
@@ -266,9 +272,9 @@ export class GeoPoint {
|
|
|
266
272
|
return shortenH3Cell(cell);
|
|
267
273
|
}
|
|
268
274
|
toString() {
|
|
269
|
-
return
|
|
275
|
+
return stringifyJSON(this.toJSON());
|
|
270
276
|
}
|
|
271
|
-
|
|
277
|
+
// #endregion
|
|
272
278
|
[Symbol.iterator]() {
|
|
273
279
|
return this.coordinates[Symbol.iterator]();
|
|
274
280
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.js","sourceRoot":"","sources":["../../lib/geometries/point.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"point.js","sourceRoot":"","sources":["../../lib/geometries/point.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,OAAO,EAA0C,cAAc,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACtF,OAAO,EAA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