@mailwoman/zoning 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.
- package/README.md +315 -0
- package/lib/index.ts +616 -0
- package/lib/ring-roles.ts +233 -0
- package/lib/rings.ts +34 -0
- package/lib/schema.ts +449 -0
- package/lib/scripts/ingest-chunk.ts +41 -0
- package/lib/sdk/build-zoning.ts +790 -0
- package/lib/sdk/cells.ts +276 -0
- package/lib/sdk/client.ts +335 -0
- package/lib/sdk/download.ts +78 -0
- package/lib/sdk/index.ts +15 -0
- package/lib/sdk/ingest-chunk.ts +360 -0
- package/lib/sdk/ingest.ts +402 -0
- package/lib/sdk/measure-resolutions.ts +100 -0
- package/lib/sdk/verify.ts +350 -0
- package/lib/test-kit.ts +207 -0
- package/lib/vocabulary.ts +342 -0
- package/out/index.d.ts +257 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +325 -0
- package/out/index.js.map +1 -0
- package/out/ring-roles.d.ts +88 -0
- package/out/ring-roles.d.ts.map +1 -0
- package/out/ring-roles.js +151 -0
- package/out/ring-roles.js.map +1 -0
- package/out/rings.d.ts +22 -0
- package/out/rings.d.ts.map +1 -0
- package/out/rings.js +22 -0
- package/out/rings.js.map +1 -0
- package/out/schema.d.ts +325 -0
- package/out/schema.d.ts.map +1 -0
- package/out/schema.js +186 -0
- package/out/schema.js.map +1 -0
- package/out/scripts/ingest-chunk.d.ts +11 -0
- package/out/scripts/ingest-chunk.d.ts.map +1 -0
- package/out/scripts/ingest-chunk.js +36 -0
- package/out/scripts/ingest-chunk.js.map +1 -0
- package/out/sdk/build-zoning.d.ts +283 -0
- package/out/sdk/build-zoning.d.ts.map +1 -0
- package/out/sdk/build-zoning.js +462 -0
- package/out/sdk/build-zoning.js.map +1 -0
- package/out/sdk/cells.d.ts +137 -0
- package/out/sdk/cells.d.ts.map +1 -0
- package/out/sdk/cells.js +176 -0
- package/out/sdk/cells.js.map +1 -0
- package/out/sdk/client.d.ts +151 -0
- package/out/sdk/client.d.ts.map +1 -0
- package/out/sdk/client.js +239 -0
- package/out/sdk/client.js.map +1 -0
- package/out/sdk/download.d.ts +51 -0
- package/out/sdk/download.d.ts.map +1 -0
- package/out/sdk/download.js +57 -0
- package/out/sdk/download.js.map +1 -0
- package/out/sdk/index.d.ts +15 -0
- package/out/sdk/index.d.ts.map +1 -0
- package/out/sdk/index.js +15 -0
- package/out/sdk/index.js.map +1 -0
- package/out/sdk/ingest-chunk.d.ts +130 -0
- package/out/sdk/ingest-chunk.d.ts.map +1 -0
- package/out/sdk/ingest-chunk.js +206 -0
- package/out/sdk/ingest-chunk.js.map +1 -0
- package/out/sdk/ingest.d.ts +191 -0
- package/out/sdk/ingest.d.ts.map +1 -0
- package/out/sdk/ingest.js +238 -0
- package/out/sdk/ingest.js.map +1 -0
- package/out/sdk/measure-resolutions.d.ts +51 -0
- package/out/sdk/measure-resolutions.d.ts.map +1 -0
- package/out/sdk/measure-resolutions.js +64 -0
- package/out/sdk/measure-resolutions.js.map +1 -0
- package/out/sdk/verify.d.ts +176 -0
- package/out/sdk/verify.d.ts.map +1 -0
- package/out/sdk/verify.js +202 -0
- package/out/sdk/verify.js.map +1 -0
- package/out/test-kit.d.ts +97 -0
- package/out/test-kit.d.ts.map +1 -0
- package/out/test-kit.js +180 -0
- package/out/test-kit.js.map +1 -0
- package/out/vocabulary.d.ts +221 -0
- package/out/vocabulary.d.ts.map +1 -0
- package/out/vocabulary.js +299 -0
- package/out/vocabulary.js.map +1 -0
- package/package.json +245 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The two-path agreement check, and its negative half.
|
|
7
|
+
*
|
|
8
|
+
* POSITIVE HALF. A sample of points is answered from the sealed artifact and then re-asked of the
|
|
9
|
+
* Department's own feature service — the same authority, a different distribution channel, and geometry
|
|
10
|
+
* this package has never touched. The point test is run again on the service's own rings, so what is
|
|
11
|
+
* compared is a verdict against a verdict rather than a file against itself. That is what makes it a check
|
|
12
|
+
* on OUR CONVERSION rather than on the authority.
|
|
13
|
+
*
|
|
14
|
+
* AND THE SERVICE ANSWERS IN THE PUBLISHER'S OWN RING CONVENTION, so the comparison exercises the hole
|
|
15
|
+
* handling twice over. `outSR=4326` on the query path returns the same clockwise-exterior rings the bulk
|
|
16
|
+
* export carries, so this side re-derives the roles the same way the ingest did — and a point inside a hole
|
|
17
|
+
* comes back OUTSIDE on both paths or on neither.
|
|
18
|
+
*
|
|
19
|
+
* NEGATIVE HALF, AND IT MATTERS MORE HERE THAN FOR ANY SIBLING LAYER. Donegal is the one local authority of
|
|
20
|
+
* 31 the Department does not publish, and Northern Ireland is outside the product entirely — so points in
|
|
21
|
+
* both must come back `unknown` with NO designation. A positive-only check would pass on an artifact that
|
|
22
|
+
* reported the whole island as zoned, and this layer's entire coverage posture exists because an absent
|
|
23
|
+
* polygon is not a statement.
|
|
24
|
+
*
|
|
25
|
+
* THE CHANNELS DIFFER IN COORDINATE PRECISION AND THAT IS WHY A BOUNDARY POINT IS NOT A FAILURE. The
|
|
26
|
+
* archive publishes nine decimals through this package's ingest; the service's own JSON rounds. A point
|
|
27
|
+
* within roughly a metre of a zone boundary can land on opposite sides of two renderings of the same edge.
|
|
28
|
+
* Those are reported as `boundary_tolerance` with their distance to the nearest edge, and the count is part
|
|
29
|
+
* of the receipt.
|
|
30
|
+
*
|
|
31
|
+
* THE DISTANCE IS TO THE EDGE, NOT TO THE NEAREST VERTEX. A point a centimetre from a long edge can be
|
|
32
|
+
* metres from every vertex of it — a sibling layer's one near-miss read 1.58 m to vertices and 0.009 m to
|
|
33
|
+
* edges, an overstatement of 175-fold — so measuring vertices makes the boundary tolerance far stricter than
|
|
34
|
+
* it reads, which is how a rendering difference gets reported as a conversion defect.
|
|
35
|
+
*/
|
|
36
|
+
import { nearestRingEdgeMetres, pointInEncodedRings, strideSampleInteriorPoints } from "@mailwoman/spatial";
|
|
37
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
38
|
+
import { ZoningLookup, ZoningReadingKind } from "#index";
|
|
39
|
+
import { encodeRings, resolveRingRoles } from "#rings";
|
|
40
|
+
/**
|
|
41
|
+
* Points this product's publication does not reach, named. Each is a place, not a bare pair of numbers: a coordinate a
|
|
42
|
+
* reader cannot name is a coordinate nobody can check.
|
|
43
|
+
*
|
|
44
|
+
* TWO POPULATIONS, AND BOTH ARE LOAD-BEARING. The Donegal points are the case this layer's coverage posture exists for
|
|
45
|
+
* — the Department has not published that authority's zoning, and a builder that read absence as "unrestricted" would
|
|
46
|
+
* answer them confidently. The Northern Irish points confirm the artifact is clipped to the Republic rather than to the
|
|
47
|
+
* island: zoning there is a different jurisdiction's instrument under a different planning act.
|
|
48
|
+
*/
|
|
49
|
+
export const OUTSIDE_PUBLICATION_POINTS = [
|
|
50
|
+
{ label: "Letterkenny town centre, Donegal", latitude: 54.9503, longitude: -7.7345 },
|
|
51
|
+
{ label: "Buncrana, Donegal", latitude: 55.1367, longitude: -7.4561 },
|
|
52
|
+
{ label: "Donegal Town", latitude: 54.6538, longitude: -8.1096 },
|
|
53
|
+
{ label: "Belfast city centre, Northern Ireland", latitude: 54.5973, longitude: -5.9301 },
|
|
54
|
+
{ label: "Derry city centre, Northern Ireland", latitude: 54.9966, longitude: -7.3086 },
|
|
55
|
+
{ label: "Enniskillen, Northern Ireland", latitude: 54.3438, longitude: -7.6316 },
|
|
56
|
+
];
|
|
57
|
+
/**
|
|
58
|
+
* Half-width of the bounding box the service is asked for, in degrees. About 11 m at this latitude — wide enough that a
|
|
59
|
+
* polygon containing the point is certainly returned, narrow enough that the response stays small.
|
|
60
|
+
*/
|
|
61
|
+
const PROBE_HALF_WIDTH_DEGREES = 0.0001;
|
|
62
|
+
/**
|
|
63
|
+
* How close to a service-polygon edge a disagreement is attributed to the channels' differing coordinate precision
|
|
64
|
+
* rather than to the conversion.
|
|
65
|
+
*
|
|
66
|
+
* Half a metre. The two channels render the same edge from the same source coordinates through different rounding, so a
|
|
67
|
+
* point between the two renderings lands on opposite sides; half a metre is far below any real zoning boundary and far
|
|
68
|
+
* above the rounding difference.
|
|
69
|
+
*/
|
|
70
|
+
const BOUNDARY_TOLERANCE_METRES = 0.5;
|
|
71
|
+
/**
|
|
72
|
+
* The reader the live check uses: a bounding-box query against the Department's own service.
|
|
73
|
+
*
|
|
74
|
+
* The service answers a BOX, not a point, so this returns what it published nearby and the containment decision is made
|
|
75
|
+
* in {@link readServiceContainment} against those rings — comparing the artifact's verdict against a bare "the service
|
|
76
|
+
* returned something here" would pass on any polygon within eleven metres.
|
|
77
|
+
*/
|
|
78
|
+
export function createServiceReader(client) {
|
|
79
|
+
return async (latitude, longitude) => client.readFeaturesNear(latitude, longitude, PROBE_HALF_WIDTH_DEGREES);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Run both halves.
|
|
83
|
+
*/
|
|
84
|
+
export async function verifyZoningDatabase(options) {
|
|
85
|
+
const lookup = new ZoningLookup({ databasePath: options.databasePath });
|
|
86
|
+
try {
|
|
87
|
+
const agreement = [];
|
|
88
|
+
for (const point of options.points) {
|
|
89
|
+
const local = lookup.lookup(point.latitude, point.longitude);
|
|
90
|
+
const service = await readServiceContainment(options.readServiceFeatures, point.latitude, point.longitude);
|
|
91
|
+
const localInside = local.kind === ZoningReadingKind.Designated;
|
|
92
|
+
const nearEdge = service.nearestEdgeMetres !== undefined && service.nearestEdgeMetres <= BOUNDARY_TOLERANCE_METRES;
|
|
93
|
+
agreement.push({
|
|
94
|
+
label: point.label,
|
|
95
|
+
latitude: point.latitude,
|
|
96
|
+
longitude: point.longitude,
|
|
97
|
+
local,
|
|
98
|
+
serviceInside: service.inside,
|
|
99
|
+
...(service.localCode === undefined ? {} : { serviceLocalCode: service.localCode }),
|
|
100
|
+
outcome: localInside === service.inside ? "agree" : nearEdge ? "boundary_tolerance" : "disagree",
|
|
101
|
+
...(service.nearestEdgeMetres === undefined ? {} : { nearestEdgeMetres: service.nearestEdgeMetres }),
|
|
102
|
+
});
|
|
103
|
+
options.onProgress?.(`${agreement.length}/${options.points.length} points compared`);
|
|
104
|
+
}
|
|
105
|
+
const outside = [];
|
|
106
|
+
for (const point of options.outsidePoints ?? OUTSIDE_PUBLICATION_POINTS) {
|
|
107
|
+
const reading = lookup.lookup(point.latitude, point.longitude);
|
|
108
|
+
outside.push({
|
|
109
|
+
label: point.label,
|
|
110
|
+
latitude: point.latitude,
|
|
111
|
+
longitude: point.longitude,
|
|
112
|
+
kind: reading.kind,
|
|
113
|
+
designations: reading.designations.length,
|
|
114
|
+
passed: reading.kind === ZoningReadingKind.Unknown && reading.designations.length === 0,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
agreement,
|
|
119
|
+
agreed: agreement.filter((row) => row.outcome === "agree").length,
|
|
120
|
+
disagreed: agreement.filter((row) => row.outcome === "disagree").length,
|
|
121
|
+
boundaryTolerance: agreement.filter((row) => row.outcome === "boundary_tolerance").length,
|
|
122
|
+
codeMismatches: agreement.filter((row) => row.outcome === "agree" &&
|
|
123
|
+
row.serviceInside &&
|
|
124
|
+
row.serviceLocalCode !== undefined &&
|
|
125
|
+
!row.local.designations.some((designation) => designation.localCode === row.serviceLocalCode)).length,
|
|
126
|
+
outside,
|
|
127
|
+
outsidePassed: outside.filter((row) => row.passed).length,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
lookup[Symbol.dispose]();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Whether the SERVICE's own geometry contains the point, decided here with the same ring-role resolution and the same
|
|
136
|
+
* even-odd rule the artifact's reader uses — so what is compared is a verdict against a verdict.
|
|
137
|
+
*/
|
|
138
|
+
async function readServiceContainment(readServiceFeatures, latitude, longitude) {
|
|
139
|
+
const features = await readServiceFeatures(latitude, longitude);
|
|
140
|
+
let nearest = Infinity;
|
|
141
|
+
let inside = false;
|
|
142
|
+
let localCode;
|
|
143
|
+
for (const feature of features) {
|
|
144
|
+
const geometry = feature.geometry;
|
|
145
|
+
if (!geometry)
|
|
146
|
+
continue;
|
|
147
|
+
const raw = geometry.type === "MultiPolygon"
|
|
148
|
+
? geometry.coordinates
|
|
149
|
+
: [geometry.coordinates];
|
|
150
|
+
const distance = nearestRingEdgeMetres(geometry, longitude, latitude);
|
|
151
|
+
if (distance < nearest) {
|
|
152
|
+
nearest = distance;
|
|
153
|
+
}
|
|
154
|
+
// THE SERVICE'S RINGS GET THE SAME ROLE RESOLUTION THE INGEST GAVE THE ARCHIVE'S. The publisher uses one convention on
|
|
155
|
+
// both channels, so reading this side as nested GeoJSON would answer "inside" for a point in a hole and report the
|
|
156
|
+
// artifact as wrong at exactly the locations the hole handling exists for.
|
|
157
|
+
const resolved = resolveRingRoles(raw, `service feature near ${latitude},${longitude}`);
|
|
158
|
+
// ENCODED AND RE-READ RATHER THAN RAY-CAST DIRECTLY, deliberately: the artifact answers through
|
|
159
|
+
// `pointInEncodedRings`, and running the service's geometry through a different predicate would compare two answers
|
|
160
|
+
// that were never asked the same question.
|
|
161
|
+
if (pointInEncodedRings(encodeRings(resolved.polygons), longitude, latitude)) {
|
|
162
|
+
inside = true;
|
|
163
|
+
const code = feature.properties?.ZONE_ORIG;
|
|
164
|
+
if (typeof code === "string" && localCode === undefined) {
|
|
165
|
+
localCode = code;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
inside,
|
|
171
|
+
...(localCode === undefined ? {} : { localCode }),
|
|
172
|
+
...(Number.isFinite(nearest) ? { nearestEdgeMetres: nearest } : {}),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Draw a reproducible sample of points from the artifact — interior points of stored polygons, spread across
|
|
177
|
+
* authorities.
|
|
178
|
+
*
|
|
179
|
+
* SPREAD ACROSS AUTHORITIES RATHER THAN DRAWN FROM ONE, because 30 local authorities publish 581 distinct local codes
|
|
180
|
+
* between them and a sample from one would verify one authority's conversion while reporting on all of them. The stride
|
|
181
|
+
* discipline — keys chosen before any geometry is read, deterministic rather than random — is
|
|
182
|
+
* `strideSampleInteriorPoints`'s.
|
|
183
|
+
*/
|
|
184
|
+
export function sampleAgreementPoints(databasePath, options = {}) {
|
|
185
|
+
const count = options.count ?? 48;
|
|
186
|
+
using database = new DatabaseClient(databasePath, { readOnly: true });
|
|
187
|
+
// ORDERED BY THE AUTHORITY FIRST, so a stride walks across the 30 of them rather than down one. A stride over
|
|
188
|
+
// `area_id` alone would follow the publisher's own feature numbering, which is grouped by authority — and would draw
|
|
189
|
+
// every sample from whichever authorities happen to sit on the stride.
|
|
190
|
+
const areaIDs = database.prepare("SELECT area_id FROM zoning_area ORDER BY jurisdiction_id, area_id").all().map((row) => row.area_id);
|
|
191
|
+
const selectArea = database.prepare("SELECT area_id, jurisdiction_id, local_code, min_lat, min_lon, max_lat, max_lon, rings FROM zoning_area WHERE area_id = ?");
|
|
192
|
+
return strideSampleInteriorPoints(areaIDs, count, {
|
|
193
|
+
fetch: (key) => selectArea.get(key),
|
|
194
|
+
gridSteps: 17,
|
|
195
|
+
toPoint: (area, interior) => ({
|
|
196
|
+
label: `${area.jurisdiction_id} ${JSON.stringify(area.local_code)} polygon ${area.area_id}`,
|
|
197
|
+
localCode: area.local_code,
|
|
198
|
+
...interior,
|
|
199
|
+
}),
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../lib/sdk/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA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C,2HAA2H,CAC3H,CAAA;IAED,OAAO,0BAA0B,CAAC,OAAO,EAAE,KAAK,EAAE;QACjD,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CACd,UAAU,CAAC,GAAG,CAAC,GAAG,CAWN;QACb,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC7B,KAAK,EAAE,GAAG,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,IAAI,CAAC,OAAO,EAAE;YAC3F,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,GAAG,QAAQ;SACX,CAAC;KACF,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* `@mailwoman/zoning/test-kit` — hand-built geometry for the fixture rung: zones in two plans over the same
|
|
7
|
+
* ground, one with a hole encoded the way this service encodes them, one smaller than a cell, and one the
|
|
8
|
+
* authority states as UNZONED.
|
|
9
|
+
*
|
|
10
|
+
* A PACKAGE SUBPATH RATHER THAN A `test/` FILE, for the same reason `packages/mailwoman/lib/test-kit` is one:
|
|
11
|
+
* the observation route's suite lives in another workspace, and a relative import across two TypeScript
|
|
12
|
+
* projects is refused outright (`TS2878`) because the compiled layout would not match the source layout.
|
|
13
|
+
*
|
|
14
|
+
* NO NETWORK AND NO GDAL. The builder takes a {@linkcode ZoningFeatureSource}, so a fixture is a list of
|
|
15
|
+
* features — which is what lets this rung exercise the ring-role resolution, the vocabulary census, the cell
|
|
16
|
+
* classification, the coverage rows, the manifest and the seal on every machine rather than only the ones
|
|
17
|
+
* with ogr2ogr.
|
|
18
|
+
*
|
|
19
|
+
* THE EXTERIOR RING IS THE CLOCKWISE ONE, WHICH IS THE INVERSE OF THE GEOJSON CONVENTION AND OF EVERY
|
|
20
|
+
* SIBLING FIXTURE. `@mailwoman/spatial`'s `rectangleRing` winds counter-clockwise and its `reversedRing`
|
|
21
|
+
* clockwise, so this file aliases them the other way round from the flood and coastal test kits: under this
|
|
22
|
+
* service a clockwise ring is the EXTERIOR and a counter-clockwise one is a HOLE. A fixture that used the
|
|
23
|
+
* sibling naming would build geometry the ingest reads inside-out, and every assertion on it would pass.
|
|
24
|
+
*
|
|
25
|
+
* THE COORDINATES ARE IN THE IRISH SEA east of Dublin — inside the Department's declared extent, so a
|
|
26
|
+
* fixture stays in the coordinate space the product occupies, and clear of every real zoning polygon.
|
|
27
|
+
*/
|
|
28
|
+
import { rectangleRing as counterClockwiseRing, reversedRing as clockwiseRing } from "@mailwoman/spatial";
|
|
29
|
+
import { type MultiPolygonRings } from "#rings";
|
|
30
|
+
import type { ZoningFeatureSource, ZoningSourceFeature } from "#sdk/ingest";
|
|
31
|
+
/**
|
|
32
|
+
* The exterior ring builder, under THIS service's convention. Clockwise.
|
|
33
|
+
*/
|
|
34
|
+
export declare const exteriorRing: typeof clockwiseRing;
|
|
35
|
+
/**
|
|
36
|
+
* The hole ring builder, under THIS service's convention. Counter-clockwise.
|
|
37
|
+
*/
|
|
38
|
+
export declare const holeRing: typeof counterClockwiseRing;
|
|
39
|
+
/**
|
|
40
|
+
* South-west corner of the fixture world, in the Irish Sea east of Dublin.
|
|
41
|
+
*/
|
|
42
|
+
export declare const FIXTURE_ORIGIN: {
|
|
43
|
+
readonly lon: -5.99;
|
|
44
|
+
readonly lat: 53.3;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Side of a fixture zone, in degrees. About 1.1 km at this latitude — several res-10 cells across, so a zone has a real
|
|
48
|
+
* interior AND a real fringe.
|
|
49
|
+
*/
|
|
50
|
+
export declare const FIXTURE_SIDE = 0.01;
|
|
51
|
+
/**
|
|
52
|
+
* The fixture authority and its two plans.
|
|
53
|
+
*/
|
|
54
|
+
export declare const FIXTURE_AUTHORITY: {
|
|
55
|
+
readonly code: "Fx";
|
|
56
|
+
readonly name: "Fixture County Council";
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* The two plans the fixture set uses, shaped like the real product's: a Development Plan and a Local Area Plan, each
|
|
60
|
+
* with its own stated window, both able to zone the same ground.
|
|
61
|
+
*
|
|
62
|
+
* The dates are in the source's own RFC 1123 form, because that is what the export publishes and this layer carries
|
|
63
|
+
* them as published rather than re-formatting them.
|
|
64
|
+
*/
|
|
65
|
+
export declare const FIXTURE_PLANS: {
|
|
66
|
+
readonly development: {
|
|
67
|
+
readonly id: "FX-DP-2024";
|
|
68
|
+
readonly name: "Fixture County Development Plan 2024-2030";
|
|
69
|
+
readonly level: "DP";
|
|
70
|
+
readonly from: "Mon, 01 Jan 2024 00:00:00 GMT";
|
|
71
|
+
readonly to: "Sun, 31 Dec 2030 00:00:00 GMT";
|
|
72
|
+
};
|
|
73
|
+
readonly localArea: {
|
|
74
|
+
readonly id: "FX-LAP-2022";
|
|
75
|
+
readonly name: "Fixture Town Local Area Plan 2022-2028";
|
|
76
|
+
readonly level: "LAP";
|
|
77
|
+
readonly from: "Sat, 01 Jan 2022 00:00:00 GMT";
|
|
78
|
+
readonly to: "Sun, 31 Dec 2028 00:00:00 GMT";
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* One fixture feature, with its rings resolved the way the real ingest resolves them.
|
|
83
|
+
*/
|
|
84
|
+
export declare function fixtureFeature(objectID: number, polygons: MultiPolygonRings, overrides?: Partial<Omit<ZoningSourceFeature, "rings">>): ZoningSourceFeature;
|
|
85
|
+
/**
|
|
86
|
+
* The fixture set: two adjacent zones, one of them holed the way this service encodes holes; a second plan over the
|
|
87
|
+
* SAME ground as the first; a zone smaller than a cell; and a zone the authority states as unzoned.
|
|
88
|
+
*
|
|
89
|
+
* THE OVERLAP BETWEEN PLANS IS THE POINT. A point inside the first zone must answer with BOTH rows, each naming its own
|
|
90
|
+
* plan — which is what proves a plan is part of the claim rather than a parameter of it.
|
|
91
|
+
*/
|
|
92
|
+
export declare function fixtureFeatures(): ZoningSourceFeature[];
|
|
93
|
+
/**
|
|
94
|
+
* A feature source over an explicit feature list.
|
|
95
|
+
*/
|
|
96
|
+
export declare function fixtureSource(features: ZoningSourceFeature[]): ZoningFeatureSource;
|
|
97
|
+
//# sourceMappingURL=test-kit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-kit.d.ts","sourceRoot":"","sources":["../lib/test-kit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,aAAa,IAAI,oBAAoB,EAAE,YAAY,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEzG,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAG3E;;GAEG;AACH,eAAO,MAAM,YAAY,sBAAgB,CAAA;AAEzC;;GAEG;AACH,eAAO,MAAM,QAAQ,6BAAuB,CAAA;AAE5C;;GAEG;AACH,eAAO,MAAM,cAAc;;;CAAqC,CAAA;AAEhE;;;GAGG;AACH,eAAO,MAAM,YAAY,OAAO,CAAA;AAEhC;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;CAA0D,CAAA;AAExF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;CAehB,CAAA;AAEV;;GAEG;AACH,wBAAgB,cAAc,CAC7B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,GAAE,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAM,GACzD,mBAAmB,CAwBrB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,mBAAmB,EAAE,CAoEvD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,mBAAmB,EAAE,GAAG,mBAAmB,CASlF"}
|
package/out/test-kit.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* `@mailwoman/zoning/test-kit` — hand-built geometry for the fixture rung: zones in two plans over the same
|
|
7
|
+
* ground, one with a hole encoded the way this service encodes them, one smaller than a cell, and one the
|
|
8
|
+
* authority states as UNZONED.
|
|
9
|
+
*
|
|
10
|
+
* A PACKAGE SUBPATH RATHER THAN A `test/` FILE, for the same reason `packages/mailwoman/lib/test-kit` is one:
|
|
11
|
+
* the observation route's suite lives in another workspace, and a relative import across two TypeScript
|
|
12
|
+
* projects is refused outright (`TS2878`) because the compiled layout would not match the source layout.
|
|
13
|
+
*
|
|
14
|
+
* NO NETWORK AND NO GDAL. The builder takes a {@linkcode ZoningFeatureSource}, so a fixture is a list of
|
|
15
|
+
* features — which is what lets this rung exercise the ring-role resolution, the vocabulary census, the cell
|
|
16
|
+
* classification, the coverage rows, the manifest and the seal on every machine rather than only the ones
|
|
17
|
+
* with ogr2ogr.
|
|
18
|
+
*
|
|
19
|
+
* THE EXTERIOR RING IS THE CLOCKWISE ONE, WHICH IS THE INVERSE OF THE GEOJSON CONVENTION AND OF EVERY
|
|
20
|
+
* SIBLING FIXTURE. `@mailwoman/spatial`'s `rectangleRing` winds counter-clockwise and its `reversedRing`
|
|
21
|
+
* clockwise, so this file aliases them the other way round from the flood and coastal test kits: under this
|
|
22
|
+
* service a clockwise ring is the EXTERIOR and a counter-clockwise one is a HOLE. A fixture that used the
|
|
23
|
+
* sibling naming would build geometry the ingest reads inside-out, and every assertion on it would pass.
|
|
24
|
+
*
|
|
25
|
+
* THE COORDINATES ARE IN THE IRISH SEA east of Dublin — inside the Department's declared extent, so a
|
|
26
|
+
* fixture stays in the coordinate space the product occupies, and clear of every real zoning polygon.
|
|
27
|
+
*/
|
|
28
|
+
import { rectangleRing as counterClockwiseRing, reversedRing as clockwiseRing } from "@mailwoman/spatial";
|
|
29
|
+
import { resolveRingRoles } from "#rings";
|
|
30
|
+
import { GZT_SOURCE_EPSG, GZT_UNZONED_LOCAL_CODE } from "#vocabulary";
|
|
31
|
+
/**
|
|
32
|
+
* The exterior ring builder, under THIS service's convention. Clockwise.
|
|
33
|
+
*/
|
|
34
|
+
export const exteriorRing = clockwiseRing;
|
|
35
|
+
/**
|
|
36
|
+
* The hole ring builder, under THIS service's convention. Counter-clockwise.
|
|
37
|
+
*/
|
|
38
|
+
export const holeRing = counterClockwiseRing;
|
|
39
|
+
/**
|
|
40
|
+
* South-west corner of the fixture world, in the Irish Sea east of Dublin.
|
|
41
|
+
*/
|
|
42
|
+
export const FIXTURE_ORIGIN = { lon: -5.99, lat: 53.3 };
|
|
43
|
+
/**
|
|
44
|
+
* Side of a fixture zone, in degrees. About 1.1 km at this latitude — several res-10 cells across, so a zone has a real
|
|
45
|
+
* interior AND a real fringe.
|
|
46
|
+
*/
|
|
47
|
+
export const FIXTURE_SIDE = 0.01;
|
|
48
|
+
/**
|
|
49
|
+
* The fixture authority and its two plans.
|
|
50
|
+
*/
|
|
51
|
+
export const FIXTURE_AUTHORITY = { code: "Fx", name: "Fixture County Council" };
|
|
52
|
+
/**
|
|
53
|
+
* The two plans the fixture set uses, shaped like the real product's: a Development Plan and a Local Area Plan, each
|
|
54
|
+
* with its own stated window, both able to zone the same ground.
|
|
55
|
+
*
|
|
56
|
+
* The dates are in the source's own RFC 1123 form, because that is what the export publishes and this layer carries
|
|
57
|
+
* them as published rather than re-formatting them.
|
|
58
|
+
*/
|
|
59
|
+
export const FIXTURE_PLANS = {
|
|
60
|
+
development: {
|
|
61
|
+
id: "FX-DP-2024",
|
|
62
|
+
name: "Fixture County Development Plan 2024-2030",
|
|
63
|
+
level: "DP",
|
|
64
|
+
from: "Mon, 01 Jan 2024 00:00:00 GMT",
|
|
65
|
+
to: "Sun, 31 Dec 2030 00:00:00 GMT",
|
|
66
|
+
},
|
|
67
|
+
localArea: {
|
|
68
|
+
id: "FX-LAP-2022",
|
|
69
|
+
name: "Fixture Town Local Area Plan 2022-2028",
|
|
70
|
+
level: "LAP",
|
|
71
|
+
from: "Sat, 01 Jan 2022 00:00:00 GMT",
|
|
72
|
+
to: "Sun, 31 Dec 2028 00:00:00 GMT",
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* One fixture feature, with its rings resolved the way the real ingest resolves them.
|
|
77
|
+
*/
|
|
78
|
+
export function fixtureFeature(objectID, polygons, overrides = {}) {
|
|
79
|
+
const plan = FIXTURE_PLANS.development;
|
|
80
|
+
return {
|
|
81
|
+
areaID: String(objectID),
|
|
82
|
+
authorityCode: FIXTURE_AUTHORITY.code,
|
|
83
|
+
authorityName: FIXTURE_AUTHORITY.name,
|
|
84
|
+
planID: plan.id,
|
|
85
|
+
planName: plan.name,
|
|
86
|
+
planLevel: plan.level,
|
|
87
|
+
planFrom: plan.from,
|
|
88
|
+
planTo: plan.to,
|
|
89
|
+
currentPlan: 1,
|
|
90
|
+
localCode: "R2 - Existing Residential",
|
|
91
|
+
localDescription: "Existing residential",
|
|
92
|
+
localCodeURL: "https://example.invalid/fixture-plan",
|
|
93
|
+
crosswalkCode: "R2",
|
|
94
|
+
crosswalkDescription: "Existing residential",
|
|
95
|
+
crosswalkRollup: "RE",
|
|
96
|
+
...overrides,
|
|
97
|
+
// RESOLVED THROUGH THE REAL RESOLVER, never hand-assembled: a fixture that nested its own holes would test the
|
|
98
|
+
// assertion rather than the resolution, and the resolution is the part of this layer no sibling already has.
|
|
99
|
+
rings: resolveRingRoles(polygons, String(objectID)),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The fixture set: two adjacent zones, one of them holed the way this service encodes holes; a second plan over the
|
|
104
|
+
* SAME ground as the first; a zone smaller than a cell; and a zone the authority states as unzoned.
|
|
105
|
+
*
|
|
106
|
+
* THE OVERLAP BETWEEN PLANS IS THE POINT. A point inside the first zone must answer with BOTH rows, each naming its own
|
|
107
|
+
* plan — which is what proves a plan is part of the claim rather than a parameter of it.
|
|
108
|
+
*/
|
|
109
|
+
export function fixtureFeatures() {
|
|
110
|
+
const { lon, lat } = FIXTURE_ORIGIN;
|
|
111
|
+
const zoneA = exteriorRing(lon, lat, lon + FIXTURE_SIDE, lat + FIXTURE_SIDE);
|
|
112
|
+
const zoneB = exteriorRing(lon + FIXTURE_SIDE, lat, lon + 2 * FIXTURE_SIDE, lat + FIXTURE_SIDE);
|
|
113
|
+
// THE HOLE IS A SEPARATE PART, not a nested ring — which is how the real service encodes it on the features that carry
|
|
114
|
+
// one, and the encoding a nesting-aware reader turns into a second zoned area.
|
|
115
|
+
const holed = [
|
|
116
|
+
[exteriorRing(lon, lat + 2 * FIXTURE_SIDE, lon + FIXTURE_SIDE, lat + 3 * FIXTURE_SIDE)],
|
|
117
|
+
[
|
|
118
|
+
holeRing(lon + FIXTURE_SIDE * 0.35, lat + 2 * FIXTURE_SIDE + FIXTURE_SIDE * 0.35, lon + FIXTURE_SIDE * 0.65, lat + 2 * FIXTURE_SIDE + FIXTURE_SIDE * 0.65),
|
|
119
|
+
],
|
|
120
|
+
];
|
|
121
|
+
// About 5.5 m across — smaller than a res-11 cell, let alone a res-9 one. `polygonToCells` returns nothing for a shape
|
|
122
|
+
// this size, so it is the fixture that proves the index takes cell-touches-polygon rather than centre-in-polygon.
|
|
123
|
+
const sliver = exteriorRing(lon + 3 * FIXTURE_SIDE, lat, lon + 3 * FIXTURE_SIDE + 0.00005, lat + 0.00005);
|
|
124
|
+
const unzoned = exteriorRing(lon + 4 * FIXTURE_SIDE, lat, lon + 5 * FIXTURE_SIDE, lat + FIXTURE_SIDE);
|
|
125
|
+
const localAreaPlan = FIXTURE_PLANS.localArea;
|
|
126
|
+
return [
|
|
127
|
+
fixtureFeature(1, [[zoneA]]),
|
|
128
|
+
fixtureFeature(2, [[zoneB]], {
|
|
129
|
+
localCode: "C2.1 - Industrial",
|
|
130
|
+
localDescription: "Industrial, enterprise and employment",
|
|
131
|
+
crosswalkCode: "C2.1",
|
|
132
|
+
crosswalkDescription: "Industrial, enterprise, employment",
|
|
133
|
+
}),
|
|
134
|
+
fixtureFeature(3, holed, {
|
|
135
|
+
localCode: "G1 - Open Space",
|
|
136
|
+
localDescription: "Open space and park",
|
|
137
|
+
crosswalkCode: "G1",
|
|
138
|
+
crosswalkDescription: "Open space, park",
|
|
139
|
+
}),
|
|
140
|
+
fixtureFeature(4, [[sliver]], {
|
|
141
|
+
localCode: "N1.1 - Road",
|
|
142
|
+
localDescription: "Road reservation",
|
|
143
|
+
crosswalkCode: "N1.1",
|
|
144
|
+
crosswalkDescription: "Road",
|
|
145
|
+
}),
|
|
146
|
+
// The authority states unzoned land POSITIVELY, and uses a code its own domain never declares for it.
|
|
147
|
+
fixtureFeature(5, [[unzoned]], {
|
|
148
|
+
localCode: GZT_UNZONED_LOCAL_CODE,
|
|
149
|
+
localDescription: "Unzoned",
|
|
150
|
+
crosswalkCode: "N/A",
|
|
151
|
+
crosswalkDescription: null,
|
|
152
|
+
crosswalkRollup: "N/A",
|
|
153
|
+
}),
|
|
154
|
+
// The SAME ground as zone A under a second plan, and the same local code mapped to a DIFFERENT generic type — which
|
|
155
|
+
// is the shape that makes the crosswalk non-functional over an (authority, code) pair.
|
|
156
|
+
fixtureFeature(6, [[zoneA]], {
|
|
157
|
+
planID: localAreaPlan.id,
|
|
158
|
+
planName: localAreaPlan.name,
|
|
159
|
+
planLevel: localAreaPlan.level,
|
|
160
|
+
planFrom: localAreaPlan.from,
|
|
161
|
+
planTo: localAreaPlan.to,
|
|
162
|
+
crosswalkCode: "R3",
|
|
163
|
+
crosswalkDescription: "Residential, mixed residential and other uses",
|
|
164
|
+
}),
|
|
165
|
+
];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* A feature source over an explicit feature list.
|
|
169
|
+
*/
|
|
170
|
+
export function fixtureSource(features) {
|
|
171
|
+
return {
|
|
172
|
+
declaredFeatureCount: features.length,
|
|
173
|
+
epsg: GZT_SOURCE_EPSG,
|
|
174
|
+
origin: "fixture",
|
|
175
|
+
async *features() {
|
|
176
|
+
yield* features;
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=test-kit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-kit.js","sourceRoot":"","sources":["../lib/test-kit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,aAAa,IAAI,oBAAoB,EAAE,YAAY,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEzG,OAAO,EAAE,gBAAgB,EAA0B,MAAM,QAAQ,CAAA;AAEjE,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAErE;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAA;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,oBAAoB,CAAA;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAW,CAAA;AAEhE;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAA;AAEhC;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,wBAAwB,EAAW,CAAA;AAExF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,WAAW,EAAE;QACZ,EAAE,EAAE,YAAY;QAChB,IAAI,EAAE,2CAA2C;QACjD,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,+BA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