@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/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
- crosswalk?: {
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 null for a code that the publisher uses without declaring.
142
115
  */
143
- label?: string;
116
+ label: string | null;
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
+ } | null;
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
- coverage?: CoverageCell & {
158
+ coverage: (CoverageCell & {
180
159
  h3CellIndex: string;
181
160
  resolution: number;
182
- };
161
+ }) | null;
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 `null` when the publisher ships none.
217
196
  */
218
- crosswalkScheme?: string;
197
+ crosswalkScheme: string | null;
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;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EAIN,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAuBnD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7D;;GAEG;AACH,eAAO,MAAM,iBAAiB;IAC7B;;OAEG;aACH,UAAU,EAAE,YAAY;IACxB;;OAEG;aACH,OAAO,EAAE,SAAS;CACT,CAAA;AAEV,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAA;AAE1F;;GAEG;AACH,eAAO,MAAM,qBAAqB;IACjC;;OAEG;aACH,SAAS,EAAE,YAAY;IACvB;;OAEG;aACH,OAAO,EAAE,UAAU;IACnB;;OAEG;aACH,UAAU,EAAE,cAAc;CACjB,CAAA;AAEV,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAA;AAEtG;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,GAAG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AK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACnG;;;OAGG;IACH,aAAa,EAAE,aAAa,CAAA;IAC5B,YAAY,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,YAAY,EAAE,eAAe,CAAA;CAC7B;AA6BD;;;;;GAKG;AACH,qBAAa,YAAa,YAAW,UAAU;;IAC9C,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAA;IAUtC,YAAY,OAAO,EAAE,mBAAmB,EAgCvC;IAED;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa,CAchE;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAE9B;CA8HD"}
package/out/index.js CHANGED
@@ -3,50 +3,7 @@
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 { assertCoverageLicensesNoExclusion, assertNoCellsFinerThanIndex, parseManifestRows, } from "@mailwoman/core/layers";
52
9
  import { CoverageBasis } from "@mailwoman/evidence";
@@ -58,7 +15,7 @@ import { ZoningCellContainment } from "#schema";
58
15
  import { GZT_COVERAGE_LIMIT, GZT_CROSSWALK_SCHEME, GZT_LAYER_NAME, GZT_PRODUCT_LIMITS, GZT_UNZONED_LOCAL_CODE, } from "#vocabulary";
59
16
  export { GZT_LAYER_NAME, ProvenanceGrade } from "#vocabulary";
60
17
  /**
61
- * What the layer can say about a coordinate.
18
+ * The kinds of answer the layer gives for a coordinate.
62
19
  */
63
20
  export const ZoningReadingKind = {
64
21
  /**
@@ -66,35 +23,32 @@ export const ZoningReadingKind = {
66
23
  */
67
24
  Designated: "designated",
68
25
  /**
69
- * No zoning polygon contains the point. NEVER an absence reading — see this file's header.
26
+ * No zoning polygon contains the point — this kind never means the location is unzoned.
70
27
  */
71
28
  Unknown: "unknown",
72
29
  };
73
30
  /**
74
- * How containment was established.
31
+ * How the lookup established containment.
75
32
  */
76
33
  export const ZoningContainmentPath = {
77
34
  /**
78
- * The cell lies wholly inside the zone; no geometry was read.
35
+ * The cell lies wholly inside the zone, so no geometry was read.
79
36
  */
80
37
  WholeCell: "whole_cell",
81
38
  /**
82
- * The cell is crossed by a boundary; the point was ray-cast against the polygons named for that cell.
39
+ * A boundary crosses the cell, so the point was ray-cast against the cell's polygons.
83
40
  */
84
41
  RayCast: "ray_cast",
85
42
  /**
86
- * No zone reaches this cell at all.
43
+ * No zone reaches this cell.
87
44
  */
88
45
  NoZoneCell: "no_zone_cell",
89
46
  };
90
47
  /**
91
- * Read a sealed `zoning-ireland.db`.
48
+ * Reads a sealed `zoning-ireland.db`.
92
49
  *
93
- * Everything that would make the reader answer a well-formed wrong thing is refused at CONSTRUCTION rather than at
94
- * query time: a manifest naming a different layer, a coverage table with no rows, a coverage row whose basis would
95
- * support an exclusion, an empty jurisdiction table. Each of those would otherwise present as a reader that quietly
96
- * always answers `unknown` — or, in the exclusion case, as a reader that confidently reports unzoned-and-unmapped land
97
- * as free of restriction.
50
+ * The constructor throws on a manifest for a different layer, an empty coverage table,
51
+ * a coverage basis that supports exclusion or an empty jurisdiction table.
98
52
  */
99
53
  export class ZoningLookup {
100
54
  identity;
@@ -108,7 +62,7 @@ export class ZoningLookup {
108
62
  constructor(options) {
109
63
  this.#database = new DatabaseClient(options.databasePath, { readOnly: true });
110
64
  try {
111
- this.identity = readIdentity(this.#database, options.databasePath);
65
+ this.identity = readIdentity(this.#database, options.databasePath.toString());
112
66
  this.#crosswalkTerms = readCrosswalkTerms(this.#database);
113
67
  }
114
68
  catch (error) {
@@ -116,10 +70,9 @@ export class ZoningLookup {
116
70
  throw error;
117
71
  }
118
72
  this.#selectCell = this.#database.prepare("SELECT area_id, containment FROM zoning_cell WHERE h3_cell = ?");
119
- // TWO STATEMENTS, AND THE SPLIT IS THE POINT. The attributes and the bbox are read WITHOUT the blob, because the
120
- // bbox is the ray cast's prefilter: pulling hundreds of thousands of vertices off disk only to reject the polygon on
121
- // a rectangle would make the prefilter cost more than the test it replaces. A `whole` cell never reads the blob at
122
- // all.
73
+ // Read without the ring blob.
74
+ // The bounding box rejects most polygons before the ray cast needs rings.
75
+ // A whole cell never reads the blob.
123
76
  this.#selectArea = this.#database.prepare("SELECT area_id, jurisdiction_id, plan_id, local_code, local_description, local_code_url, crosswalk_code, " +
124
77
  "crosswalk_scheme, crosswalk_description, crosswalk_rollup, provenance_grade, min_lat, min_lon, max_lat, max_lon " +
125
78
  "FROM zoning_area WHERE area_id = ?");
@@ -128,7 +81,7 @@ export class ZoningLookup {
128
81
  this.#selectCoverage = this.#database.prepare("SELECT h3_cell, completeness, basis, observed_rows FROM layer_coverage WHERE h3_cell = ?");
129
82
  }
130
83
  /**
131
- * What an adopted plan assigns at this coordinate.
84
+ * Returns what an adopted plan assigns at this coordinate.
132
85
  */
133
86
  lookup(latitude, longitude) {
134
87
  const indexCell = latLngToCell(latitude, longitude, this.identity.indexResolution);
@@ -138,7 +91,7 @@ export class ZoningLookup {
138
91
  kind: resolved.designations.length ? ZoningReadingKind.Designated : ZoningReadingKind.Unknown,
139
92
  designations: resolved.designations,
140
93
  containment: resolved.containment,
141
- ...(coverage ? { coverage } : {}),
94
+ coverage,
142
95
  indexCellIndex: indexCell,
143
96
  limits: GZT_PRODUCT_LIMITS,
144
97
  coverageLimit: GZT_COVERAGE_LIMIT,
@@ -148,13 +101,13 @@ export class ZoningLookup {
148
101
  this.#database.destroy();
149
102
  }
150
103
  /**
151
- * The coverage row for the index cell's parent at the coverage resolution.
104
+ * Returns the coverage row for the index cell's parent at the coverage resolution.
152
105
  */
153
106
  #readCoverage(indexCell) {
154
107
  return readCoverageAt(this.#selectCoverage, indexCell, this.identity.coverageResolution);
155
108
  }
156
109
  /**
157
- * Walk the index, falling through to the geometry only for a cell a boundary crosses.
110
+ * Walks the cell index up the ancestor chain and reads geometry only for cells that a boundary crosses.
158
111
  */
159
112
  #resolveDesignations(indexCell, latitude, longitude) {
160
113
  const whole = new Set();
@@ -179,15 +132,12 @@ export class ZoningLookup {
179
132
  }
180
133
  let rayCastRan = false;
181
134
  for (const areaID of [...partial].toSorted()) {
182
- // A polygon that already answered `whole` higher in the chain needs no geometry read.
183
135
  if (whole.has(areaID))
184
136
  continue;
185
137
  const area = this.#selectArea.get(areaID);
186
138
  if (!area)
187
139
  continue;
188
140
  rayCastRan = true;
189
- // The bbox is the prefilter the geometry table stores precisely so the ray cast runs on the few polygons that
190
- // could contain the point rather than on every polygon reaching the cell.
191
141
  if (!bboxContains(area, longitude, latitude)) {
192
142
  continue;
193
143
  }
@@ -211,7 +161,7 @@ export class ZoningLookup {
211
161
  };
212
162
  }
213
163
  /**
214
- * One stored row as a designation, with its plan and its authority attached.
164
+ * Converts a stored row to a designation with its plan and jurisdiction.
215
165
  */
216
166
  #toDesignation(area, containment) {
217
167
  const plan = this.#selectPlan.get(area.plan_id);
@@ -221,26 +171,22 @@ export class ZoningLookup {
221
171
  sourceCode: area.jurisdiction_id,
222
172
  country: "",
223
173
  };
224
- const term = area.crosswalk_code === null ? undefined : this.#crosswalkTerms.get(area.crosswalk_code);
174
+ const term = area.crosswalk_code ? this.#crosswalkTerms.get(area.crosswalk_code) : undefined;
225
175
  return {
226
176
  areaID: area.area_id,
227
177
  localCode: area.local_code,
228
178
  localDescription: area.local_description,
229
179
  localCodeURL: area.local_code_url,
230
- // The crosswalk travels as one object or not at all: a code without its scheme reads as a code in whichever
231
- // vocabulary the consumer happened to assume.
232
- ...(area.crosswalk_code === null || area.crosswalk_scheme === null
233
- ? {}
180
+ crosswalk: !area.crosswalk_code || !area.crosswalk_scheme
181
+ ? null
234
182
  : {
235
- crosswalk: {
236
- scheme: area.crosswalk_scheme,
237
- code: area.crosswalk_code,
238
- description: area.crosswalk_description,
239
- rollup: area.crosswalk_rollup,
240
- ...(term ? { label: term.label } : {}),
241
- declared: term?.declared ?? false,
242
- },
243
- }),
183
+ scheme: area.crosswalk_scheme,
184
+ code: area.crosswalk_code,
185
+ description: area.crosswalk_description,
186
+ rollup: area.crosswalk_rollup,
187
+ label: term?.label ?? null,
188
+ declared: term?.declared ?? false,
189
+ },
244
190
  provenanceGrade: area.provenance_grade,
245
191
  jurisdiction,
246
192
  plan: {
@@ -256,9 +202,6 @@ export class ZoningLookup {
256
202
  };
257
203
  }
258
204
  }
259
- /**
260
- * The publisher's crosswalk domain, by code — its label and whether the publisher DECLARED it.
261
- */
262
205
  function readCrosswalkTerms(database) {
263
206
  const rows = database
264
207
  .prepare("SELECT code, label, declared FROM zoning_vocabulary WHERE scheme = ?")
@@ -266,7 +209,7 @@ function readCrosswalkTerms(database) {
266
209
  return new Map(rows.map((row) => [row.code, { label: row.label, declared: row.declared === 1 }]));
267
210
  }
268
211
  /**
269
- * Read and check the layer's identity.
212
+ * Reads the layer's identity and throws if it is unusable.
270
213
  */
271
214
  function readIdentity(database, databasePath) {
272
215
  const manifest = parseManifestRows(database.prepare("SELECT * FROM layer_manifest").all(), GZT_LAYER_NAME, `zoning reader: ${databasePath}`);
@@ -274,10 +217,8 @@ function readIdentity(database, databasePath) {
274
217
  if (!spineKeys.h3) {
275
218
  throw new Error(`zoning reader: ${databasePath} declares no h3 spine key`);
276
219
  }
277
- // THE EXCLUSION CHECK, AND IT IS A CONDITION RATHER THAN A CONVENTION. The Department publishes its coverage detail
278
- // only inside a map viewer, so no row of this layer may license a claim that a location is unrestricted. A stronger
279
- // basis reaching a caller would let an absent polygon be read as a designation of freedom to build over most of the
280
- // map. The check itself is the contract's rather than this product's; the SENTENCE saying why is this product's.
220
+ // The Department publishes its coverage footprint only in a map viewer,
221
+ // so no coverage row may support a claim that a location is unrestricted.
281
222
  assertCoverageLicensesNoExclusion(database.prepare("SELECT DISTINCT basis FROM layer_coverage").all().map((coverageRow) => coverageRow.basis), `zoning reader: ${databasePath}`, GZT_COVERAGE_LIMIT);
282
223
  const extentRows = database.prepare("SELECT * FROM zoning_mapped_extent ORDER BY extent_id").all();
283
224
  const cellResolutions = database.prepare("SELECT DISTINCT resolution FROM zoning_cell ORDER BY resolution").all().map((entry) => entry.resolution);
@@ -292,10 +233,10 @@ function readIdentity(database, databasePath) {
292
233
  const crosswalkScheme = database
293
234
  .prepare("SELECT DISTINCT crosswalk_scheme FROM zoning_area WHERE crosswalk_scheme IS NOT NULL")
294
235
  .all().map((entry) => entry.crosswalk_scheme);
295
- // THE COVERAGE RESOLUTION IS RECOVERED FROM THE CELLS, NOT DECLARED. The manifest's spine key names the INDEX
296
- // resolution; `layer_coverage` is keyed at a coarser one, and this layer has no footprint row to carry it. Recovering
297
- // it is exact rather than approximate — a short cell expands to a valid index at exactly one resolution — and the
298
- // shared helper throws on a table that mixes them.
236
+ // The layer stores no coverage resolution.
237
+ // The code recovers it from the coverage cells.
238
+ // A short cell expands to a valid index at exactly one resolution.
239
+ // The helper throws on mixed resolutions.
299
240
  const coverageResolution = recoverShortCellResolution(database.prepare("SELECT h3_cell FROM layer_coverage").all().map((coverageRow) => coverageRow.h3_cell), `zoning reader: ${databasePath}`);
300
241
  return {
301
242
  manifest,
@@ -311,7 +252,7 @@ function readIdentity(database, databasePath) {
311
252
  country: entry.country,
312
253
  },
313
254
  ])),
314
- ...(crosswalkScheme[0] ? { crosswalkScheme: crosswalkScheme[0] } : {}),
255
+ crosswalkScheme: crosswalkScheme[0] || null,
315
256
  mappedExtents: extentRows.map((extentRow) => ({
316
257
  extentID: String(extentRow.extent_id),
317
258
  source: String(extentRow.source),