@mailwoman/zoning 10.0.0 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +169 -163
  2. package/lib/index.ts +103 -135
  3. package/lib/paths.ts +24 -0
  4. package/lib/ring-roles.ts +30 -71
  5. package/lib/rings.ts +2 -13
  6. package/lib/schema.ts +98 -139
  7. package/lib/vocabulary.ts +52 -130
  8. package/out/index.d.ts +81 -101
  9. package/out/index.d.ts.map +1 -1
  10. package/out/index.js +37 -96
  11. package/out/index.js.map +1 -1
  12. package/out/paths.d.ts +19 -0
  13. package/out/paths.d.ts.map +1 -0
  14. package/out/paths.js +21 -0
  15. package/out/paths.js.map +1 -0
  16. package/out/ring-roles.d.ts +16 -50
  17. package/out/ring-roles.d.ts.map +1 -1
  18. package/out/ring-roles.js +18 -51
  19. package/out/ring-roles.js.map +1 -1
  20. package/out/rings.d.ts +2 -13
  21. package/out/rings.d.ts.map +1 -1
  22. package/out/rings.js +2 -13
  23. package/out/rings.js.map +1 -1
  24. package/out/schema.d.ts +90 -132
  25. package/out/schema.d.ts.map +1 -1
  26. package/out/schema.js +17 -45
  27. package/out/schema.js.map +1 -1
  28. package/out/sdk/build-zoning.d.ts +58 -111
  29. package/out/sdk/build-zoning.d.ts.map +1 -1
  30. package/out/sdk/build-zoning.js +50 -139
  31. package/out/sdk/build-zoning.js.map +1 -1
  32. package/out/sdk/cells.d.ts +21 -62
  33. package/out/sdk/cells.d.ts.map +1 -1
  34. package/out/sdk/cells.js +15 -52
  35. package/out/sdk/cells.js.map +1 -1
  36. package/out/sdk/client.d.ts +23 -67
  37. package/out/sdk/client.d.ts.map +1 -1
  38. package/out/sdk/client.js +29 -77
  39. package/out/sdk/client.js.map +1 -1
  40. package/out/sdk/download.d.ts +7 -27
  41. package/out/sdk/download.d.ts.map +1 -1
  42. package/out/sdk/download.js +8 -28
  43. package/out/sdk/download.js.map +1 -1
  44. package/out/sdk/ingest/chunk.d.ts +19 -43
  45. package/out/sdk/ingest/chunk.d.ts.map +1 -1
  46. package/out/sdk/ingest/chunk.js +19 -52
  47. package/out/sdk/ingest/chunk.js.map +1 -1
  48. package/out/sdk/ingest/worker.d.ts +9 -0
  49. package/out/sdk/ingest/worker.d.ts.map +1 -0
  50. package/out/{scripts/ingest-chunk.js → sdk/ingest/worker.js} +8 -10
  51. package/out/sdk/ingest/worker.js.map +1 -0
  52. package/out/sdk/ingest.d.ts +152 -0
  53. package/out/sdk/ingest.d.ts.map +1 -0
  54. package/out/sdk/ingest.js +200 -0
  55. package/out/sdk/ingest.js.map +1 -0
  56. package/out/sdk/measure-resolutions.d.ts +7 -34
  57. package/out/sdk/measure-resolutions.d.ts.map +1 -1
  58. package/out/sdk/measure-resolutions.js +5 -23
  59. package/out/sdk/measure-resolutions.js.map +1 -1
  60. package/out/sdk/test-kit.d.ts +75 -0
  61. package/out/sdk/test-kit.d.ts.map +1 -0
  62. package/out/{test-kit.js → sdk/test-kit.js} +20 -43
  63. package/out/sdk/test-kit.js.map +1 -0
  64. package/out/sdk/verify.d.ts +79 -80
  65. package/out/sdk/verify.d.ts.map +1 -1
  66. package/out/sdk/verify.js +83 -70
  67. package/out/sdk/verify.js.map +1 -1
  68. package/out/vocabulary.d.ts +52 -120
  69. package/out/vocabulary.d.ts.map +1 -1
  70. package/out/vocabulary.js +47 -125
  71. package/out/vocabulary.js.map +1 -1
  72. package/package.json +38 -162
  73. package/{lib/sdk → sdk}/build-zoning.ts +102 -188
  74. package/{lib/sdk → sdk}/cells.ts +27 -66
  75. package/{lib/sdk → sdk}/client.ts +34 -82
  76. package/sdk/download.ts +58 -0
  77. package/{lib/sdk → sdk}/ingest/chunk.ts +36 -65
  78. package/{lib/scripts/ingest-chunk.ts → sdk/ingest/worker.ts} +7 -9
  79. package/sdk/ingest.ts +354 -0
  80. package/sdk/measure-resolutions.ts +72 -0
  81. package/{lib → sdk}/test-kit.ts +21 -44
  82. package/sdk/verify.ts +367 -0
  83. package/lib/sdk/download.ts +0 -78
  84. package/lib/sdk/index.ts +0 -15
  85. package/lib/sdk/ingest/index.ts +0 -393
  86. package/lib/sdk/measure-resolutions.ts +0 -101
  87. package/lib/sdk/verify.ts +0 -357
  88. package/out/scripts/ingest-chunk.d.ts +0 -11
  89. package/out/scripts/ingest-chunk.d.ts.map +0 -1
  90. package/out/scripts/ingest-chunk.js.map +0 -1
  91. package/out/sdk/index.d.ts +0 -15
  92. package/out/sdk/index.d.ts.map +0 -1
  93. package/out/sdk/index.js +0 -15
  94. package/out/sdk/index.js.map +0 -1
  95. package/out/sdk/ingest/index.d.ts +0 -185
  96. package/out/sdk/ingest/index.d.ts.map +0 -1
  97. package/out/sdk/ingest/index.js +0 -232
  98. package/out/sdk/ingest/index.js.map +0 -1
  99. package/out/test-kit.d.ts +0 -96
  100. package/out/test-kit.d.ts.map +0 -1
  101. package/out/test-kit.js.map +0 -1
package/lib/sdk/verify.ts DELETED
@@ -1,357 +0,0 @@
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
-
37
- import {
38
- nearestRingEdgeMetres,
39
- pointInEncodedRings,
40
- strideSampleInteriorPoints,
41
- encodeRings,
42
- type MultiPolygonRings,
43
- type PolygonRings,
44
- } from "@mailwoman/spatial"
45
- import { DatabaseClient } from "@mailwoman/sqlite/client"
46
-
47
- import { ZoningLookup, ZoningReadingKind, type ZoningReading } from "#index"
48
- import { resolveRingRoles } from "#rings"
49
- import type { ZoningDatabase } from "#schema"
50
- import type { GZTClient } from "#sdk/client"
51
-
52
- /**
53
- * One point, both verdicts, and whether they agree.
54
- */
55
- export interface AgreementRow {
56
- label: string
57
- latitude: number
58
- longitude: number
59
- /**
60
- * The artifact's answer.
61
- */
62
- local: ZoningReading
63
- /**
64
- * Whether the service's own geometry places the point inside a zoning polygon.
65
- */
66
- serviceInside: boolean
67
- /**
68
- * The local code the SERVICE reports at the point, where it reports one. Compared verbatim against the artifact's,
69
- * because carrying the code verbatim is what this layer is for: two paths that agree on containment and disagree on
70
- * the code would be a silent vocabulary defect.
71
- */
72
- serviceLocalCode?: string
73
- outcome: "agree" | "disagree" | "boundary_tolerance"
74
- /**
75
- * Metres from the point to the nearest EDGE of any polygon the service returned nearby.
76
- *
77
- * Carried on every row rather than only the tolerated ones, because it is what separates a real defect from the two
78
- * channels rendering the same edge differently — and a receipt that omits it forces a re-run. `undefined` means the
79
- * service returned no polygon at all near the point.
80
- */
81
- nearestEdgeMetres?: number
82
- }
83
-
84
- /**
85
- * The negative half: a point this product's publication does not reach.
86
- */
87
- export interface OutsideRow {
88
- label: string
89
- latitude: number
90
- longitude: number
91
- kind: string
92
- designations: number
93
- /**
94
- * True when the artifact answered `unknown` with no designation — the only acceptable reading here.
95
- */
96
- passed: boolean
97
- }
98
-
99
- export interface VerifyZoningResult {
100
- agreement: AgreementRow[]
101
- agreed: number
102
- disagreed: number
103
- boundaryTolerance: number
104
- /**
105
- * Points where both paths placed the location inside a zone and the local codes differed.
106
- */
107
- codeMismatches: number
108
- outside: OutsideRow[]
109
- outsidePassed: number
110
- }
111
-
112
- /**
113
- * Points this product's publication does not reach, named. Each is a place, not a bare pair of numbers: a coordinate a
114
- * reader cannot name is a coordinate nobody can check.
115
- *
116
- * TWO POPULATIONS, AND BOTH ARE LOAD-BEARING. The Donegal points are the case this layer's coverage posture exists for
117
- * — the Department has not published that authority's zoning, and a builder that read absence as "unrestricted" would
118
- * answer them confidently. The Northern Irish points confirm the artifact is clipped to the Republic rather than to the
119
- * island: zoning there is a different jurisdiction's instrument under a different planning act.
120
- */
121
- export const OUTSIDE_PUBLICATION_POINTS: ReadonlyArray<{ label: string; latitude: number; longitude: number }> = [
122
- { label: "Letterkenny town centre, Donegal", latitude: 54.9503, longitude: -7.7345 },
123
- { label: "Buncrana, Donegal", latitude: 55.1367, longitude: -7.4561 },
124
- { label: "Donegal Town", latitude: 54.6538, longitude: -8.1096 },
125
- { label: "Belfast city centre, Northern Ireland", latitude: 54.5973, longitude: -5.9301 },
126
- { label: "Derry city centre, Northern Ireland", latitude: 54.9966, longitude: -7.3086 },
127
- { label: "Enniskillen, Northern Ireland", latitude: 54.3438, longitude: -7.6316 },
128
- ]
129
-
130
- /**
131
- * Half-width of the bounding box the service is asked for, in degrees. About 11 m at this latitude — wide enough that a
132
- * polygon containing the point is certainly returned, narrow enough that the response stays small.
133
- */
134
- const PROBE_HALF_WIDTH_DEGREES = 0.0001
135
-
136
- /**
137
- * How close to a service-polygon edge a disagreement is attributed to the channels' differing coordinate precision
138
- * rather than to the conversion.
139
- *
140
- * Half a metre. The two channels render the same edge from the same source coordinates through different rounding, so a
141
- * point between the two renderings lands on opposite sides; half a metre is far below any real zoning boundary and far
142
- * above the rounding difference.
143
- */
144
- const BOUNDARY_TOLERANCE_METRES = 0.5
145
-
146
- /**
147
- * One feature as the service publishes it — the only shape the comparison reads.
148
- */
149
- export interface ServiceFeature {
150
- properties?: Record<string, unknown>
151
- geometry?: { type: string; coordinates: unknown }
152
- }
153
-
154
- /**
155
- * The ONE call the verification makes against the service: the features it publishes near a point.
156
- *
157
- * A function rather than the client, and that is what makes the check's own logic testable. The comparison's value is
158
- * that it decides which of three outcomes a point gets; expressed against an HTTP client it could only ever be watched
159
- * on a live run, and a scripted reader lets those decisions be pinned. {@link createServiceReader} builds the real
160
- * one.
161
- */
162
- export type ServiceFeatureReader = (latitude: number, longitude: number) => Promise<ServiceFeature[]>
163
-
164
- /**
165
- * The reader the live check uses: a bounding-box query against the Department's own service.
166
- *
167
- * The service answers a BOX, not a point, so this returns what it published nearby and the containment decision is made
168
- * in {@link readServiceContainment} against those rings — comparing the artifact's verdict against a bare "the service
169
- * returned something here" would pass on any polygon within eleven metres.
170
- */
171
- export function createServiceReader(client: Pick<GZTClient, "readFeaturesNear">): ServiceFeatureReader {
172
- return async (latitude, longitude) => client.readFeaturesNear(latitude, longitude, PROBE_HALF_WIDTH_DEGREES)
173
- }
174
-
175
- export interface VerifyZoningOptions {
176
- databasePath: string
177
- readServiceFeatures: ServiceFeatureReader
178
- /**
179
- * Points to re-ask the service about. A caller samples them from the artifact — see {@link sampleAgreementPoints}.
180
- */
181
- points: ReadonlyArray<{ label: string; latitude: number; longitude: number; localCode?: string }>
182
- outsidePoints?: ReadonlyArray<{ label: string; latitude: number; longitude: number }>
183
- onProgress?: (message: string) => void
184
- }
185
-
186
- /**
187
- * Run both halves.
188
- */
189
- export async function verifyZoningDatabase(options: VerifyZoningOptions): Promise<VerifyZoningResult> {
190
- const lookup = new ZoningLookup({ databasePath: options.databasePath })
191
-
192
- try {
193
- const agreement: AgreementRow[] = []
194
-
195
- for (const point of options.points) {
196
- const local = lookup.lookup(point.latitude, point.longitude)
197
- const service = await readServiceContainment(options.readServiceFeatures, point.latitude, point.longitude)
198
- const localInside = local.kind === ZoningReadingKind.Designated
199
- const nearEdge = service.nearestEdgeMetres !== undefined && service.nearestEdgeMetres <= BOUNDARY_TOLERANCE_METRES
200
-
201
- agreement.push({
202
- label: point.label,
203
- latitude: point.latitude,
204
- longitude: point.longitude,
205
- local,
206
- serviceInside: service.inside,
207
- ...(service.localCode === undefined ? {} : { serviceLocalCode: service.localCode }),
208
- outcome: localInside === service.inside ? "agree" : nearEdge ? "boundary_tolerance" : "disagree",
209
- ...(service.nearestEdgeMetres === undefined ? {} : { nearestEdgeMetres: service.nearestEdgeMetres }),
210
- })
211
-
212
- options.onProgress?.(`${agreement.length}/${options.points.length} points compared`)
213
- }
214
-
215
- const outside: OutsideRow[] = []
216
-
217
- for (const point of options.outsidePoints ?? OUTSIDE_PUBLICATION_POINTS) {
218
- const reading = lookup.lookup(point.latitude, point.longitude)
219
-
220
- outside.push({
221
- label: point.label,
222
- latitude: point.latitude,
223
- longitude: point.longitude,
224
- kind: reading.kind,
225
- designations: reading.designations.length,
226
- passed: reading.kind === ZoningReadingKind.Unknown && reading.designations.length === 0,
227
- })
228
- }
229
-
230
- return {
231
- agreement,
232
- agreed: agreement.filter((row) => row.outcome === "agree").length,
233
- disagreed: agreement.filter((row) => row.outcome === "disagree").length,
234
- boundaryTolerance: agreement.filter((row) => row.outcome === "boundary_tolerance").length,
235
- codeMismatches: agreement.filter(
236
- (row) =>
237
- row.outcome === "agree" &&
238
- row.serviceInside &&
239
- row.serviceLocalCode !== undefined &&
240
- !row.local.designations.some((designation) => designation.localCode === row.serviceLocalCode)
241
- ).length,
242
- outside,
243
- outsidePassed: outside.filter((row) => row.passed).length,
244
- }
245
- } finally {
246
- lookup[Symbol.dispose]()
247
- }
248
- }
249
-
250
- /**
251
- * Whether the SERVICE's own geometry contains the point, decided here with the same ring-role resolution and the same
252
- * even-odd rule the artifact's reader uses — so what is compared is a verdict against a verdict.
253
- */
254
- async function readServiceContainment(
255
- readServiceFeatures: ServiceFeatureReader,
256
- latitude: number,
257
- longitude: number
258
- ): Promise<{ inside: boolean; localCode?: string; nearestEdgeMetres?: number }> {
259
- const features = await readServiceFeatures(latitude, longitude)
260
-
261
- let nearest = Infinity
262
- let inside = false
263
- let localCode: string | undefined
264
-
265
- for (const feature of features) {
266
- const geometry = feature.geometry
267
-
268
- if (!geometry) continue
269
-
270
- const raw: MultiPolygonRings =
271
- geometry.type === "MultiPolygon"
272
- ? (geometry.coordinates as MultiPolygonRings)
273
- : [geometry.coordinates as PolygonRings]
274
-
275
- const distance = nearestRingEdgeMetres(geometry, longitude, latitude)
276
-
277
- if (distance < nearest) {
278
- nearest = distance
279
- }
280
-
281
- // THE SERVICE'S RINGS GET THE SAME ROLE RESOLUTION THE INGEST GAVE THE ARCHIVE'S. The publisher uses one convention on
282
- // both channels, so reading this side as nested GeoJSON would answer "inside" for a point in a hole and report the
283
- // artifact as wrong at exactly the locations the hole handling exists for.
284
- const resolved = resolveRingRoles(raw, `service feature near ${latitude},${longitude}`)
285
-
286
- // ENCODED AND RE-READ RATHER THAN RAY-CAST DIRECTLY, deliberately: the artifact answers through
287
- // `pointInEncodedRings`, and running the service's geometry through a different predicate would compare two answers
288
- // that were never asked the same question.
289
- if (pointInEncodedRings(encodeRings(resolved.polygons), longitude, latitude)) {
290
- inside = true
291
-
292
- const code = feature.properties?.ZONE_ORIG
293
-
294
- if (typeof code === "string" && localCode === undefined) {
295
- localCode = code
296
- }
297
- }
298
- }
299
-
300
- return {
301
- inside,
302
- ...(localCode === undefined ? {} : { localCode }),
303
- ...(Number.isFinite(nearest) ? { nearestEdgeMetres: nearest } : {}),
304
- }
305
- }
306
-
307
- /**
308
- * Draw a reproducible sample of points from the artifact — interior points of stored polygons, spread across
309
- * authorities.
310
- *
311
- * SPREAD ACROSS AUTHORITIES RATHER THAN DRAWN FROM ONE, because 30 local authorities publish 581 distinct local codes
312
- * between them and a sample from one would verify one authority's conversion while reporting on all of them. The stride
313
- * discipline — keys chosen before any geometry is read, deterministic rather than random — is
314
- * `strideSampleInteriorPoints`'s.
315
- */
316
- export function sampleAgreementPoints(
317
- databasePath: string,
318
- options: { count?: number } = {}
319
- ): Array<{ label: string; latitude: number; longitude: number; localCode: string }> {
320
- const count = options.count ?? 48
321
- using database = new DatabaseClient<ZoningDatabase>(databasePath, { readOnly: true })
322
-
323
- // ORDERED BY THE AUTHORITY FIRST, so a stride walks across the 30 of them rather than down one. A stride over
324
- // `area_id` alone would follow the publisher's own feature numbering, which is grouped by authority — and would draw
325
- // every sample from whichever authorities happen to sit on the stride.
326
- const areaIDs = (
327
- database.prepare("SELECT area_id FROM zoning_area ORDER BY jurisdiction_id, area_id").all() as Array<{
328
- area_id: string
329
- }>
330
- ).map((row) => row.area_id)
331
-
332
- const selectArea = database.prepare(
333
- "SELECT area_id, jurisdiction_id, local_code, min_lat, min_lon, max_lat, max_lon, rings FROM zoning_area WHERE area_id = ?"
334
- )
335
-
336
- return strideSampleInteriorPoints(areaIDs, count, {
337
- fetch: (key) =>
338
- selectArea.get(key) as
339
- | {
340
- area_id: string
341
- jurisdiction_id: string
342
- local_code: string
343
- min_lat: number
344
- min_lon: number
345
- max_lat: number
346
- max_lon: number
347
- rings: Uint8Array
348
- }
349
- | undefined,
350
- gridSteps: 17,
351
- toPoint: (area, interior) => ({
352
- label: `${area.jurisdiction_id} ${JSON.stringify(area.local_code)} polygon ${area.area_id}`,
353
- localCode: area.local_code,
354
- ...interior,
355
- }),
356
- })
357
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * One chunk of the zoning ingest, as its own process — spawned by `buildZoningDatabase`, never run by
7
- * hand. The process boundary and the stdout contract live with `runIngestChunkScript`; what stays here is
8
- * only this product's flags and its feature-source constructor.
9
- */
10
- export {};
11
- //# sourceMappingURL=ingest-chunk.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ingest-chunk.d.ts","sourceRoot":"","sources":["../../lib/scripts/ingest-chunk.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ingest-chunk.js","sourceRoot":"","sources":["../../lib/scripts/ingest-chunk.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAA;AAIxG,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAE7D,MAAM,oBAAoB,CAAC;IAC1B,OAAO,EAAE,qBAAqB;IAC9B,OAAO,EAAE;QACR,GAAG,kBAAkB;QACrB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACpC,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAClC;IACD,GAAG,EAAE,KAAK,EAAE,QAAwC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CACtE,iBAAiB,CAAC,QAAQ,EAAE;QAC3B,MAAM,EAAE,MAAM,yBAAyB,CAAC;YACvC,UAAU,EAAE,gBAAgB,CAAC,qBAAqB,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;YAC5E,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC;YACrG,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC;YAC/F,8GAA8G;YAC9G,iGAAiG;YACjG,oBAAoB,EAAE,CAAC;SACvB,CAAC;QACF,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;QAC5C,UAAU,EAAE,KAAK,CAAC,UAAU;KAC5B,CAAC;CACH,CAAC,CAAA"}
@@ -1,15 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- * @file The acquisition + build surface for the Irish zoning layer. The READER is the package root.
6
- */
7
- export * from "#sdk/build-zoning";
8
- export * from "#sdk/cells";
9
- export * from "#sdk/client";
10
- export * from "#sdk/download";
11
- export * from "#sdk/ingest/index";
12
- export * from "#sdk/ingest/chunk";
13
- export * from "#sdk/measure-resolutions";
14
- export * from "#sdk/verify";
15
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/sdk/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AACxC,cAAc,aAAa,CAAA"}
package/out/sdk/index.js DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- * @file The acquisition + build surface for the Irish zoning layer. The READER is the package root.
6
- */
7
- export * from "#sdk/build-zoning";
8
- export * from "#sdk/cells";
9
- export * from "#sdk/client";
10
- export * from "#sdk/download";
11
- export * from "#sdk/ingest/index";
12
- export * from "#sdk/ingest/chunk";
13
- export * from "#sdk/measure-resolutions";
14
- export * from "#sdk/verify";
15
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/sdk/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AACxC,cAAc,aAAa,CAAA"}
@@ -1,185 +0,0 @@
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 { type ResolvedRingRoles } from "#rings";
43
- /**
44
- * One zoning feature, reprojected to WGS84 with its hole roles resolved.
45
- */
46
- export interface ZoningSourceFeature {
47
- /**
48
- * The authority's own `OBJECTID`, as a string.
49
- */
50
- areaID: string;
51
- /**
52
- * `LA_CODE`, verbatim — `Fl` for Fingal, and never repaired.
53
- */
54
- authorityCode: string;
55
- authorityName: string;
56
- planID: string;
57
- planName: string;
58
- planLevel: string;
59
- planFrom: string | null;
60
- planTo: string | null;
61
- currentPlan: number;
62
- /**
63
- * `ZONE_ORIG`, verbatim, including case and any trailing space.
64
- */
65
- localCode: string;
66
- localDescription: string | null;
67
- localCodeURL: string | null;
68
- /**
69
- * `ZONE_GZT` — the Department's national generic type for THIS polygon.
70
- */
71
- crosswalkCode: string | null;
72
- crosswalkDescription: string | null;
73
- /**
74
- * `SZO` — the coarser national code, as published.
75
- */
76
- crosswalkRollup: string | null;
77
- /**
78
- * The rings, with hole roles resolved from orientation, plus the receipt of that resolution.
79
- */
80
- rings: ResolvedRingRoles;
81
- }
82
- /**
83
- * What the ingest was pointed at.
84
- */
85
- export interface ZoningIngestOptions {
86
- /**
87
- * Path to the bulk GeoJSON export.
88
- */
89
- exportPath: string;
90
- /**
91
- * Stop after this many features — the fixtures and smoke rungs use it; a full build does not set it.
92
- */
93
- limit?: number;
94
- /**
95
- * The EPSG code the source must declare. A source declaring anything else is a product change, not a variation to
96
- * absorb.
97
- */
98
- expectEPSG?: number;
99
- /**
100
- * The extent every reprojected vertex must land inside. Defaults to the Department's own declaration.
101
- */
102
- declaredBBox?: readonly [number, number, number, number];
103
- /**
104
- * Read only the authority's feature ids in `[objectIDFrom, objectIDTo]`, inclusive.
105
- *
106
- * This is what makes a bounded build possible: h3's WASM heap cannot be reset from JavaScript, so the classification
107
- * runs one child process per range of the authority's OWN ids. Ranges rather than an offset because `OBJECTID` is the
108
- * source's stable key — a range names the same features on every run, which an offset into a result set does not.
109
- *
110
- * A NARROWER RANGE COSTS A WHOLE PASS. The source is one GeoJSON document rather than an indexed store, so ogr2ogr
111
- * scans all 247 MB for every range. The national set fits inside one chunk at the default bound, so that cost is not
112
- * paid on a full build.
113
- */
114
- objectIDFrom?: number;
115
- objectIDTo?: number;
116
- /**
117
- * Restrict to one local authority's own `LA_CODE` — the smoke rung.
118
- */
119
- authorityCode?: string;
120
- }
121
- /**
122
- * What the source declares about itself, read before any feature is.
123
- */
124
- export interface ZoningSourceIdentity {
125
- epsg: number;
126
- featureCount: number;
127
- layer: string;
128
- /**
129
- * The source's own attribute field names. A `-select` naming a column this set does not hold makes ogr2ogr write an
130
- * empty column rather than refuse, so the query is built from the set rather than from a schema read off a sibling
131
- * publication.
132
- */
133
- fields: ReadonlySet<string>;
134
- }
135
- /**
136
- * The attribute columns the ingest reads. Every one is required: this product publishes a single schema, and a column
137
- * that vanished would be a product change rather than a variation to absorb.
138
- */
139
- export declare const ZONING_SOURCE_FIELDS: ReadonlyArray<string>;
140
- /**
141
- * What the source declares about itself: its authority code, its feature count and its field list.
142
- *
143
- * @throws {Error} When the export is unreadable, its declared EPSG is not `expectEPSG`, or it is missing a field the
144
- * ingest reads.
145
- */
146
- export declare function readZoningSourceIdentity(options: ZoningIngestOptions): Promise<ZoningSourceIdentity>;
147
- /**
148
- * Stream the export through ogr2ogr as reprojected WKT, checking every vertex against the declared extent.
149
- *
150
- * A swapped coordinate order survives a projection check — both axes are still numbers in a plausible range — and shows
151
- * up here immediately, before 85,330 polygons are written to the wrong side of the planet.
152
- *
153
- * @throws {Error} When ogr2ogr fails, when a feature carries no geometry, when a reprojected vertex falls outside the
154
- * declared extent, or when a feature's rings cannot be resolved into at least one exterior.
155
- */
156
- export declare function readZoningFeatures(options: ZoningIngestOptions): AsyncGenerator<ZoningSourceFeature>;
157
- /**
158
- * Where a build's features come from, and what the source declares about itself.
159
- *
160
- * The builder takes ONE of these rather than a path, which is what makes the fixture rung possible: hand-built geometry
161
- * with no network and no GDAL still exercises the whole database half — the domain checks, the ring-role resolution,
162
- * the cell classification, the coverage rows, the manifest and the seal. A fixture rung that could only run through
163
- * ogr2ogr would test the conversion on the machines that have it and nothing at all on the ones that do not.
164
- */
165
- export interface ZoningFeatureSource {
166
- /**
167
- * What the source says it holds. The build compares its own streamed total against this, so a short read throws
168
- * instead of building a smaller country.
169
- */
170
- declaredFeatureCount: number;
171
- epsg: number;
172
- /**
173
- * A description of where these features came from, for the receipt.
174
- */
175
- origin: string;
176
- features: () => AsyncIterable<ZoningSourceFeature>;
177
- }
178
- export interface ExportSourceOptions extends ZoningIngestOptions {
179
- declaredFeatureCount?: number;
180
- }
181
- /**
182
- * The bulk export as a feature source — identity read up front, features streamed on demand.
183
- */
184
- export declare function createExportFeatureSource(options: ExportSourceOptions): Promise<ZoningFeatureSource>;
185
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/sdk/ingest/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AASH,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAGjE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B;;OAEG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAA;IACnC;;OAEG;IACH,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B;;OAEG;IACH,KAAK,EAAE,iBAAiB,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IACxD;;;;;;;;;;OAUG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAC3B;AAgBD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAgBtD,CAAA;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAoB1G;AAiCD;;;;;;;;GAQG;AACH,wBAAuB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,cAAc,CAAC,mBAAmB,CAAC,CAoF3G;AAaD;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,aAAa,CAAC,mBAAmB,CAAC,CAAA;CAClD;AAED,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC/D,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED;;GAEG;AACH,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAe1G"}