@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,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Read the Department's bulk export as a stream of WGS84 features, through ogr2ogr.
|
|
7
|
+
*
|
|
8
|
+
* OGR IS BUILD TOOLING, NEVER A SERVE DEPENDENCY (SCOPE invariant 6). It converts the authority's geometry
|
|
9
|
+
* into the structure the runtime probes, and nothing downstream of this module knows GDAL exists.
|
|
10
|
+
*
|
|
11
|
+
* THE STREAM IS WKT, NOT GEOJSON, AND THAT IS A CORRECTNESS CHOICE RATHER THAN A TASTE ONE. This service
|
|
12
|
+
* encodes hole roles by ring ORIENTATION — clockwise exterior, the inverse of RFC 7946 — and puts each ring
|
|
13
|
+
* in its own `MultiPolygon` part on the features that carry holes that way. GDAL's GeoJSON writer enforces
|
|
14
|
+
* the RFC 7946 winding unconditionally: `-lco RFC7946=NO` is not a GeoJSONSeq option, and
|
|
15
|
+
* `--config OGR_ORGANIZE_POLYGONS SKIP` changes nothing. Measured on the largest feature in the country,
|
|
16
|
+
* Meath's `RA - Rural Area`: through GeoJSONSeq it arrives as 107 counter-clockwise rings totalling
|
|
17
|
+
* 2,371.9 km², through CSV/WKT as the source's own 5 clockwise and 102 counter-clockwise totalling
|
|
18
|
+
* 2,223.1 km² against the Department's published 2,232.1 km². The GeoJSON path has silently turned 102
|
|
19
|
+
* holes into 102 zoned areas.
|
|
20
|
+
*
|
|
21
|
+
* AND THE TRANSPORT IS NOT THE SLOW HALF. Measured on this lab over the whole national export: ogr2ogr
|
|
22
|
+
* reprojects to 224,066,621 bytes of WKT CSV in 13.2 s, and `CSVSpliterator` plus the WKT parse reads
|
|
23
|
+
* 85,330 rows, 93,483 rings and 6,327,256 positions back out of it in 2.2 s.
|
|
24
|
+
*
|
|
25
|
+
* THE SOURCE IS NOT IN WGS84 AND SAYING SO IS THE CHECK. The bulk export is IRENET95 / Irish Transverse
|
|
26
|
+
* Mercator — metres, easting/northing, EPSG:2157 — declared in a top-level `crs` member RFC 7946 removed
|
|
27
|
+
* from the format. GDAL honours the legacy member; a strict reader ignores it and places Ireland's zoning
|
|
28
|
+
* at latitude 735,435. So the projection is asserted against the source's declared authority code before a
|
|
29
|
+
* single feature is read, and every reprojected vertex is asserted inside the Department's own declared
|
|
30
|
+
* extent — which is the check that catches a coordinate-order mistake the projection check cannot see.
|
|
31
|
+
*
|
|
32
|
+
* THE DATUM SHIFT NEEDS A GRID, AND ITS ABSENCE IS SILENT. PROJ substitutes a ballpark offset when the
|
|
33
|
+
* accurate transformation is unavailable and produces coordinates that are metres wrong and
|
|
34
|
+
* indistinguishable from correct ones. {@linkcode assertDatumTransformationAvailable} asks `projinfo` what
|
|
35
|
+
* PROJ would choose and refuses a ballpark; for this source it names
|
|
36
|
+
* `Inverse of Irish Transverse Mercator + IRENET95 to WGS 84 (1), 1 m`.
|
|
37
|
+
*
|
|
38
|
+
* THE PUBLISHER'S OWN AREA COLUMN IS NOT IN THE ARCHIVE. `Shape__Area` is a service field and the export
|
|
39
|
+
* drops it, so the area cross-check reads it from the live service instead — which makes it a genuine
|
|
40
|
+
* two-path check rather than the archive agreeing with itself. See `sdk/client.ts`.
|
|
41
|
+
*/
|
|
42
|
+
import { assertRingsInsideExtent, requireArealPolygons } from "@mailwoman/spatial";
|
|
43
|
+
import { readOGRLayerIdentity } from "@mailwoman/spatial/tools/ogr";
|
|
44
|
+
import { spawnOGR2OGR } from "@mailwoman/spatial/tools/ogr-stream";
|
|
45
|
+
import { wellKnownGeometryToGeoJSON } from "@mailwoman/spatial/well-known-text";
|
|
46
|
+
import { CSVSpliterator } from "spliterator";
|
|
47
|
+
import { resolveRingRoles } from "#rings";
|
|
48
|
+
import { GZT_DECLARED_BBOX, GZT_SOURCE_EPSG } from "#vocabulary";
|
|
49
|
+
/**
|
|
50
|
+
* The ring types and the PROJ guard, both re-exported from `@mailwoman/spatial`: neither is zoning-specific, and a
|
|
51
|
+
* second copy of the `projinfo` parse would be a second place for the ballpark check to stop refusing.
|
|
52
|
+
*/
|
|
53
|
+
export { assessDatumTransformation } from "@mailwoman/spatial/projection-transform";
|
|
54
|
+
/**
|
|
55
|
+
* Coordinate decimals ogr2ogr writes into the stream. Nine is ~0.1 mm at this latitude — far past the source's own
|
|
56
|
+
* precision, and chosen so the reprojection contributes nothing measurable to the area cross-check.
|
|
57
|
+
*/
|
|
58
|
+
const COORDINATE_PRECISION = 9;
|
|
59
|
+
/**
|
|
60
|
+
* How far outside the declared extent a vertex may fall before the ingest refuses.
|
|
61
|
+
*
|
|
62
|
+
* A declared extent is itself a rounded published value, so an exact test would be brittle; this margin is small enough
|
|
63
|
+
* that an unprojected or axis-swapped read — which lands degrees or whole hemispheres away — still fails.
|
|
64
|
+
*/
|
|
65
|
+
const BBOX_MARGIN_DEGREES = 0.01;
|
|
66
|
+
/**
|
|
67
|
+
* The attribute columns the ingest reads. Every one is required: this product publishes a single schema, and a column
|
|
68
|
+
* that vanished would be a product change rather than a variation to absorb.
|
|
69
|
+
*/
|
|
70
|
+
export const ZONING_SOURCE_FIELDS = [
|
|
71
|
+
"OBJECTID",
|
|
72
|
+
"LA_CODE",
|
|
73
|
+
"LA_NAME",
|
|
74
|
+
"PLAN_ID",
|
|
75
|
+
"PLAN_NAME",
|
|
76
|
+
"PLAN_LEVEL",
|
|
77
|
+
"PLAN_FROM",
|
|
78
|
+
"PLAN_TO",
|
|
79
|
+
"CURRENT_PLAN",
|
|
80
|
+
"ZONE_ORIG",
|
|
81
|
+
"ZONE_DESC",
|
|
82
|
+
"ZONE_LINK",
|
|
83
|
+
"ZONE_GZT",
|
|
84
|
+
"GZT_DESC",
|
|
85
|
+
"SZO",
|
|
86
|
+
];
|
|
87
|
+
/**
|
|
88
|
+
* What the source declares about itself: its authority code, its feature count and its field list.
|
|
89
|
+
*
|
|
90
|
+
* @throws {Error} When the export is unreadable, its declared EPSG is not `expectEPSG`, or it is missing a field the
|
|
91
|
+
* ingest reads.
|
|
92
|
+
*/
|
|
93
|
+
export async function readZoningSourceIdentity(options) {
|
|
94
|
+
const identity = await readOGRLayerIdentity({
|
|
95
|
+
path: options.exportPath,
|
|
96
|
+
expectEPSG: options.expectEPSG ?? GZT_SOURCE_EPSG,
|
|
97
|
+
context: "zoning ingest",
|
|
98
|
+
areaOfUse: "Ireland",
|
|
99
|
+
});
|
|
100
|
+
const missing = ZONING_SOURCE_FIELDS.filter((field) => field !== "OBJECTID" && !identity.fields.has(field));
|
|
101
|
+
// `-select` on a missing column makes ogr2ogr write an EMPTY column rather than refuse, so a schema change would
|
|
102
|
+
// arrive as a stream of nulls: every local code blank, every plan unnamed, and a well-formed artifact describing
|
|
103
|
+
// nothing. Refused here instead, by name.
|
|
104
|
+
if (missing.length) {
|
|
105
|
+
throw new Error(`zoning ingest: ${options.exportPath} carries no ${missing.join(", ")} column(s) — ogr2ogr writes a missing column as empty rather than refusing, so a schema change would arrive as a stream of blank codes`);
|
|
106
|
+
}
|
|
107
|
+
return { epsg: identity.epsg, featureCount: identity.featureCount, layer: identity.layer, fields: identity.fields };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The `-where` predicate for a bounded chunk or a one-authority smoke run.
|
|
111
|
+
*/
|
|
112
|
+
function whereClause(options) {
|
|
113
|
+
const bounds = [];
|
|
114
|
+
if (options.objectIDFrom !== undefined) {
|
|
115
|
+
bounds.push(`OBJECTID >= ${options.objectIDFrom}`);
|
|
116
|
+
}
|
|
117
|
+
if (options.objectIDTo !== undefined) {
|
|
118
|
+
bounds.push(`OBJECTID <= ${options.objectIDTo}`);
|
|
119
|
+
}
|
|
120
|
+
if (options.authorityCode !== undefined) {
|
|
121
|
+
bounds.push(`LA_CODE = '${options.authorityCode.replaceAll("'", "''")}'`);
|
|
122
|
+
}
|
|
123
|
+
return bounds.length ? ["-where", bounds.join(" AND ")] : [];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* A published value, as a string or null. An EMPTY STRING IS NOT NULL HERE for the local code, which is the one column
|
|
127
|
+
* this layer exists to repeat: a blank one is refused by the ingest rather than stored.
|
|
128
|
+
*/
|
|
129
|
+
function blankToNull(value) {
|
|
130
|
+
if (value === undefined)
|
|
131
|
+
return null;
|
|
132
|
+
return value.length ? value : null;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Stream the export through ogr2ogr as reprojected WKT, checking every vertex against the declared extent.
|
|
136
|
+
*
|
|
137
|
+
* A swapped coordinate order survives a projection check — both axes are still numbers in a plausible range — and shows
|
|
138
|
+
* up here immediately, before 85,330 polygons are written to the wrong side of the planet.
|
|
139
|
+
*
|
|
140
|
+
* @throws {Error} When ogr2ogr fails, when a feature carries no geometry, when a reprojected vertex falls outside the
|
|
141
|
+
* declared extent, or when a feature's rings cannot be resolved into at least one exterior.
|
|
142
|
+
*/
|
|
143
|
+
export async function* readZoningFeatures(options) {
|
|
144
|
+
const [minLon, minLat, maxLon, maxLat] = options.declaredBBox ?? GZT_DECLARED_BBOX;
|
|
145
|
+
const args = [
|
|
146
|
+
"-f",
|
|
147
|
+
"CSV",
|
|
148
|
+
"/vsistdout/",
|
|
149
|
+
"-t_srs",
|
|
150
|
+
"EPSG:4326",
|
|
151
|
+
"-lco",
|
|
152
|
+
"GEOMETRY=AS_WKT",
|
|
153
|
+
"-lco",
|
|
154
|
+
"CREATE_CSVT=NO",
|
|
155
|
+
"-lco",
|
|
156
|
+
`COORDINATE_PRECISION=${COORDINATE_PRECISION}`,
|
|
157
|
+
"-select",
|
|
158
|
+
ZONING_SOURCE_FIELDS.join(","),
|
|
159
|
+
...whereClause(options),
|
|
160
|
+
...(options.limit === undefined ? [] : ["-limit", String(options.limit)]),
|
|
161
|
+
options.exportPath,
|
|
162
|
+
];
|
|
163
|
+
const proc = spawnOGR2OGR(args, "zoning ingest");
|
|
164
|
+
try {
|
|
165
|
+
for await (const row of CSVSpliterator.fromAsync(proc.stdout, {
|
|
166
|
+
mode: "object",
|
|
167
|
+
// Opt-in end-to-end quoting: the WKT column carries commas and spaces on every row, so a reader without it
|
|
168
|
+
// mis-splits every feature into hundreds of columns.
|
|
169
|
+
enableQuoteHandling: true,
|
|
170
|
+
})) {
|
|
171
|
+
const areaID = row.OBJECTID ?? "";
|
|
172
|
+
if (!areaID) {
|
|
173
|
+
throw new Error("zoning ingest: a row carries no OBJECTID — the authority's own key is the artifact's key");
|
|
174
|
+
}
|
|
175
|
+
const wkt = row.WKT;
|
|
176
|
+
if (!wkt) {
|
|
177
|
+
throw new Error(`zoning ingest: feature ${areaID} carries no geometry`);
|
|
178
|
+
}
|
|
179
|
+
const polygons = normalizePolygons(wkt, `feature ${areaID}`);
|
|
180
|
+
assertRingsInsideExtent(polygons, `feature ${areaID}`, { minLon, minLat, maxLon, maxLat }, BBOX_MARGIN_DEGREES, "zoning ingest");
|
|
181
|
+
const localCode = row.ZONE_ORIG ?? "";
|
|
182
|
+
// The local code is what this layer exists to repeat, so a blank one is refused rather than stored: it would read
|
|
183
|
+
// as a zone the authority named nothing, which is not a reading the authority ever makes.
|
|
184
|
+
if (!localCode.trim()) {
|
|
185
|
+
throw new Error(`zoning ingest: feature ${areaID} carries a blank ZONE_ORIG — the authority's own code is the claim, so a blank is refused rather than stored`);
|
|
186
|
+
}
|
|
187
|
+
yield {
|
|
188
|
+
areaID,
|
|
189
|
+
authorityCode: row.LA_CODE ?? "",
|
|
190
|
+
authorityName: row.LA_NAME ?? "",
|
|
191
|
+
planID: row.PLAN_ID ?? "",
|
|
192
|
+
planName: row.PLAN_NAME ?? "",
|
|
193
|
+
planLevel: row.PLAN_LEVEL ?? "",
|
|
194
|
+
planFrom: blankToNull(row.PLAN_FROM),
|
|
195
|
+
planTo: blankToNull(row.PLAN_TO),
|
|
196
|
+
currentPlan: Number(row.CURRENT_PLAN ?? 0),
|
|
197
|
+
// VERBATIM, and deliberately un-trimmed: `Proposed Residential ` carries a trailing space in the source, and
|
|
198
|
+
// five of the 581 distinct strings collide with another only on case or that space.
|
|
199
|
+
localCode,
|
|
200
|
+
localDescription: blankToNull(row.ZONE_DESC),
|
|
201
|
+
localCodeURL: blankToNull(row.ZONE_LINK),
|
|
202
|
+
crosswalkCode: blankToNull(row.ZONE_GZT),
|
|
203
|
+
crosswalkDescription: blankToNull(row.GZT_DESC),
|
|
204
|
+
crosswalkRollup: blankToNull(row.SZO),
|
|
205
|
+
rings: resolveRingRoles(polygons, areaID),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
finally {
|
|
210
|
+
proc.kill();
|
|
211
|
+
}
|
|
212
|
+
await proc.settled;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Parse one WKT geometry into the ring shape the rest of this package works in.
|
|
216
|
+
*
|
|
217
|
+
* @throws {Error} When the geometry is neither a `Polygon` nor a `MultiPolygon`.
|
|
218
|
+
*/
|
|
219
|
+
function normalizePolygons(wkt, label) {
|
|
220
|
+
const geometry = wellKnownGeometryToGeoJSON(wkt);
|
|
221
|
+
return requireArealPolygons(geometry, label, "zoning ingest");
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The bulk export as a feature source — identity read up front, features streamed on demand.
|
|
225
|
+
*/
|
|
226
|
+
export async function createExportFeatureSource(options) {
|
|
227
|
+
const identity = await readZoningSourceIdentity(options);
|
|
228
|
+
return {
|
|
229
|
+
// A RANGE's or an authority's own count is supplied by the caller, because `ogrinfo` reports a layer's total and
|
|
230
|
+
// nothing narrower.
|
|
231
|
+
declaredFeatureCount: options.declaredFeatureCount ??
|
|
232
|
+
(options.limit === undefined ? identity.featureCount : Math.min(options.limit, identity.featureCount)),
|
|
233
|
+
epsg: identity.epsg,
|
|
234
|
+
origin: options.exportPath,
|
|
235
|
+
features: () => readZoningFeatures(options),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=ingest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingest.js","sourceRoot":"","sources":["../../lib/sdk/ingest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA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AC;YAAS,CAAC;QACV,IAAI,CAAC,IAAI,EAAE,CAAA;IACZ,CAAC;IAED,MAAM,IAAI,CAAC,OAAO,CAAA;AACnB,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,GAAW,EAAE,KAAa;IACpD,MAAM,QAAQ,GAAG,0BAA0B,CAAyC,GAAG,CAAC,CAAA;IAExF,OAAO,oBAAoB,CAAC,QAAQ,EAAE,KAAK,EAAE,eAAe,CAAC,CAAA;AAC9D,CAAC;AA4BD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,OAA4B;IAC3E,MAAM,QAAQ,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,CAAA;IAExD,OAAO;QACN,iHAAiH;QACjH,oBAAoB;QACpB,oBAAoB,EACnB,OAAO,CAAC,oBAAoB;YAC5B,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;QACvG,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,MAAM,EAAE,OAAO,CAAC,UAAU;QAC1B,QAAQ,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC;KAC3C,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The index resolution is a MEASUREMENT this layer takes, not a number argued to — and for this subject the
|
|
7
|
+
* inherited size contract's own statistic is not the one that decides it.
|
|
8
|
+
*
|
|
9
|
+
* THE `partial` SHARE CARRIES NO SIGNAL HERE, AND THAT WAS MEASURED. Computed over all 85,330 Irish
|
|
10
|
+
* features, the median zoning polygon is 4,497 m² against an average res-9 cell of 105,333 m²: 95.7% of
|
|
11
|
+
* them are smaller than a res-9 cell, 75.1% smaller than a res-10 cell and 34.5% smaller than a res-11 one.
|
|
12
|
+
* So the `partial` share sits near 100% at every candidate and cannot choose between them.
|
|
13
|
+
*
|
|
14
|
+
* TWO NUMBERS CAN. CANDIDATES PER CELL is what a probe pays — a cell naming eight polygons is eight
|
|
15
|
+
* bounding-box tests and up to eight ray casts — and the POLYFILL-ONLY ZERO-CELL COUNT is how many features
|
|
16
|
+
* the obvious index would have dropped, each of which would read downstream as an absence of zoning. Both
|
|
17
|
+
* are reported per resolution and the `partial` share rides beside them.
|
|
18
|
+
*
|
|
19
|
+
* ONE STREAM, EVERY RESOLUTION. Re-reading the export per candidate costs a full pass each and buys
|
|
20
|
+
* nothing — the classification is per feature, so every candidate index folds the same feature in turn. The
|
|
21
|
+
* cost is memory: each resolution holds its own cell sets, and the finest candidate dominates. A caller that
|
|
22
|
+
* runs out of headroom runs the candidates in separate invocations.
|
|
23
|
+
*/
|
|
24
|
+
import type { ResolutionMeasurementOptions } from "@mailwoman/core/layers";
|
|
25
|
+
import { type CellIndexMeasurement } from "#sdk/cells";
|
|
26
|
+
import { type ZoningIngestOptions } from "#sdk/ingest";
|
|
27
|
+
export interface MeasureResolutionsOptions extends ZoningIngestOptions, ResolutionMeasurementOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Also run a centre-in-polygon polyfill per feature per resolution, to report what a polyfill-only index would have
|
|
30
|
+
* dropped. On by default: it is the column the resolution is chosen on, and its cost is one extra h3 call per
|
|
31
|
+
* feature.
|
|
32
|
+
*/
|
|
33
|
+
measurePolyfill?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface ResolutionMeasurementReport {
|
|
36
|
+
features: number;
|
|
37
|
+
/**
|
|
38
|
+
* The count the source declares for itself. A run whose streamed total differs read a truncated file.
|
|
39
|
+
*/
|
|
40
|
+
declaredFeatureCount: number;
|
|
41
|
+
measurements: CellIndexMeasurement[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Measure every candidate resolution over the real source.
|
|
45
|
+
*
|
|
46
|
+
* @throws {Error} When the streamed feature count does not match the count the source declares. A short read produces a
|
|
47
|
+
* well-formed table describing a smaller country, which is the partial result that must throw.
|
|
48
|
+
*/
|
|
49
|
+
export declare function measureZoningCellResolutions(options: MeasureResolutionsOptions): Promise<ResolutionMeasurementReport>;
|
|
50
|
+
export { formatResolutionRows } from "#sdk/cells";
|
|
51
|
+
//# sourceMappingURL=measure-resolutions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measure-resolutions.d.ts","sourceRoot":"","sources":["../../lib/sdk/measure-resolutions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AAE1E,OAAO,EAA+D,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACnH,OAAO,EAAgD,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEpG,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB,EAAE,4BAA4B;IACnG;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,MAAM,WAAW,2BAA2B;IAC3C,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAA;IAC5B,YAAY,EAAE,oBAAoB,EAAE,CAAA;CACpC;AAID;;;;;GAKG;AACH,wBAAsB,4BAA4B,CACjD,OAAO,EAAE,yBAAyB,GAChC,OAAO,CAAC,2BAA2B,CAAC,CAwCtC;AAED,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The index resolution is a MEASUREMENT this layer takes, not a number argued to — and for this subject the
|
|
7
|
+
* inherited size contract's own statistic is not the one that decides it.
|
|
8
|
+
*
|
|
9
|
+
* THE `partial` SHARE CARRIES NO SIGNAL HERE, AND THAT WAS MEASURED. Computed over all 85,330 Irish
|
|
10
|
+
* features, the median zoning polygon is 4,497 m² against an average res-9 cell of 105,333 m²: 95.7% of
|
|
11
|
+
* them are smaller than a res-9 cell, 75.1% smaller than a res-10 cell and 34.5% smaller than a res-11 one.
|
|
12
|
+
* So the `partial` share sits near 100% at every candidate and cannot choose between them.
|
|
13
|
+
*
|
|
14
|
+
* TWO NUMBERS CAN. CANDIDATES PER CELL is what a probe pays — a cell naming eight polygons is eight
|
|
15
|
+
* bounding-box tests and up to eight ray casts — and the POLYFILL-ONLY ZERO-CELL COUNT is how many features
|
|
16
|
+
* the obvious index would have dropped, each of which would read downstream as an absence of zoning. Both
|
|
17
|
+
* are reported per resolution and the `partial` share rides beside them.
|
|
18
|
+
*
|
|
19
|
+
* ONE STREAM, EVERY RESOLUTION. Re-reading the export per candidate costs a full pass each and buys
|
|
20
|
+
* nothing — the classification is per feature, so every candidate index folds the same feature in turn. The
|
|
21
|
+
* cost is memory: each resolution holds its own cell sets, and the finest candidate dominates. A caller that
|
|
22
|
+
* runs out of headroom runs the candidates in separate invocations.
|
|
23
|
+
*/
|
|
24
|
+
import { polyfillFindsNothing, ZoningCellIndex, classifyFeatureCells } from "#sdk/cells";
|
|
25
|
+
import { readZoningFeatures, readZoningSourceIdentity } from "#sdk/ingest";
|
|
26
|
+
const DEFAULT_PROGRESS_EVERY = 5000;
|
|
27
|
+
/**
|
|
28
|
+
* Measure every candidate resolution over the real source.
|
|
29
|
+
*
|
|
30
|
+
* @throws {Error} When the streamed feature count does not match the count the source declares. A short read produces a
|
|
31
|
+
* well-formed table describing a smaller country, which is the partial result that must throw.
|
|
32
|
+
*/
|
|
33
|
+
export async function measureZoningCellResolutions(options) {
|
|
34
|
+
const identity = await readZoningSourceIdentity(options);
|
|
35
|
+
const indexes = options.resolutions.map((resolution) => new ZoningCellIndex(resolution));
|
|
36
|
+
const progressEvery = options.progressEvery ?? DEFAULT_PROGRESS_EVERY;
|
|
37
|
+
const measurePolyfill = options.measurePolyfill ?? true;
|
|
38
|
+
let features = 0;
|
|
39
|
+
for await (const feature of readZoningFeatures(options)) {
|
|
40
|
+
for (const index of indexes) {
|
|
41
|
+
index.add(classifyFeatureCells(feature.rings.polygons, index.resolution, feature.areaID, "zoning cells"));
|
|
42
|
+
if (measurePolyfill) {
|
|
43
|
+
index.addPolyfillProbe(polyfillFindsNothing(feature.rings.polygons, index.resolution));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
features++;
|
|
47
|
+
if (features % progressEvery === 0) {
|
|
48
|
+
options.onProgress?.(`${features.toLocaleString()} features classified`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// A RANGE or an authority selector narrows the population on purpose, so the declared total is only a check on a whole
|
|
52
|
+
// pass. Narrowed runs report what they read and assert nothing about it.
|
|
53
|
+
const narrowed = options.limit !== undefined || options.authorityCode !== undefined || options.objectIDFrom !== undefined;
|
|
54
|
+
if (!narrowed && features !== identity.featureCount) {
|
|
55
|
+
throw new Error(`zoning measure: streamed ${features} features, the source declares ${identity.featureCount} — a short read reports a smaller country rather than failing`);
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
features,
|
|
59
|
+
declaredFeatureCount: identity.featureCount,
|
|
60
|
+
measurements: indexes.map((index) => index.finish()),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export { formatResolutionRows } from "#sdk/cells";
|
|
64
|
+
//# sourceMappingURL=measure-resolutions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measure-resolutions.js","sourceRoot":"","sources":["../../lib/sdk/measure-resolutions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,EAAE,oBAAoB,EA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;IAED,uHAAuH;IACvH,yEAAyE;IACzE,MAAM,QAAQ,GACb,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,CAAA;IAEzG,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,QAAQ,CAAC,YAAY,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CACd,4BAA4B,QAAQ,kCAAkC,QAAQ,CAAC,YAAY,+DAA+D,CAC1J,CAAA;IACF,CAAC;IAED,OAAO;QACN,QAAQ;QACR,oBAAoB,EAAE,QAAQ,CAAC,YAAY;QAC3C,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;KACpD,CAAA;AACF,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,176 @@
|
|
|
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 { type ZoningReading } from "#index";
|
|
37
|
+
import type { GZTClient } from "#sdk/client";
|
|
38
|
+
/**
|
|
39
|
+
* One point, both verdicts, and whether they agree.
|
|
40
|
+
*/
|
|
41
|
+
export interface AgreementRow {
|
|
42
|
+
label: string;
|
|
43
|
+
latitude: number;
|
|
44
|
+
longitude: number;
|
|
45
|
+
/**
|
|
46
|
+
* The artifact's answer.
|
|
47
|
+
*/
|
|
48
|
+
local: ZoningReading;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the service's own geometry places the point inside a zoning polygon.
|
|
51
|
+
*/
|
|
52
|
+
serviceInside: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The local code the SERVICE reports at the point, where it reports one. Compared verbatim against the artifact's,
|
|
55
|
+
* because carrying the code verbatim is what this layer is for: two paths that agree on containment and disagree on
|
|
56
|
+
* the code would be a silent vocabulary defect.
|
|
57
|
+
*/
|
|
58
|
+
serviceLocalCode?: string;
|
|
59
|
+
outcome: "agree" | "disagree" | "boundary_tolerance";
|
|
60
|
+
/**
|
|
61
|
+
* Metres from the point to the nearest EDGE of any polygon the service returned nearby.
|
|
62
|
+
*
|
|
63
|
+
* Carried on every row rather than only the tolerated ones, because it is what separates a real defect from the two
|
|
64
|
+
* channels rendering the same edge differently — and a receipt that omits it forces a re-run. `undefined` means the
|
|
65
|
+
* service returned no polygon at all near the point.
|
|
66
|
+
*/
|
|
67
|
+
nearestEdgeMetres?: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The negative half: a point this product's publication does not reach.
|
|
71
|
+
*/
|
|
72
|
+
export interface OutsideRow {
|
|
73
|
+
label: string;
|
|
74
|
+
latitude: number;
|
|
75
|
+
longitude: number;
|
|
76
|
+
kind: string;
|
|
77
|
+
designations: number;
|
|
78
|
+
/**
|
|
79
|
+
* True when the artifact answered `unknown` with no designation — the only acceptable reading here.
|
|
80
|
+
*/
|
|
81
|
+
passed: boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface VerifyZoningResult {
|
|
84
|
+
agreement: AgreementRow[];
|
|
85
|
+
agreed: number;
|
|
86
|
+
disagreed: number;
|
|
87
|
+
boundaryTolerance: number;
|
|
88
|
+
/**
|
|
89
|
+
* Points where both paths placed the location inside a zone and the local codes differed.
|
|
90
|
+
*/
|
|
91
|
+
codeMismatches: number;
|
|
92
|
+
outside: OutsideRow[];
|
|
93
|
+
outsidePassed: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Points this product's publication does not reach, named. Each is a place, not a bare pair of numbers: a coordinate a
|
|
97
|
+
* reader cannot name is a coordinate nobody can check.
|
|
98
|
+
*
|
|
99
|
+
* TWO POPULATIONS, AND BOTH ARE LOAD-BEARING. The Donegal points are the case this layer's coverage posture exists for
|
|
100
|
+
* — the Department has not published that authority's zoning, and a builder that read absence as "unrestricted" would
|
|
101
|
+
* answer them confidently. The Northern Irish points confirm the artifact is clipped to the Republic rather than to the
|
|
102
|
+
* island: zoning there is a different jurisdiction's instrument under a different planning act.
|
|
103
|
+
*/
|
|
104
|
+
export declare const OUTSIDE_PUBLICATION_POINTS: ReadonlyArray<{
|
|
105
|
+
label: string;
|
|
106
|
+
latitude: number;
|
|
107
|
+
longitude: number;
|
|
108
|
+
}>;
|
|
109
|
+
/**
|
|
110
|
+
* One feature as the service publishes it — the only shape the comparison reads.
|
|
111
|
+
*/
|
|
112
|
+
export interface ServiceFeature {
|
|
113
|
+
properties?: Record<string, unknown>;
|
|
114
|
+
geometry?: {
|
|
115
|
+
type: string;
|
|
116
|
+
coordinates: unknown;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The ONE call the verification makes against the service: the features it publishes near a point.
|
|
121
|
+
*
|
|
122
|
+
* A function rather than the client, and that is what makes the check's own logic testable. The comparison's value is
|
|
123
|
+
* that it decides which of three outcomes a point gets; expressed against an HTTP client it could only ever be watched
|
|
124
|
+
* on a live run, and a scripted reader lets those decisions be pinned. {@link createServiceReader} builds the real
|
|
125
|
+
* one.
|
|
126
|
+
*/
|
|
127
|
+
export type ServiceFeatureReader = (latitude: number, longitude: number) => Promise<ServiceFeature[]>;
|
|
128
|
+
/**
|
|
129
|
+
* The reader the live check uses: a bounding-box query against the Department's own service.
|
|
130
|
+
*
|
|
131
|
+
* The service answers a BOX, not a point, so this returns what it published nearby and the containment decision is made
|
|
132
|
+
* in {@link readServiceContainment} against those rings — comparing the artifact's verdict against a bare "the service
|
|
133
|
+
* returned something here" would pass on any polygon within eleven metres.
|
|
134
|
+
*/
|
|
135
|
+
export declare function createServiceReader(client: Pick<GZTClient, "readFeaturesNear">): ServiceFeatureReader;
|
|
136
|
+
export interface VerifyZoningOptions {
|
|
137
|
+
databasePath: string;
|
|
138
|
+
readServiceFeatures: ServiceFeatureReader;
|
|
139
|
+
/**
|
|
140
|
+
* Points to re-ask the service about. A caller samples them from the artifact — see {@link sampleAgreementPoints}.
|
|
141
|
+
*/
|
|
142
|
+
points: ReadonlyArray<{
|
|
143
|
+
label: string;
|
|
144
|
+
latitude: number;
|
|
145
|
+
longitude: number;
|
|
146
|
+
localCode?: string;
|
|
147
|
+
}>;
|
|
148
|
+
outsidePoints?: ReadonlyArray<{
|
|
149
|
+
label: string;
|
|
150
|
+
latitude: number;
|
|
151
|
+
longitude: number;
|
|
152
|
+
}>;
|
|
153
|
+
onProgress?: (message: string) => void;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Run both halves.
|
|
157
|
+
*/
|
|
158
|
+
export declare function verifyZoningDatabase(options: VerifyZoningOptions): Promise<VerifyZoningResult>;
|
|
159
|
+
/**
|
|
160
|
+
* Draw a reproducible sample of points from the artifact — interior points of stored polygons, spread across
|
|
161
|
+
* authorities.
|
|
162
|
+
*
|
|
163
|
+
* SPREAD ACROSS AUTHORITIES RATHER THAN DRAWN FROM ONE, because 30 local authorities publish 581 distinct local codes
|
|
164
|
+
* between them and a sample from one would verify one authority's conversion while reporting on all of them. The stride
|
|
165
|
+
* discipline — keys chosen before any geometry is read, deterministic rather than random — is
|
|
166
|
+
* `strideSampleInteriorPoints`'s.
|
|
167
|
+
*/
|
|
168
|
+
export declare function sampleAgreementPoints(databasePath: string, options?: {
|
|
169
|
+
count?: number;
|
|
170
|
+
}): Array<{
|
|
171
|
+
label: string;
|
|
172
|
+
latitude: number;
|
|
173
|
+
longitude: number;
|
|
174
|
+
localCode: string;
|
|
175
|
+
}>;
|
|
176
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../lib/sdk/verify.ts"],"names":[],"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