@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
|
@@ -8,94 +8,33 @@ import type { LineStringPath } from "#geometries/line-string";
|
|
|
8
8
|
import type { GeoObjectLiteral } from "#objects";
|
|
9
9
|
/**
|
|
10
10
|
* An array of positions forming a closed shape, such as a country or a lake.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* A polygon without holes:
|
|
14
|
-
*
|
|
15
|
-
* ```json
|
|
16
|
-
* {
|
|
17
|
-
* "type": "Polygon",
|
|
18
|
-
* "coordinates": [
|
|
19
|
-
* [
|
|
20
|
-
* [100, 0],
|
|
21
|
-
* [101, 0],
|
|
22
|
-
* [101, 1],
|
|
23
|
-
* [100, 1],
|
|
24
|
-
* [100, 0]
|
|
25
|
-
* ]
|
|
26
|
-
* ]
|
|
27
|
-
* }
|
|
28
|
-
* ```
|
|
29
11
|
*/
|
|
30
12
|
export type SolidPolygonPath = [
|
|
31
13
|
/**
|
|
32
|
-
*
|
|
33
|
-
* - The first and last positions are equivalent (they represent equivalent points).
|
|
14
|
+
* A linear ring is a closed LineString with four or more positions.
|
|
34
15
|
*/
|
|
35
16
|
exteriorRing: LineStringPath
|
|
36
17
|
];
|
|
37
18
|
/**
|
|
38
|
-
* An array of positions forming a closed shape with holes, such as a country
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* A polygon with holes:
|
|
42
|
-
*
|
|
43
|
-
* ```json
|
|
44
|
-
* {
|
|
45
|
-
* "type": "Polygon",
|
|
46
|
-
* "coordinates": [
|
|
47
|
-
* [
|
|
48
|
-
* [100.0, 0.0],
|
|
49
|
-
* [101.0, 0.0],
|
|
50
|
-
* [101.0, 1.0],
|
|
51
|
-
* [100.0, 1.0],
|
|
52
|
-
* [100.0, 0.0]
|
|
53
|
-
* ],
|
|
54
|
-
* [
|
|
55
|
-
* [100.8, 0.8],
|
|
56
|
-
* [100.8, 0.2],
|
|
57
|
-
* [100.2, 0.2],
|
|
58
|
-
* [100.2, 0.8],
|
|
59
|
-
* [100.8, 0.8]
|
|
60
|
-
* ]
|
|
61
|
-
* ]
|
|
62
|
-
* }
|
|
63
|
-
* ```
|
|
19
|
+
* An array of positions forming a closed shape with holes, such as a country
|
|
20
|
+
* with islands or a lake with islands.
|
|
64
21
|
*/
|
|
65
22
|
export type NestedPolygonPath = [
|
|
66
23
|
/**
|
|
67
|
-
*
|
|
68
|
-
* - The first and last positions are equivalent (they represent equivalent points).
|
|
24
|
+
* A linear ring is a closed LineString with four or more positions.
|
|
69
25
|
*/
|
|
70
26
|
exteriorRing: LineStringPath,
|
|
71
|
-
/**
|
|
72
|
-
* - The interior rings are arrays of positions forming holes in the polygon.
|
|
73
|
-
*/
|
|
74
27
|
...interiorRings: LineStringPath[]
|
|
75
28
|
];
|
|
76
29
|
/**
|
|
77
30
|
* A polygon geometry.
|
|
78
|
-
*
|
|
79
|
-
* @see {@linkcode PolygonLiteral} for applicable JSON schema.
|
|
80
|
-
* @see {@linkcode SolidPolygonPath} for more information.
|
|
81
|
-
* @see {@linkcode NestedPolygonPath} for more information.
|
|
82
31
|
*/
|
|
83
32
|
export type PolygonPath = SolidPolygonPath | NestedPolygonPath;
|
|
84
33
|
/**
|
|
85
34
|
* An array of positions forming a closed shape, such as a country or a lake.
|
|
86
35
|
*/
|
|
87
36
|
export interface PolygonLiteral<P extends PolygonPath = PolygonPath> extends GeoObjectLiteral {
|
|
88
|
-
/**
|
|
89
|
-
* Declares the type of GeoJSON object as a `Polygon` geometry.
|
|
90
|
-
*/
|
|
91
37
|
type: "Polygon";
|
|
92
|
-
/**
|
|
93
|
-
* An array of positions for each point in the geometry.
|
|
94
|
-
*
|
|
95
|
-
* @see {@link https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6 | RFC 7946 Section 3.1.6}
|
|
96
|
-
* @see {@linkcode SolidPolygonPath}
|
|
97
|
-
* @see {@linkcode NestedPolygonPath}
|
|
98
|
-
*/
|
|
99
38
|
coordinates: P;
|
|
100
39
|
}
|
|
101
40
|
/**
|
|
@@ -107,42 +46,31 @@ export declare function isPolygonLiteral<P extends PolygonPath = PolygonPath>(in
|
|
|
107
46
|
*/
|
|
108
47
|
export declare function isSolidPolygonPath(input: PolygonLiteral<PolygonPath>): boolean;
|
|
109
48
|
/**
|
|
110
|
-
* A linear ring as the containment predicates read it
|
|
111
|
-
*
|
|
112
|
-
* Deliberately looser than {@link LineStringPath} — the ray cast only ever indexes `[0]` and `[1]`, and the callers
|
|
113
|
-
* arrive with different position types (`[number, number, ...number[]]` from the resolver's GeoJSON reader, plain
|
|
114
|
-
* `number[][]` from a `JSON.parse` of a stored geometry column). A tight tuple type here would force a cast at every
|
|
115
|
-
* call site and buy nothing the predicate uses.
|
|
49
|
+
* A linear ring as the containment predicates read it, deliberately looser than
|
|
50
|
+
* {@link LineStringPath} because callers arrive with different position types.
|
|
116
51
|
*/
|
|
117
52
|
export type ContainmentRing = readonly (readonly number[])[];
|
|
118
53
|
/**
|
|
119
|
-
* One polygon's rings: `[exterior, ...holes]
|
|
120
|
-
* {@linkcode ContainmentRing}).
|
|
54
|
+
* One polygon's rings: `[exterior, ...holes]`.
|
|
121
55
|
*/
|
|
122
56
|
export type PolygonRings = readonly ContainmentRing[];
|
|
123
57
|
/**
|
|
124
|
-
* A feature's polygons — `MultiPolygon` coordinates, with a bare `Polygon` lifted
|
|
125
|
-
* {@linkcode arealPolygons}.
|
|
58
|
+
* A feature's polygons — `MultiPolygon` coordinates, with a bare `Polygon` lifted
|
|
59
|
+
* into the same shape by {@linkcode arealPolygons}.
|
|
126
60
|
*/
|
|
127
61
|
export type MultiPolygonRings = readonly PolygonRings[];
|
|
128
62
|
/**
|
|
129
|
-
* Ray-cast a point against
|
|
130
|
-
* edge
|
|
131
|
-
*
|
|
132
|
-
* Points exactly on an edge are implementation-defined; either side is acceptable for geocoding, where admin boundaries
|
|
133
|
-
* are Douglas-Peucker–simplified before they ever reach us.
|
|
63
|
+
* Ray-cast a point against one linear ring — the even-odd crossing count,
|
|
64
|
+
* with points exactly on an edge left implementation-defined.
|
|
134
65
|
*/
|
|
135
66
|
export declare function pointInRing(lon: number, lat: number, ring: ContainmentRing): boolean;
|
|
136
67
|
/**
|
|
137
|
-
* Even-odd containment over a polygon's ring list (`[outer, hole₁, …]`)
|
|
138
|
-
*
|
|
139
|
-
* Being inside an odd number of rings means inside the polygon, which handles holes — and islands inside holes —
|
|
140
|
-
* without depending on ring winding order. GeoJSON nominally specifies orientation, but the gazetteer sources do not
|
|
141
|
-
* reliably honour it, so the orientation-free rule is the one that survives real data.
|
|
68
|
+
* Even-odd containment over a polygon's ring list (`[outer, hole₁, …]`), independent of
|
|
69
|
+
* ring winding order because the gazetteer sources do not honor it reliably.
|
|
142
70
|
*/
|
|
143
71
|
export declare function pointInPolygon(lon: number, lat: number, rings: PolygonRings): boolean;
|
|
144
72
|
/**
|
|
145
|
-
* Inside
|
|
73
|
+
* Inside any polygon of a multi-polygon.
|
|
146
74
|
*/
|
|
147
75
|
export declare function pointInMultiPolygon(lon: number, lat: number, polygons: readonly (readonly ContainmentRing[])[]): boolean;
|
|
148
76
|
/**
|
|
@@ -150,60 +78,33 @@ export declare function pointInMultiPolygon(lon: number, lat: number, polygons:
|
|
|
150
78
|
*/
|
|
151
79
|
export interface MultiPolygonLiteral<P extends PolygonPath = PolygonPath> extends GeoObjectLiteral {
|
|
152
80
|
type: "MultiPolygon";
|
|
153
|
-
/**
|
|
154
|
-
* One ring array per polygon — `coordinates[polygon][ring][position]`, matching a `Polygon`'s `coordinates` lifted by
|
|
155
|
-
* exactly one level.
|
|
156
|
-
*
|
|
157
|
-
* @see {@link https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.7 | RFC 7946 Section 3.1.7}
|
|
158
|
-
*/
|
|
159
81
|
coordinates: P[];
|
|
160
82
|
}
|
|
161
83
|
/**
|
|
162
|
-
* A geometry as it arrives from `JSON.parse`, or a typed literal
|
|
163
|
-
*
|
|
164
|
-
* is the one place that happens for the areal types.
|
|
84
|
+
* A geometry as it arrives from `JSON.parse`, or a typed literal, with `type` unchecked
|
|
85
|
+
* and no arity validation on `coordinates`.
|
|
165
86
|
*/
|
|
166
87
|
export type ParsedGeometry = GeometryLiteral | {
|
|
167
88
|
type: string;
|
|
168
89
|
coordinates?: unknown;
|
|
169
90
|
};
|
|
170
91
|
/**
|
|
171
|
-
* A geometry's polygons in the `MultiPolygon` coordinate shape,
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
* The one place a `Polygon` is lifted to `[rings]`; a caller that must refuse a non-areal geometry does so on the
|
|
175
|
-
* `null`, with its own message.
|
|
92
|
+
* A geometry's polygons in the `MultiPolygon` coordinate shape, with a bare `Polygon`
|
|
93
|
+
* lifted to `[rings]` and `null` for any non-areal geometry.
|
|
176
94
|
*/
|
|
177
95
|
export declare function arealPolygons(geometry: ParsedGeometry | null | undefined): MultiPolygonRings | null;
|
|
178
96
|
/**
|
|
179
|
-
* The polygons of a geometry that
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* @param subject Names the feature in the refusal, e.g. `feature 41209`.
|
|
183
|
-
* @param context Names the calling ingest, so a build log says which layer stopped.
|
|
184
|
-
* @throws {Error} When the geometry is neither a `Polygon` nor a `MultiPolygon`.
|
|
97
|
+
* The polygons of a geometry that must be areal, throwing when the geometry
|
|
98
|
+
* is not a `Polygon` or `MultiPolygon`.
|
|
185
99
|
*/
|
|
186
100
|
export declare function requireArealPolygons(geometry: ParsedGeometry, subject: string, context: string): MultiPolygonRings;
|
|
187
101
|
/**
|
|
188
|
-
* Does an areal GeoJSON geometry contain the point
|
|
189
|
-
*
|
|
190
|
-
* The three-valued return is the point of the function. `null` means the geometry is NOT AREAL — a Point or a
|
|
191
|
-
* LineString cannot contain anything — and a caller must read that as "no polygon on record", the same as a missing
|
|
192
|
-
* geometry, never as a rejection. Collapsing it to `false` is how a place with a point-only record gets excluded from a
|
|
193
|
-
* containment pass instead of falling through to the approximate path.
|
|
194
|
-
*
|
|
195
|
-
* `scripts/eval/pip-containment.py` grades the same containment truth against its own ray cast and has to be matched BY
|
|
196
|
-
* HAND if this one changes — it is the one copy no import can reach.
|
|
102
|
+
* Does an areal GeoJSON geometry contain the point, returning `null` for a
|
|
103
|
+
* non-areal geometry rather than `false`.
|
|
197
104
|
*/
|
|
198
105
|
export declare function geometryContains(geometry: ParsedGeometry | null | undefined, lon: number, lat: number): boolean | null;
|
|
199
106
|
/**
|
|
200
|
-
* An axis-aligned rectangle as a closed ring, in GeoJSON `[lon, lat]` order and counter-clockwise
|
|
201
|
-
* winding.
|
|
202
|
-
*
|
|
203
|
-
* SHARED BECAUSE THE WINDING IS A CONVENTION AND A SECOND COPY IS A SECOND PLACE FOR IT TO DRIFT. Three layer builders
|
|
204
|
-
* hand-build rectangles for their fixture rungs, and each pairs this with {@link reversedRing} to make a hole. A copy
|
|
205
|
-
* whose hole is wound the same way as its exterior produces a fixture that passes every structural check and tests
|
|
206
|
-
* nothing about hole handling — which is the exact failure the area cross-check exists to catch in production data.
|
|
107
|
+
* An axis-aligned rectangle as a closed ring, in GeoJSON `[lon, lat]` order and counter-clockwise.
|
|
207
108
|
*/
|
|
208
109
|
export declare function rectangleRing(minLon: number, minLat: number, maxLon: number, maxLat: number): number[][];
|
|
209
110
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polygon.d.ts","sourceRoot":"","sources":["../../lib/geometries/polygon.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD
|
|
1
|
+
{"version":3,"file":"polygon.d.ts","s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B,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CAQvG"}
|
|
@@ -14,17 +14,13 @@ export function isPolygonLiteral(input) {
|
|
|
14
14
|
/**
|
|
15
15
|
* Predicate for checking if a polygon geometry is a solid, i.e. it has no holes.
|
|
16
16
|
*/
|
|
17
|
-
// The parameter admits
|
|
18
|
-
// `SolidPolygonPath`, it cannot be asked about a polygon with holes without the caller asserting past the signature.
|
|
17
|
+
// The parameter admits both paths because distinguishing them is the function's job.
|
|
19
18
|
export function isSolidPolygonPath(input) {
|
|
20
19
|
return input.coordinates.length === 1;
|
|
21
20
|
}
|
|
22
21
|
/**
|
|
23
|
-
* Ray-cast a point against
|
|
24
|
-
* edge
|
|
25
|
-
*
|
|
26
|
-
* Points exactly on an edge are implementation-defined; either side is acceptable for geocoding, where admin boundaries
|
|
27
|
-
* are Douglas-Peucker–simplified before they ever reach us.
|
|
22
|
+
* Ray-cast a point against one linear ring — the even-odd crossing count,
|
|
23
|
+
* with points exactly on an edge left implementation-defined.
|
|
28
24
|
*/
|
|
29
25
|
export function pointInRing(lon, lat, ring) {
|
|
30
26
|
let inside = false;
|
|
@@ -41,11 +37,8 @@ export function pointInRing(lon, lat, ring) {
|
|
|
41
37
|
return inside;
|
|
42
38
|
}
|
|
43
39
|
/**
|
|
44
|
-
* Even-odd containment over a polygon's ring list (`[outer, hole₁, …]`)
|
|
45
|
-
*
|
|
46
|
-
* Being inside an odd number of rings means inside the polygon, which handles holes — and islands inside holes —
|
|
47
|
-
* without depending on ring winding order. GeoJSON nominally specifies orientation, but the gazetteer sources do not
|
|
48
|
-
* reliably honour it, so the orientation-free rule is the one that survives real data.
|
|
40
|
+
* Even-odd containment over a polygon's ring list (`[outer, hole₁, …]`), independent of
|
|
41
|
+
* ring winding order because the gazetteer sources do not honor it reliably.
|
|
49
42
|
*/
|
|
50
43
|
export function pointInPolygon(lon, lat, rings) {
|
|
51
44
|
let inside = false;
|
|
@@ -57,17 +50,14 @@ export function pointInPolygon(lon, lat, rings) {
|
|
|
57
50
|
return inside;
|
|
58
51
|
}
|
|
59
52
|
/**
|
|
60
|
-
* Inside
|
|
53
|
+
* Inside any polygon of a multi-polygon.
|
|
61
54
|
*/
|
|
62
55
|
export function pointInMultiPolygon(lon, lat, polygons) {
|
|
63
56
|
return polygons.some((rings) => pointInPolygon(lon, lat, rings));
|
|
64
57
|
}
|
|
65
58
|
/**
|
|
66
|
-
* A geometry's polygons in the `MultiPolygon` coordinate shape,
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* The one place a `Polygon` is lifted to `[rings]`; a caller that must refuse a non-areal geometry does so on the
|
|
70
|
-
* `null`, with its own message.
|
|
59
|
+
* A geometry's polygons in the `MultiPolygon` coordinate shape, with a bare `Polygon`
|
|
60
|
+
* lifted to `[rings]` and `null` for any non-areal geometry.
|
|
71
61
|
*/
|
|
72
62
|
export function arealPolygons(geometry) {
|
|
73
63
|
if (!geometry)
|
|
@@ -79,12 +69,8 @@ export function arealPolygons(geometry) {
|
|
|
79
69
|
return null;
|
|
80
70
|
}
|
|
81
71
|
/**
|
|
82
|
-
* The polygons of a geometry that
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* @param subject Names the feature in the refusal, e.g. `feature 41209`.
|
|
86
|
-
* @param context Names the calling ingest, so a build log says which layer stopped.
|
|
87
|
-
* @throws {Error} When the geometry is neither a `Polygon` nor a `MultiPolygon`.
|
|
72
|
+
* The polygons of a geometry that must be areal, throwing when the geometry
|
|
73
|
+
* is not a `Polygon` or `MultiPolygon`.
|
|
88
74
|
*/
|
|
89
75
|
export function requireArealPolygons(geometry, subject, context) {
|
|
90
76
|
const polygons = arealPolygons(geometry);
|
|
@@ -93,15 +79,8 @@ export function requireArealPolygons(geometry, subject, context) {
|
|
|
93
79
|
throw new Error(`${context}: ${subject} is a ${geometry.type}, expected Polygon or MultiPolygon`);
|
|
94
80
|
}
|
|
95
81
|
/**
|
|
96
|
-
* Does an areal GeoJSON geometry contain the point
|
|
97
|
-
*
|
|
98
|
-
* The three-valued return is the point of the function. `null` means the geometry is NOT AREAL — a Point or a
|
|
99
|
-
* LineString cannot contain anything — and a caller must read that as "no polygon on record", the same as a missing
|
|
100
|
-
* geometry, never as a rejection. Collapsing it to `false` is how a place with a point-only record gets excluded from a
|
|
101
|
-
* containment pass instead of falling through to the approximate path.
|
|
102
|
-
*
|
|
103
|
-
* `scripts/eval/pip-containment.py` grades the same containment truth against its own ray cast and has to be matched BY
|
|
104
|
-
* HAND if this one changes — it is the one copy no import can reach.
|
|
82
|
+
* Does an areal GeoJSON geometry contain the point, returning `null` for a
|
|
83
|
+
* non-areal geometry rather than `false`.
|
|
105
84
|
*/
|
|
106
85
|
export function geometryContains(geometry, lon, lat) {
|
|
107
86
|
const polygons = arealPolygons(geometry);
|
|
@@ -110,13 +89,7 @@ export function geometryContains(geometry, lon, lat) {
|
|
|
110
89
|
return polygons.some((rings) => pointInPolygon(lon, lat, rings));
|
|
111
90
|
}
|
|
112
91
|
/**
|
|
113
|
-
* An axis-aligned rectangle as a closed ring, in GeoJSON `[lon, lat]` order and counter-clockwise
|
|
114
|
-
* winding.
|
|
115
|
-
*
|
|
116
|
-
* SHARED BECAUSE THE WINDING IS A CONVENTION AND A SECOND COPY IS A SECOND PLACE FOR IT TO DRIFT. Three layer builders
|
|
117
|
-
* hand-build rectangles for their fixture rungs, and each pairs this with {@link reversedRing} to make a hole. A copy
|
|
118
|
-
* whose hole is wound the same way as its exterior produces a fixture that passes every structural check and tests
|
|
119
|
-
* nothing about hole handling — which is the exact failure the area cross-check exists to catch in production data.
|
|
92
|
+
* An axis-aligned rectangle as a closed ring, in GeoJSON `[lon, lat]` order and counter-clockwise.
|
|
120
93
|
*/
|
|
121
94
|
export function rectangleRing(minLon, minLat, maxLon, maxLat) {
|
|
122
95
|
return [
|
|
@@ -139,5 +112,4 @@ export function reversedRing(minLon, minLat, maxLon, maxLat) {
|
|
|
139
112
|
[minLon, minLat],
|
|
140
113
|
];
|
|
141
114
|
}
|
|
142
|
-
//#endregion
|
|
143
115
|
//# sourceMappingURL=polygon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polygon.js","sourceRoot":"","sources":["../../lib/geometries/polygon.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"polygon.js","sourceRoot":"","sources":["../../lib/geometries/polygon.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAyCH;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAsC,KAAc;IACnF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAE7D,OAAO,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,aAAa,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;AACjH,CAAC;AAED;;GAEG;AACH,qFAAqF;AACrF,MAAM,UAAU,kBAAkB,CAAC,KAAkC;IACpE,OAAO,KAAK,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,CAAA;AACtC,CAAC;AAmBD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,GAAW,EAAE,IAAqB;IAC1E,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAA;IAErB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,CAAA;QACvB,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC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CAAC;QAChB,CAAC,MAAM,EAAE,MAAM,CAAC;KAChB,CAAA;AACF,CAAC"}
|
|
@@ -3,120 +3,55 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* THE GEOMETRY IS THE TRUTH TABLE. An H3 index above it answers a cell that lies wholly inside one
|
|
10
|
-
* feature; a cell a boundary crosses falls through to a ray cast against the few features the index
|
|
11
|
-
* already named. A rooftop answer at a boundary — which is where the answer usually matters most — has
|
|
12
|
-
* no other source, so the rings are stored at the resolution the authority published them and never
|
|
13
|
-
* simplified.
|
|
14
|
-
*
|
|
15
|
-
* THE LAYOUT PUTS THE COORDINATES ON AN 8-BYTE BOUNDARY, so the reader takes a `Float64Array` view over
|
|
16
|
-
* them instead of a `DataView.getFloat64` per ordinate. Header is `u32 version`, `u32 ringCount`, then
|
|
17
|
-
* one `(u32 pointCount, u32 polygonIndex)` pair per ring — `8 + 8 × ringCount` bytes, a multiple of
|
|
18
|
-
* eight by construction. Coordinates follow as `[lon, lat]` pairs, ring by ring.
|
|
19
|
-
*
|
|
20
|
-
* `polygonIndex` IS required AND CANNOT BE INFERRED. A source feature is a MultiPolygon, so its
|
|
21
|
-
* rings belong to several polygons and "the first ring is the exterior" is true only per polygon. The
|
|
22
|
-
* point test is orientation-free and nesting-free (even-odd across a polygon's own rings, the rule
|
|
23
|
-
* {@link pointInPolygon} uses), but it still has to know which rings share a polygon: an island sitting
|
|
24
|
-
* inside another polygon's hole is inside the layer and would cancel to "outside" if every ring were
|
|
25
|
-
* pooled into one list.
|
|
26
|
-
*
|
|
27
|
-
* SHARED BY EVERY POLYGON LAYER RATHER THAN COPIED INTO EACH. `@mailwoman/flood` and `@mailwoman/soil`
|
|
28
|
-
* both store an authority's rings this way, and a second copy of the alignment arithmetic or of the
|
|
29
|
-
* signed-area reading would be a second thing to get right — both failure modes are silent, since a
|
|
30
|
-
* mis-read blob answers a containment question wrongly and a hole-blind area reading answers "inside"
|
|
31
|
-
* for every point in a hole.
|
|
6
|
+
* A polygon layer's stored ring blob: an 8-byte header, then a `(u32 pointCount, u32 polygonIndex)`
|
|
7
|
+
* pair per ring, then `[lon, lat]` pairs on an 8-byte boundary so the reader takes a
|
|
8
|
+
* `Float64Array` view; `polygonIndex` is required because one feature's rings belong to several polygons.
|
|
32
9
|
*/
|
|
10
|
+
import type { LatLonBounds } from "#bbox";
|
|
33
11
|
import type { MultiPolygonRings } from "#geometries/polygon";
|
|
34
12
|
/**
|
|
35
|
-
* Format version stamped into every blob
|
|
36
|
-
* bytes it does not know the shape of.
|
|
13
|
+
* Format version stamped into every blob, rejected by a reader that meets a different number.
|
|
37
14
|
*/
|
|
38
15
|
export declare const RING_BLOB_VERSION = 1;
|
|
39
16
|
/**
|
|
40
|
-
* One decoded feature: `[exteriorRing, ...holes]` per polygon, each ring a
|
|
17
|
+
* One decoded feature: `[exteriorRing, ...holes]` per polygon, each ring a
|
|
18
|
+
* flat `[lon, lat, lon, lat, …]` run.
|
|
41
19
|
*/
|
|
42
20
|
export interface DecodedRings {
|
|
43
|
-
/**
|
|
44
|
-
* `polygons[p][r]` is a flat coordinate run for ring `r` of polygon `p`.
|
|
45
|
-
*/
|
|
46
21
|
polygons: number[][][];
|
|
47
22
|
}
|
|
48
23
|
/**
|
|
49
|
-
* Pack a GeoJSON `MultiPolygon`/`Polygon` coordinate tree into the stored blob
|
|
50
|
-
*
|
|
51
|
-
* @throws {RangeError} When the geometry carries no ring, or a ring carries fewer than four positions (a linear ring is
|
|
52
|
-
* closed, so three is the minimum distinct-vertex count plus the repeat).
|
|
24
|
+
* Pack a GeoJSON `MultiPolygon`/`Polygon` coordinate tree into the stored blob, throwing
|
|
25
|
+
* when the geometry has no ring or a ring has fewer than four positions.
|
|
53
26
|
*/
|
|
54
27
|
export declare function encodeRings(polygons: MultiPolygonRings): Uint8Array;
|
|
55
28
|
/**
|
|
56
|
-
* Is the point inside the stored geometry
|
|
57
|
-
*
|
|
58
|
-
* Even-odd within each polygon's own ring list, inside-any-polygon across them — the orientation-free rule
|
|
59
|
-
* {@linkcode pointInPolygon} states, applied without allocating the ring arrays. Reading a hole as an exterior ring is
|
|
60
|
-
* what this rule survives: a point inside a hole crosses two rings and comes out even, whichever way either ring
|
|
61
|
-
* winds.
|
|
29
|
+
* Is the point inside the stored geometry, even-odd within each polygon's own ring list
|
|
30
|
+
* and inside-any-polygon across them, without allocating the ring arrays.
|
|
62
31
|
*/
|
|
63
32
|
export declare function pointInEncodedRings(blob: Uint8Array, lon: number, lat: number): boolean;
|
|
64
33
|
/**
|
|
65
|
-
* Unpack the blob back into per-polygon flat coordinate runs
|
|
66
|
-
* check a build's fixtures assert.
|
|
34
|
+
* Unpack the blob back into per-polygon flat coordinate runs.
|
|
67
35
|
*/
|
|
68
36
|
export declare function decodeRings(blob: Uint8Array): DecodedRings;
|
|
69
37
|
/**
|
|
70
|
-
* Signed spherical area of one linear ring, in square
|
|
71
|
-
*
|
|
72
|
-
* The sign is the whole point: an orientation-respecting sum over a polygon's rings subtracts its holes, while a sum of
|
|
73
|
-
* absolute values adds them. Comparing the two against the source's own area figure is what tells a builder whether it
|
|
74
|
-
* has read the holes at all — the failure mode is silent, because a hole read as an exterior ring produces a perfectly
|
|
75
|
-
* well-formed polygon that simply covers more ground than the authority mapped.
|
|
76
|
-
*
|
|
77
|
-
* WHICH WINDING IS POSITIVE IS A CONTRACT, NOT A DETAIL, because a builder whose source encodes hole roles by
|
|
78
|
-
* ORIENTATION reads roles off this sign. It is the opposite of the standard planar shoelace: this sum runs `(lonᵢ −
|
|
79
|
-
* lonⱼ)` against the shoelace's `(xⱼ − xᵢ)`, so a ring `@mailwoman/spatial`'s own {@link rectangleRing} builds
|
|
80
|
-
* counter-clockwise answers NEGATIVE here. `@mailwoman/zoning` is the caller that depends on it, and
|
|
81
|
-
* `packages/zoning/test/unit/ring-roles.test.ts` pins the sign directly.
|
|
38
|
+
* Signed spherical area of one linear ring, in square meters, with clockwise positive
|
|
39
|
+
* and counter-clockwise negative.
|
|
82
40
|
*/
|
|
83
41
|
export declare function ringSignedAreaM2(ring: ReadonlyArray<readonly number[]>): number;
|
|
84
42
|
/**
|
|
85
|
-
* Both readings of one feature's area, in square
|
|
86
|
-
* `allExterior` does not (holes add).
|
|
87
|
-
*
|
|
88
|
-
* A source whose holes are correctly nested makes `nested` match the authority's own figure and `allExterior` exceed
|
|
89
|
-
* it. The gap between them is the area a hole-blind reader would answer "inside" for.
|
|
43
|
+
* Both readings of one feature's area, in square meters: `nested` respects ring
|
|
44
|
+
* orientation (holes subtract) and `allExterior` does not (holes add).
|
|
90
45
|
*/
|
|
91
46
|
export declare function ringAreaReadings(polygons: MultiPolygonRings): {
|
|
92
47
|
nested: number;
|
|
93
48
|
allExterior: number;
|
|
94
49
|
};
|
|
95
50
|
/**
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
export interface DegreeExtent {
|
|
99
|
-
minLon: number;
|
|
100
|
-
minLat: number;
|
|
101
|
-
maxLon: number;
|
|
102
|
-
maxLat: number;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Refuse a feature whose reprojected vertices fall outside the publisher's own declared extent.
|
|
106
|
-
*
|
|
107
|
-
* THE CHECK A PROJECTION CHECK CANNOT MAKE. A swapped coordinate order survives an authority-code comparison — both
|
|
108
|
-
* axes are still numbers in a plausible range — and a source read in its own metres as if they were degrees produces
|
|
109
|
-
* perfectly well-formed coordinates in the wrong ocean. Both show up here on the first feature, before a whole layer is
|
|
110
|
-
* written to the wrong side of the planet.
|
|
111
|
-
*
|
|
112
|
-
* SHARED BY EVERY POLYGON INGEST, because it is rectangle arithmetic over the ring types and knows nothing about any
|
|
113
|
-
* product. `marginDegrees` is the caller's, because a declared extent is itself a rounded published value and how
|
|
114
|
-
* tightly a source hugs its own is a fact about that source.
|
|
115
|
-
*
|
|
116
|
-
* @param context Names the calling ingest in the refusal, so a build log says which layer stopped.
|
|
117
|
-
* @throws {RangeError} On the first vertex outside the extent.
|
|
51
|
+
* Refuse a feature whose reprojected vertices fall outside the publisher's own
|
|
52
|
+
* declared extent, throwing on the first vertex outside it.
|
|
118
53
|
*/
|
|
119
|
-
export declare function assertRingsInsideExtent(polygons: MultiPolygonRings, label: string, extent:
|
|
54
|
+
export declare function assertRingsInsideExtent(polygons: MultiPolygonRings, label: string, extent: LatLonBounds, marginDegrees: number, context?: string): void;
|
|
120
55
|
/**
|
|
121
56
|
* One stored polygon's bounding box and geometry, as every polygon layer's truth table stores them.
|
|
122
57
|
*/
|
|
@@ -128,40 +63,19 @@ export interface EncodedArea {
|
|
|
128
63
|
rings: Uint8Array;
|
|
129
64
|
}
|
|
130
65
|
/**
|
|
131
|
-
* A point
|
|
132
|
-
*
|
|
133
|
-
* The bounding-box centre is tried first; where it is not inside — a crescent, a band hugging a river, a polygon with a
|
|
134
|
-
* hole through its middle — a small deterministic grid over the box is scanned. A polygon no grid point lands inside is
|
|
135
|
-
* refused (`undefined`) rather than approximated, because a sample point that is not actually inside the polygon turns
|
|
136
|
-
* an agreement check into a check on the sampler.
|
|
137
|
-
*
|
|
138
|
-
* SHARED BY EVERY POLYGON LAYER'S VERIFY, because it is bounding-box arithmetic over the ring blob and knows nothing
|
|
139
|
-
* about any product. `gridSteps` is the one thing that differs between them: a layer whose polygons are narrow strips
|
|
140
|
-
* needs a finer grid than one whose polygons are compact, and the value is part of a layer's sampling receipt — two
|
|
141
|
-
* runs of the same layer must draw the same points, so it is a caller's choice rather than a shared default nobody
|
|
142
|
-
* owns.
|
|
143
|
-
*
|
|
144
|
-
* @param gridSteps Grid divisions per axis. Only `steps − 1` interior lines are tested, so 7 gives a 6 × 6 grid.
|
|
66
|
+
* A point inside one stored polygon for a verification sampler, returning `undefined` when neither
|
|
67
|
+
* the bounding-box center nor any of the `gridSteps − 1` interior grid lines lands inside.
|
|
145
68
|
*/
|
|
146
69
|
export declare function interiorPointOfEncodedRings(area: EncodedArea, gridSteps?: number): {
|
|
147
70
|
latitude: number;
|
|
148
71
|
longitude: number;
|
|
149
72
|
} | undefined;
|
|
150
73
|
/**
|
|
151
|
-
* Whether a stored polygon's precomputed bounding box contains the point
|
|
152
|
-
* only pulled off disk for a polygon that could contain the point.
|
|
74
|
+
* Whether a stored polygon's precomputed bounding box contains the point.
|
|
153
75
|
*/
|
|
154
76
|
export declare function bboxContains(bounds: Pick<EncodedArea, "min_lat" | "min_lon" | "max_lat" | "max_lon">, longitude: number, latitude: number): boolean;
|
|
155
77
|
/**
|
|
156
|
-
* A reproducible sample of interior points drawn by a deterministic
|
|
157
|
-
* layer's verification sampler shares.
|
|
158
|
-
*
|
|
159
|
-
* The keys are chosen before any geometry is read: selecting them alone is an index-only walk over the primary key, and
|
|
160
|
-
* the rows they name are then fetched by key. The draw is deterministic rather than random, so a re-run compares the
|
|
161
|
-
* same points and a disagreement can be looked at rather than re-rolled.
|
|
162
|
-
*
|
|
163
|
-
* @param options.gridSteps The interior-point search depth, per {@link interiorPointOfEncodedRings} — part of a layer's
|
|
164
|
-
* sampling receipt, so it is a caller's choice rather than a shared default nobody owns.
|
|
78
|
+
* A reproducible sample of interior points drawn by a deterministic stride over a key list.
|
|
165
79
|
*/
|
|
166
80
|
export declare function strideSampleInteriorPoints<Area extends EncodedArea, Point>(keys: readonly string[], count: number, options: {
|
|
167
81
|
fetch: (key: string) => Area | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ring-blob.d.ts","sourceRoot":"","sources":["../../lib/geometries/ring-blob.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ring-blob.d.ts","sourceRoot":"","sources":["../../lib/geometries/ring-blob.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D;;G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