@mailwoman/zoning 10.0.0 → 10.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +169 -163
  2. package/lib/index.ts +89 -120
  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 +96 -114
  7. package/lib/vocabulary.ts +52 -130
  8. package/out/index.d.ts +75 -95
  9. package/out/index.d.ts.map +1 -1
  10. package/out/index.js +25 -82
  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 +93 -108
  25. package/out/schema.d.ts.map +1 -1
  26. package/out/schema.js +16 -44
  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 +47 -136
  31. package/out/sdk/build-zoning.js.map +1 -1
  32. package/out/sdk/cells.d.ts +20 -61
  33. package/out/sdk/cells.d.ts.map +1 -1
  34. package/out/sdk/cells.js +13 -50
  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 +7 -27
  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 +16 -49
  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} +5 -7
  51. package/out/sdk/ingest/worker.js.map +1 -0
  52. package/out/sdk/ingest.d.ts +162 -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 -24
  57. package/out/sdk/measure-resolutions.d.ts.map +1 -1
  58. package/out/sdk/measure-resolutions.js +5 -22
  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 +74 -56
  65. package/out/sdk/verify.d.ts.map +1 -1
  66. package/out/sdk/verify.js +70 -57
  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 +37 -161
  73. package/{lib/sdk → sdk}/build-zoning.ts +99 -185
  74. package/{lib/sdk → sdk}/cells.ts +24 -63
  75. package/{lib/sdk → sdk}/client.ts +34 -82
  76. package/sdk/download.ts +58 -0
  77. package/{lib/sdk → sdk}/ingest/chunk.ts +33 -62
  78. package/{lib/scripts/ingest-chunk.ts → sdk/ingest/worker.ts} +4 -6
  79. package/sdk/ingest.ts +366 -0
  80. package/{lib/sdk → sdk}/measure-resolutions.ts +9 -26
  81. package/{lib → sdk}/test-kit.ts +21 -44
  82. package/{lib/sdk → sdk}/verify.ts +102 -75
  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/out/scripts/ingest-chunk.d.ts +0 -11
  87. package/out/scripts/ingest-chunk.d.ts.map +0 -1
  88. package/out/scripts/ingest-chunk.js.map +0 -1
  89. package/out/sdk/index.d.ts +0 -15
  90. package/out/sdk/index.d.ts.map +0 -1
  91. package/out/sdk/index.js +0 -15
  92. package/out/sdk/index.js.map +0 -1
  93. package/out/sdk/ingest/index.d.ts +0 -185
  94. package/out/sdk/ingest/index.d.ts.map +0 -1
  95. package/out/sdk/ingest/index.js +0 -232
  96. package/out/sdk/ingest/index.js.map +0 -1
  97. package/out/test-kit.d.ts +0 -96
  98. package/out/test-kit.d.ts.map +0 -1
  99. package/out/test-kit.js.map +0 -1
package/lib/vocabulary.ts CHANGED
@@ -3,52 +3,26 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The Department's own words, as data: the product identity, the national generic-type domain it declares,
7
- * the plan vocabulary, the exclusions it states, and the licence posture that holds this layer at
8
- * `build-local`.
9
- *
10
- * THE LOCAL CODE IS CARRIED VERBATIM AND THE CROSSWALK SITS BESIDE IT, NEVER INSTEAD OF IT. The Department
11
- * publishes a national generic type over 30 local authorities' own zone codes and says in its own item
12
- * description that the scheme "complements (rather than replaces) the existing statutory zoning used for
13
- * each individual plan". So a row carries both: `local_code` as the authority spelled it, and
14
- * `crosswalk_code` under {@link GZT_CROSSWALK_SCHEME} with its own provenance. Measured over the whole
15
- * national set, 52 of 795 (authority, local code) pairs take MORE THAN ONE generic type, so the mapping is
16
- * not a function of the pair and no code table can carry it — which is why `zoning_crosswalk_edge` ships
17
- * empty and the mapping lives per polygon.
18
- *
19
- * THE DECLARED DOMAIN IS CLOSED AND THE SOURCE ALREADY BREAKS IT. The service declares 54 generic types in
20
- * its own coded-value domain; the data uses 55. `N/A` appears on 4 rows and in no domain. So the ingest
21
- * carries the declared domain PLUS the values observed in the data and records the difference
22
- * (`zoning_vocabulary.declared`) rather than coercing an undeclared value to a neighbour or to null —
23
- * either of which turns "the source changed" into "there is nothing here".
24
- *
25
- * `CURRENT_PLAN = 1` DOES NOT MEAN "IN FORCE TODAY". All 85,330 rows in the Current layer carry it, and the
26
- * domain defines it as `Current plan` against `Expired and not replaced` and `Expired and replaced`. It
27
- * means "not superseded". The plan's own `PLAN_FROM`/`PLAN_TO` window is a separate fact a consumer must
28
- * read, and it is carried on `zoning_plan` for that reason.
29
- *
30
- * `LA_CODE` IS DIRTY AND IS NEVER REPAIRED. Fingal's code is `Fl` with a lowercase second letter against
31
- * `CL`, `CO`, `DU` and the rest. It is the publisher's key; repairing it would put this package's spelling
32
- * into an artifact that claims to repeat the authority's.
6
+ * The Department's product identity, declared vocabularies, stated limits and license status for the zoning layer.
33
7
  */
34
8
 
35
9
  /**
36
- * The layer name written into `layer_manifest.name`, and the only name the reader accepts.
10
+ * The layer name written to `layer_manifest.name`; the reader accepts no other name.
37
11
  */
38
12
  export const GZT_LAYER_NAME = "zoning-ie-gzt"
39
13
 
40
14
  /**
41
- * The ArcGIS Online item the product is published as, written into `layer_manifest.source`.
15
+ * The ArcGIS Online item id of the product, written to `layer_manifest.source`.
42
16
  */
43
17
  export const GZT_ITEM_ID = "5c2608ebedd84013aaeff8bf669e8596"
44
18
 
45
19
  /**
46
- * The publishing organisation's ArcGIS Online id.
20
+ * The publishing organization's ArcGIS Online id.
47
21
  */
48
22
  export const GZT_ORG_ID = "NzlPQPKn5QF9v2US"
49
23
 
50
24
  /**
51
- * The feature layer the product is served from.
25
+ * The feature layer that serves the product.
52
26
  */
53
27
  export const GZT_SERVICE_URL = `https://services.arcgis.com/${GZT_ORG_ID}/arcgis/rest/services/GZT_Current_Plan/FeatureServer/0`
54
28
 
@@ -58,38 +32,28 @@ export const GZT_SERVICE_URL = `https://services.arcgis.com/${GZT_ORG_ID}/arcgis
58
32
  export const GZT_ITEM_URL = `https://www.arcgis.com/home/item.html?id=${GZT_ITEM_ID}`
59
33
 
60
34
  /**
61
- * The Department's own zoning map viewer, which is where its coverage detail is published — and the reason
62
- * `zoning_mapped_extent` ships empty (see {@link GZT_COVERAGE_LIMIT}).
35
+ * The Department's zoning map viewer.
36
+ *
37
+ * It is the only place the Department publishes coverage detail.
63
38
  */
64
39
  export const GZT_MAP_VIEWER_URL = "https://www.myplan.ie/zoning-map-viewer/"
65
40
 
66
41
  /**
67
- * The attribution the item's `accessInformation` field carries, plus the licensor its `licenseInfo` names.
68
- *
69
- * BOTH HALVES RIDE, because the second is the half that holds this layer at `build-local`. The Department's own credit
70
- * line is the first; the all-rights-reserved clause naming Tailte Éireann as an upstream licensor is the second, and a
71
- * re-user who saw only the first would not know it exists.
42
+ * The item's `accessInformation` credit line followed by the Tailte Éireann clause from its
43
+ * `licenseInfo`, whose all-rights-reserved clause keeps this layer at the `build-local` tier.
72
44
  */
73
45
  export const GZT_ATTRIBUTION =
74
46
  "Department of Housing, Local Government, and Heritage (Generalised Zoning Types, MyPlan.ie). " +
75
47
  "© Copyright 2011 DHLGH. All rights reserved. © Tailte Éireann. All rights reserved. Licence No. 2023/OSi_NMA_073"
76
48
 
77
49
  /**
78
- * The licence expression written into `layer_manifest.license`.
79
- *
80
- * `NOASSERTION` IS THE HONEST VALUE AND IT IS NOT A PLACEHOLDER. Three published statements disagree about the grant —
81
- * see {@link GZT_LICENSE_CONTRADICTION} — and the manifest column is a string a consumer reads as the terms it may rely
82
- * on. Writing `CC-BY-4.0` there while an all-rights-reserved clause names a licensor would be this program asserting a
83
- * grant nobody made; leaving the column empty would read as a layer whose licence nobody looked at. `NOASSERTION` is
84
- * SPDX's own token for a determination that has not been made, which is exactly the state.
85
- *
86
- * {@linkcode assertTierMatchesLicense} refuses a `shipped` build while this holds, so moving the tier takes a
87
- * deliberate edit at a guard that names the reason rather than a manifest field nobody notices.
50
+ * The license expression written to `layer_manifest.license`; `assertTierMatchesLicense`
51
+ * in `@mailwoman/core/layers` rejects a `shipped` build while this value is set.
88
52
  */
89
53
  export const GZT_LICENSE = "NOASSERTION"
90
54
 
91
55
  /**
92
- * Why the licence is unresolved, in one sentence a receipt can carry.
56
+ * The explanation of why the license is unresolved, for build reports.
93
57
  */
94
58
  export const GZT_LICENSE_CONTRADICTION =
95
59
  "Three published statements disagree about the grant: data.gov.ie declares CC-BY-4.0; the ArcGIS item's licenseInfo " +
@@ -100,70 +64,59 @@ export const GZT_LICENSE_CONTRADICTION =
100
64
  "A shipped layer needs one grant it can quote, so this one is built locally and never redistributed."
101
65
 
102
66
  /**
103
- * The projected CRS the service and its bulk export both declare. The source is NOT in WGS84 — it is IRENET95 / Irish
104
- * Transverse Mercator, in metres — so the ingest reprojects and refuses a source declaring anything else.
67
+ * The projected CRS that the service and its bulk export declare — IRENET95 / Irish Transverse
68
+ * Mercator, in meters — which the ingest reprojects from and rejects any other code for.
105
69
  */
106
70
  export const GZT_SOURCE_EPSG = 2157
107
71
 
108
72
  /**
109
- * The extent the Department declares for the item, in CRS84 order `[minLon, minLat, maxLon, maxLat]` — the Republic of
110
- * Ireland, excluding Northern Ireland.
73
+ * The extent that the Department declares for the item, as `[minLon, minLat, maxLon, maxLat]` in CRS84.
111
74
  *
112
- * The ingest asserts every reprojected vertex lands inside this. That is the check a projection check cannot make: the
113
- * bulk export carries Irish Transverse Mercator metres under a legacy `crs` member, so a reader that took the numbers
114
- * as degrees would place Ireland's zoning at latitude 735,435 — a well-formed set of coordinates in the Southern
115
- * Ocean.
75
+ * The ingest checks every reprojected vertex against it to catch the source's
76
+ * projected meters read as degrees.
116
77
  */
117
78
  export const GZT_DECLARED_BBOX: readonly [number, number, number, number] = [
118
79
  -10.54553193079905, 51.452765583177616, -5.947766999109422, 54.47387941831219,
119
80
  ]
120
81
 
121
82
  /**
122
- * The feature count the service's own `returnCountOnly` and the bulk export agree on.
83
+ * The feature count reported by both the service's `returnCountOnly` query and the bulk export.
123
84
  */
124
85
  export const GZT_DECLARED_FEATURE_COUNT = 85_330
125
86
 
126
87
  /**
127
- * The crosswalk scheme the Department publishes — its national Generalised Zoning Type code.
88
+ * The crosswalk scheme of the Department's national Generalised Zoning Type codes.
128
89
  */
129
90
  export const GZT_CROSSWALK_SCHEME = "IE-GZT"
130
91
 
131
92
  /**
132
- * The Department's second, coarser national code (`SZO`, Standardised Zoning Objective).
133
- *
134
- * Carried as published rather than derived. Measured over the whole national set it is a STRICT COARSENING of the
135
- * generic type — no generic type maps to more than one `SZO` — but the roll-up is the Department's to change, so
136
- * re-deriving it here would replace a published fact with this package's arithmetic.
93
+ * The scheme of the Department's coarser national code, `SZO` (Standardised Zoning Objective),
94
+ * stored as published because the Department may change it.
137
95
  */
138
96
  export const GZT_ROLLUP_SCHEME = "IE-SZO"
139
97
 
140
98
  /**
141
- * The vocabulary scheme one local authority's own zone codes belong to.
142
- *
143
- * PER AUTHORITY RATHER THAN ONE POOLED LOCAL SCHEME, because the codes collide: `Residential` means one thing in Cork
144
- * County Council's plan and another in Westmeath's, and pooling them would assert an equivalence no authority stated.
99
+ * Returns the vocabulary scheme for one local authority's zone codes, since the
100
+ * same code can mean different things in different plans.
145
101
  */
146
102
  export function localSchemeFor(authorityCode: string): string {
147
103
  return `IE-LOCAL:${authorityCode}`
148
104
  }
149
105
 
150
106
  /**
151
- * One value a publisher declares, with the label it publishes for it.
107
+ * One value that a publisher declares, with its published label.
152
108
  */
153
109
  export interface ZoningTermDefinition {
154
110
  /**
155
- * The code as the publisher spells it — never re-spelled, never normalized.
111
+ * The code exactly as the publisher spells it.
156
112
  */
157
113
  code: string
158
114
  label: string
159
115
  }
160
116
 
161
117
  /**
162
- * The Department's declared generic-type domain, verbatim from the service's own `GZT Code` coded-value domain.
163
- *
164
- * FIFTY-FOUR DECLARED AGAINST FIFTY-FIVE USED. `N/A` appears on 4 of 85,330 rows and in no domain, so the ingest
165
- * records it as observed-but-undeclared rather than adding it here — a declaration this package wrote would be
166
- * indistinguishable from one the Department made.
118
+ * The Department's declared generic-type domain, copied verbatim from the service's
119
+ * `GZT Code` coded-value domain, omitting the observed-but-undeclared `N/A`.
167
120
  */
168
121
  export const GZT_DECLARED_CODES: ReadonlyArray<ZoningTermDefinition> = [
169
122
  { code: "P1", label: "Agriculture" },
@@ -228,8 +181,8 @@ export const GZT_DECLARED_CODES: ReadonlyArray<ZoningTermDefinition> = [
228
181
  export const GZT_DECLARED_CODE_SET: ReadonlySet<string> = new Set(GZT_DECLARED_CODES.map((term) => term.code))
229
182
 
230
183
  /**
231
- * The `PLAN_LEVEL` domain, verbatim. `SDZ` is declared and used on no row of the current edition; it is carried anyway,
232
- * because the domain is the Department's statement of what a plan may be rather than a census of what it is.
184
+ * The `PLAN_LEVEL` domain, verbatim, including `SDZ` because the Department declares it
185
+ * although no current row uses it.
233
186
  */
234
187
  export const GZT_PLAN_LEVELS: ReadonlyArray<ZoningTermDefinition> = [
235
188
  { code: "DP", label: "Development Plan" },
@@ -243,7 +196,8 @@ export const GZT_PLAN_LEVELS: ReadonlyArray<ZoningTermDefinition> = [
243
196
  export const GZT_PLAN_LEVEL_SET: ReadonlySet<string> = new Set(GZT_PLAN_LEVELS.map((term) => term.code))
244
197
 
245
198
  /**
246
- * The `CURRENT_PLAN` domain, verbatim, keyed by the integer the source publishes.
199
+ * The `CURRENT_PLAN` domain, verbatim, keyed by the published integer, where 1 means the
200
+ * plan is not superseded and its validity window is stored separately on `zoning_plan`.
247
201
  */
248
202
  export const GZT_CURRENT_PLAN_VALUES: ReadonlyMap<number, string> = new Map([
249
203
  [1, "Current plan"],
@@ -252,42 +206,35 @@ export const GZT_CURRENT_PLAN_VALUES: ReadonlyMap<number, string> = new Map([
252
206
  ])
253
207
 
254
208
  /**
255
- * The provenance grade a zoning claim carries. Exactly one per row, and the two never merge.
256
- *
257
- * `authoritative` is a planning or legislative authority for the land, or a government body republishing that
258
- * authority's own adopted records — the Department republishing 30 local authorities' plans is one. `inferred` is an
259
- * observation, a community mapping project or a research assembly: OpenStreetMap `landuse` is inferred, and so is
260
- * Overture's `base/land_use`, because it is the same data.
209
+ * The provenance grade of a zoning row.
261
210
  *
262
- * NEITHER GRADE IS BETTER; THEY ANSWER DIFFERENT QUESTIONS. The rule is that a query answered from an `inferred` row
263
- * may never be presented as the authority's designation. Measured in one jurisdiction on one day: of 1,652
264
- * OpenStreetMap `landuse=residential` polygons in South Dublin, only 558 — 33.8% — sit on land the authority zones
265
- * residential, and the two largest wrong answers are agriculture (23.4%) and conservation (19.6%).
211
+ * A caller must present an `inferred` row as an inference rather than as the authority's designation.
212
+ * Each artifact holds one grade.
266
213
  *
267
- * ONE ARTIFACT HOLDS ONE GRADE. An observed land-use layer is a different database with a different
268
- * `layer_manifest.name`, because `layer_coverage.observed_rows` means "rows this layer actually holds in the cell" and
269
- * coverage measured over community-mapped polygons cannot describe an authority's zones. The licences make the
270
- * separation compulsory anyway: OpenStreetMap and Overture `base` are ODbL, and merging an ODbL row into this table
271
- * would relicense it.
214
+ * ODbL sources require relicensing before they can be merged into this table.
272
215
  */
273
216
  export const ProvenanceGrade = {
274
217
  Authoritative: "authoritative",
275
218
  Inferred: "inferred",
276
219
  } as const
277
220
 
221
+ /**
222
+ * One of the {@link ProvenanceGrade} values.
223
+ */
278
224
  export type ProvenanceGrade = (typeof ProvenanceGrade)[keyof typeof ProvenanceGrade]
279
225
 
280
226
  /**
281
- * The grade every row of THIS artifact carries. A government department republishing local authorities' adopted plans.
227
+ * The grade of every row in this artifact, because the Department republishes
228
+ * local authorities' adopted plans.
282
229
  */
283
230
  export const GZT_PROVENANCE_GRADE: ProvenanceGrade = ProvenanceGrade.Authoritative
284
231
 
285
232
  /**
286
- * What the product does NOT state, in the Department's own words.
233
+ * The Department's own statements define the product's limits.
287
234
  *
288
- * Carried onto every reading, because a caller holding a zone code cannot see from it that the answer is a generalised
289
- * republication rather than the plan itself. The first of these is the sharpest constraint the Department states, and
290
- * it is why this layer reports what a plan assigns at a location and never what may be built there.
235
+ * Every reading includes these statements.
236
+ * They report the plan's zoning assignment at a location.
237
+ * They do not establish what may be built there.
291
238
  */
292
239
  export const GZT_PRODUCT_LIMITS: ReadonlyArray<string> = [
293
240
  "Myplan.ie data are not published here as legal definitions of the current actuality with regard to Local Authority zoning or their geographic extents.",
@@ -298,15 +245,9 @@ export const GZT_PRODUCT_LIMITS: ReadonlyArray<string> = [
298
245
  ]
299
246
 
300
247
  /**
301
- * Why this layer's coverage licenses no negative claim, in one sentence a receipt can carry.
302
- *
303
- * THE MEANING-OF-ZERO RULE UNDER ITS HARDEST CASE. For flood zones the Environment Agency states England-wide coverage
304
- * and the Planning Practice Guidance defines Zone 1 as the absence, so a location with no polygon IS a designation. No
305
- * such definition exists anywhere for zoning. A location with no zoning polygon is one of at least four different
306
- * things: outside any adopted plan area, inside a plan area on land the plan does not zone, in a jurisdiction that has
307
- * never adopted zoning, or in a jurisdiction whose records nobody has published. And the source can state one of them
308
- * positively — `ZONE_ORIG = "UNZ - Unzoned"` appears on 4 of 85,330 rows — which is what proves the other absences are
309
- * absences rather than designations.
248
+ * The explanation of why this layer's coverage supports no negative claim,
249
+ * because land without a polygon may be outside every plan area, unzoned by a plan,
250
+ * in a jurisdiction without zoning, or in one whose records are unpublished.
310
251
  */
311
252
  export const GZT_COVERAGE_LIMIT =
312
253
  "The Department publishes zoning polygons and states its coverage detail only inside a map viewer, so this layer " +
@@ -315,28 +256,9 @@ export const GZT_COVERAGE_LIMIT =
315
256
  "not yet published — and the product cannot tell those apart, so nothing here supports a claim that no restriction applies."
316
257
 
317
258
  /**
318
- * The one local code that states unzoned land POSITIVELY, and the reason the coverage rule above is grounded rather
319
- * than asserted: where the authority means "unzoned" it says so on a row, so every other absence is a row that is not
320
- * there.
321
- */
322
- export const GZT_UNZONED_LOCAL_CODE = "UNZ - Unzoned"
323
-
324
- /**
325
- * Refuse a manifest that would ship this layer under a licence nobody resolved.
326
- *
327
- * A GUARD RATHER THAN A CONVENTION, for the same reason the coverage basis is one: the tier is a field, and a field can
328
- * be edited without anyone reading the three statements that disagree. Moving this layer to `shipped` has to go through
329
- * a line that names what is unresolved.
259
+ * The local code with which an authority explicitly marks land as unzoned.
330
260
  *
331
- * @throws {Error} When a `shipped` tier is asked for while the licence is unresolved.
261
+ * A row with this code means the location is unzoned.
262
+ * A location with no row makes no statement about zoning.
332
263
  */
333
- export function assertTierMatchesLicense(tier: string, license: string): void {
334
- if (tier !== "shipped") return
335
-
336
- if (license === GZT_LICENSE) {
337
- throw new Error(
338
- `zoning build: tier "shipped" was asked for while the licence reads ${JSON.stringify(GZT_LICENSE)}. ` +
339
- `${GZT_LICENSE_CONTRADICTION} Resolve the grant in writing first, then change both this guard and the tier.`
340
- )
341
- }
342
- }
264
+ export const GZT_UNZONED_LOCAL_CODE = "UNZ - Unzoned"
package/out/index.d.ts CHANGED
@@ -3,56 +3,14 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The `zoning-ireland.db` reader — what a local authority's adopted plan assigns at a coordinate, in that
7
- * authority's own vocabulary, and on what basis.
8
- *
9
- * TWO READINGS, AND THE ONE THAT IS MISSING IS THE POINT.
10
- *
11
- * 1. `designated` — an adopted plan places the location inside a zoning polygon, and the polygon is the
12
- * answer: the authority's own code, its own description, the plan it belongs to and that plan's stated
13
- * window, with the Department's national generic type BESIDE the local code rather than instead of it.
14
- * 2. `unknown` — no polygon contains the point. THAT IS NOT AN ABSENCE READING, and this layer has none.
15
- *
16
- * THERE IS NO `designated_absence` HERE, AND ZONING IS THE HARDEST CASE OF THE RULE. For flood zones the
17
- * Environment Agency states England-wide coverage and the Planning Practice Guidance defines Zone 1 as the
18
- * land outside Zones 2 and 3, so an empty answer inside England IS a designation. No such definition exists
19
- * anywhere for zoning: a location with no zoning polygon is outside any adopted plan area, or inside one on
20
- * land the plan does not zone, or in a jurisdiction that has never adopted zoning, or in a jurisdiction
21
- * whose records nobody has published — and no product distinguishes them. The source itself proves the
22
- * asymmetry: it states `UNZ - Unzoned` as a POSITIVE value on 4 of 85,330 rows, so where the authority
23
- * means unzoned it says so, and every other absence is a row that is not there.
24
- *
25
- * SO THE CONSTRUCTOR REFUSES A COVERAGE ROW THAT WOULD SUPPORT AN EXCLUSION. Every row must read
26
- * `source_present`; `supportsExclusion` must be false for all of them. That is not a convention this reader
27
- * follows — it is a condition it checks at open time, so the day someone writes a stronger basis without
28
- * settling the footprint question, the layer refuses to open rather than answering confidently.
29
- *
30
- * NEITHER READING IS A STATEMENT ABOUT WHAT MAY BE BUILT. The layer reports what a plan assigns at a
31
- * location, which is a fact about the plan. The Department states that its data are "not published here as
32
- * legal definitions of the current actuality with regard to Local Authority zoning or their geographic
33
- * extents" and that "Original data should be sourced directly from the relevant Local Authority" — and
34
- * `limits` carries the authority's own exclusions on every answer.
35
- *
36
- * THE PLAN IS PART OF THE CLAIM, NEVER A PARAMETER OF IT. A zone exists inside a named Development Plan or
37
- * Local Area Plan with a stated validity window; a reading that dropped the plan would answer a question no
38
- * authority asked. And `currentPlan = 1` means "not superseded", not "in force today": 2,363 of 85,330 rows
39
- * carry a `validTo` already in the past, so the window travels on every reading and the comparison against a
40
- * date is the caller's, made against a clock this reader does not own.
41
- *
42
- * THE PROBE IS STRUCTURE FIRST, GEOMETRY LAST. `cellToParent` up the compacted whole-cell chain answers an
43
- * interior point with primary-key probes alone; only a cell a boundary crosses reaches the ray cast, and
44
- * then only against the polygons `zoning_cell` already named for that cell.
45
- *
46
- * THE READER IS SYNCHRONOUS AND USES RAW PREPARED STATEMENTS, for the same reason the sibling layer readers
47
- * are: it answers one point per geocode with a bounded number of primary-key probes plus a bounded geometry
48
- * read, and the ray cast it wraps is synchronous anyway. The DDL that created these tables IS Kysely — see
49
- * `schema.ts`.
6
+ * Synchronous reader for `zoning-ireland.db` that returns the zoning an adopted local plan assigns at a coordinate.
50
7
  */
51
8
  import { type CoverageCell, type LayerManifest } from "@mailwoman/core/layers";
52
9
  import { CoverageBasis } from "@mailwoman/evidence";
10
+ import type { PathBuilderLike } from "path-ts";
53
11
  export { GZT_LAYER_NAME, ProvenanceGrade } from "#vocabulary";
54
12
  /**
55
- * What the layer can say about a coordinate.
13
+ * The kinds of answer the layer gives for a coordinate.
56
14
  */
57
15
  export declare const ZoningReadingKind: {
58
16
  /**
@@ -60,28 +18,34 @@ export declare const ZoningReadingKind: {
60
18
  */
61
19
  readonly Designated: "designated";
62
20
  /**
63
- * No zoning polygon contains the point. NEVER an absence reading — see this file's header.
21
+ * No zoning polygon contains the point — this kind never means the location is unzoned.
64
22
  */
65
23
  readonly Unknown: "unknown";
66
24
  };
25
+ /**
26
+ * One of the {@link ZoningReadingKind} values.
27
+ */
67
28
  export type ZoningReadingKind = (typeof ZoningReadingKind)[keyof typeof ZoningReadingKind];
68
29
  /**
69
- * How containment was established.
30
+ * How the lookup established containment.
70
31
  */
71
32
  export declare const ZoningContainmentPath: {
72
33
  /**
73
- * The cell lies wholly inside the zone; no geometry was read.
34
+ * The cell lies wholly inside the zone, so no geometry was read.
74
35
  */
75
36
  readonly WholeCell: "whole_cell";
76
37
  /**
77
- * The cell is crossed by a boundary; the point was ray-cast against the polygons named for that cell.
38
+ * A boundary crosses the cell, so the point was ray-cast against the cell's polygons.
78
39
  */
79
40
  readonly RayCast: "ray_cast";
80
41
  /**
81
- * No zone reaches this cell at all.
42
+ * No zone reaches this cell.
82
43
  */
83
44
  readonly NoZoneCell: "no_zone_cell";
84
45
  };
46
+ /**
47
+ * One of the {@link ZoningContainmentPath} values.
48
+ */
85
49
  export type ZoningContainmentPath = (typeof ZoningContainmentPath)[keyof typeof ZoningContainmentPath];
86
50
  /**
87
51
  * The authority that adopted the plan.
@@ -90,135 +54,151 @@ export interface ZoningJurisdiction {
90
54
  jurisdictionID: string;
91
55
  name: string;
92
56
  /**
93
- * The publisher's own code, verbatim — `Fl` for Fingal, against `CL`, `CO`, `DU` for the rest.
57
+ * The publisher's code, verbatim.
94
58
  */
95
59
  sourceCode: string;
96
60
  country: string;
97
61
  }
98
62
  /**
99
- * The plan a zone belongs to, with its own stated window.
63
+ * The plan that a zone belongs to, with its stated validity window.
64
+ *
65
+ * The caller must compare the window with the current date, because a plan that is
66
+ * not superseded can still have a `validTo` in the past.
100
67
  */
101
68
  export interface ZoningPlan {
102
69
  planID: string;
103
70
  name: string;
104
71
  /**
105
- * `DP` Development Plan, `LAP` Local Area Plan, `SDZ` Strategic Development Zone.
72
+ * The plan level: `DP` for Development Plan, `LAP` for Local Area Plan
73
+ * or `SDZ` for Strategic Development Zone.
106
74
  */
107
75
  level: string;
108
76
  validFrom: string | null;
109
77
  validTo: string | null;
110
78
  /**
111
- * The publisher's `CURRENT_PLAN` flag, carried as published. `1` means NOT SUPERSEDED — not "in force today".
79
+ * The publisher's `CURRENT_PLAN` flag as published.
80
+ *
81
+ * The value `1` means the plan is active.
82
+ * `validTo` determines whether it has force today.
112
83
  */
113
84
  currentPlan: number;
114
85
  }
115
86
  /**
116
- * One zoning polygon the point falls inside, as the authority publishes it.
87
+ * One zoning polygon that contains the point, as the authority publishes it.
117
88
  */
118
89
  export interface ZoningDesignation {
119
90
  areaID: string;
120
91
  /**
121
- * The authority's own zone code, verbatim.
92
+ * The authority's zone code, verbatim.
122
93
  */
123
94
  localCode: string;
124
95
  localDescription: string | null;
125
96
  localCodeURL: string | null;
126
97
  /**
127
- * The publishing authority's OWN crosswalk into a shared scheme, where it publishes one. Beside the local code, never
128
- * instead of it: 52 of 795 (authority, local code) pairs take more than one generic type, so this cannot be
129
- * reconstructed from `localCode` and is a per-polygon fact the Department authored.
98
+ * The publisher's crosswalk from the local code into a shared scheme, when it publishes one.
99
+ *
100
+ * The crosswalk is stored per polygon because one local code can map to several
101
+ * generic types, so it cannot be derived from `localCode`.
130
102
  */
131
103
  crosswalk?: {
132
104
  scheme: string;
133
105
  code: string;
134
106
  description: string | null;
135
107
  /**
136
- * A coarser code from the same authority, carried as published.
108
+ * A coarser code from the same authority, as published.
137
109
  */
138
110
  rollup: string | null;
139
111
  /**
140
- * The publisher's own label for `code`, from its declared domain — absent for a code the publisher uses and never
141
- * declared.
112
+ * The publisher's label for `code` from its declared domain.
113
+ *
114
+ * It is absent for a code that the publisher uses without declaring.
142
115
  */
143
116
  label?: string;
144
117
  /**
145
- * `false` where the publisher uses this code without declaring it in its own domain.
118
+ * Whether the publisher declares this code in its own domain.
146
119
  */
147
120
  declared: boolean;
148
121
  };
149
122
  /**
150
- * One of {@link ProvenanceGrade}. Every row of THIS artifact is `authoritative`; the column exists because a query
151
- * answered from an `inferred` row may never be presented as the authority's designation.
123
+ * One of {@link ProvenanceGrade}.
124
+ *
125
+ * Every row of this artifact is `authoritative`.
126
+ * A caller must never present an `inferred` row as the authority's designation.
152
127
  */
153
128
  provenanceGrade: string;
154
129
  jurisdiction: ZoningJurisdiction;
155
130
  plan: ZoningPlan;
156
131
  /**
157
- * The authority states unzoned land POSITIVELY on a handful of rows. `true` here is the authority saying so; an
158
- * ABSENT designation says nothing at all, which is the distinction this layer exists to keep.
132
+ * Whether the authority explicitly zones this polygon as unzoned.
133
+ *
134
+ * Only this flag means unzoned.
135
+ * A point with no designation makes no statement about zoning.
159
136
  */
160
137
  unzoned: boolean;
161
138
  containment: ZoningContainmentPath;
162
139
  }
163
140
  /**
164
- * One reading, carrying everything a caller needs to re-derive it rather than take it.
141
+ * One reading at a coordinate, with the provenance a caller needs to check it.
165
142
  */
166
143
  export interface ZoningReading {
167
144
  kind: ZoningReadingKind;
168
145
  /**
169
- * Every polygon containing the point, ordered by `area_id`. Usually one; several where a Local Area Plan overlays a
170
- * Development Plan over the same ground, which the source publishes as two rows.
146
+ * Every polygon that contains the point, ordered by `area_id`.
147
+ *
148
+ * A Local Area Plan that overlays a Development Plan produces two designations for the same ground.
171
149
  */
172
150
  designations: ZoningDesignation[];
173
151
  containment: ZoningContainmentPath;
174
152
  /**
175
- * The coverage row for the location, when the product has data in that cell. Its basis is always `source_present`, so
176
- * it licenses PRESENCE and nothing else — an absent coverage row and a present one are both compatible with "no
177
- * zoning polygon here", and neither says the location is unrestricted.
153
+ * The coverage row for the location, when the product has data in that cell.
154
+ *
155
+ * Its basis is always `source_present`, which only shows that the source has data nearby.
156
+ * Neither a present nor an absent coverage row means the location is unrestricted.
178
157
  */
179
158
  coverage?: CoverageCell & {
180
159
  h3CellIndex: string;
181
160
  resolution: number;
182
161
  };
183
162
  /**
184
- * The index cell probed, for a receipt.
163
+ * The H3 index cell that the lookup probed.
185
164
  */
186
165
  indexCellIndex: string;
187
166
  /**
188
- * What the product does not state, in the authority's own words.
167
+ * The authority's own statements of what the product does not state.
189
168
  */
190
169
  limits: ReadonlyArray<string>;
191
170
  /**
192
- * Why this layer's coverage licenses no negative claim, in one sentence.
171
+ * One sentence on why this layer's coverage supports no negative claim.
193
172
  */
194
173
  coverageLimit: string;
195
174
  }
196
175
  /**
197
- * The layer's identity, read once at open time.
176
+ * The layer's identity, read once when the database opens.
198
177
  */
199
178
  export interface ZoningLayerIdentity {
200
179
  manifest: LayerManifest;
201
180
  indexResolution: number;
202
181
  coverageResolution: number;
203
182
  /**
204
- * Every resolution `zoning_cell` stores a row at, coarsest first — the ancestor chain a probe walks.
183
+ * Every resolution at which `zoning_cell` stores rows, coarsest first.
205
184
  *
206
- * Several, and necessarily so: each feature's whole tier is compacted parent-ward, and a polygon too large for h3's
207
- * allocator at the index resolution was indexed coarser. A reader that probed one resolution would read every row at
208
- * the others as an absence.
185
+ * A probe walks all of them because whole cells are compacted into parents.
186
+ * The builder indexes a polygon at a coarser resolution when the h3 allocator
187
+ * cannot fit it at the index resolution.
209
188
  */
210
189
  cellResolutions: number[];
211
190
  /**
212
- * The jurisdictions the layer holds, by id.
191
+ * The jurisdictions in the layer, keyed by id.
213
192
  */
214
193
  jurisdictions: ReadonlyMap<string, ZoningJurisdiction>;
215
194
  /**
216
- * The crosswalk scheme this layer's rows carry, or `undefined` where the publisher ships none.
195
+ * The crosswalk scheme of this layer's rows, or `undefined` when the publisher ships none.
217
196
  */
218
197
  crosswalkScheme?: string;
219
198
  /**
220
- * The authority's footprint statements. EMPTY in this edition, which is what makes `source_present` the only basis
221
- * the coverage may carry — see `schema.ts`.
199
+ * The authority's footprint statements.
200
+ *
201
+ * This edition has none, so `source_present` is the only coverage basis allowed.
222
202
  */
223
203
  mappedExtents: Array<{
224
204
  extentID: string;
@@ -227,30 +207,30 @@ export interface ZoningLayerIdentity {
227
207
  statementURL: string;
228
208
  }>;
229
209
  /**
230
- * The coverage basis every row carries. Always `source_present` while `mappedExtents` is empty; checked at open time
231
- * rather than assumed.
210
+ * The coverage basis of every row.
211
+ * It is `source_present` while `mappedExtents` is empty.
232
212
  */
233
213
  coverageBasis: CoverageBasis;
234
214
  databasePath: string;
235
215
  }
216
+ /**
217
+ * Options for {@link ZoningLookup}.
218
+ */
236
219
  export interface ZoningLookupOptions {
237
- databasePath: string;
220
+ databasePath: PathBuilderLike;
238
221
  }
239
222
  /**
240
- * Read a sealed `zoning-ireland.db`.
223
+ * Reads a sealed `zoning-ireland.db`.
241
224
  *
242
- * Everything that would make the reader answer a well-formed wrong thing is refused at CONSTRUCTION rather than at
243
- * query time: a manifest naming a different layer, a coverage table with no rows, a coverage row whose basis would
244
- * support an exclusion, an empty jurisdiction table. Each of those would otherwise present as a reader that quietly
245
- * always answers `unknown` — or, in the exclusion case, as a reader that confidently reports unzoned-and-unmapped land
246
- * as free of restriction.
225
+ * The constructor throws on a manifest for a different layer, an empty coverage table,
226
+ * a coverage basis that supports exclusion or an empty jurisdiction table.
247
227
  */
248
228
  export declare class ZoningLookup implements Disposable {
249
229
  #private;
250
230
  readonly identity: ZoningLayerIdentity;
251
231
  constructor(options: ZoningLookupOptions);
252
232
  /**
253
- * What an adopted plan assigns at this coordinate.
233
+ * Returns what an adopted plan assigns at this coordinate.
254
234
  */
255
235
  lookup(latitude: number, longitude: number): ZoningReading;
256
236
  [Symbol.dispose](): void;