@mailwoman/zoning 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +315 -0
- package/lib/index.ts +616 -0
- package/lib/ring-roles.ts +233 -0
- package/lib/rings.ts +34 -0
- package/lib/schema.ts +449 -0
- package/lib/scripts/ingest-chunk.ts +41 -0
- package/lib/sdk/build-zoning.ts +790 -0
- package/lib/sdk/cells.ts +276 -0
- package/lib/sdk/client.ts +335 -0
- package/lib/sdk/download.ts +78 -0
- package/lib/sdk/index.ts +15 -0
- package/lib/sdk/ingest-chunk.ts +360 -0
- package/lib/sdk/ingest.ts +402 -0
- package/lib/sdk/measure-resolutions.ts +100 -0
- package/lib/sdk/verify.ts +350 -0
- package/lib/test-kit.ts +207 -0
- package/lib/vocabulary.ts +342 -0
- package/out/index.d.ts +257 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +325 -0
- package/out/index.js.map +1 -0
- package/out/ring-roles.d.ts +88 -0
- package/out/ring-roles.d.ts.map +1 -0
- package/out/ring-roles.js +151 -0
- package/out/ring-roles.js.map +1 -0
- package/out/rings.d.ts +22 -0
- package/out/rings.d.ts.map +1 -0
- package/out/rings.js +22 -0
- package/out/rings.js.map +1 -0
- package/out/schema.d.ts +325 -0
- package/out/schema.d.ts.map +1 -0
- package/out/schema.js +186 -0
- package/out/schema.js.map +1 -0
- package/out/scripts/ingest-chunk.d.ts +11 -0
- package/out/scripts/ingest-chunk.d.ts.map +1 -0
- package/out/scripts/ingest-chunk.js +36 -0
- package/out/scripts/ingest-chunk.js.map +1 -0
- package/out/sdk/build-zoning.d.ts +283 -0
- package/out/sdk/build-zoning.d.ts.map +1 -0
- package/out/sdk/build-zoning.js +462 -0
- package/out/sdk/build-zoning.js.map +1 -0
- package/out/sdk/cells.d.ts +137 -0
- package/out/sdk/cells.d.ts.map +1 -0
- package/out/sdk/cells.js +176 -0
- package/out/sdk/cells.js.map +1 -0
- package/out/sdk/client.d.ts +151 -0
- package/out/sdk/client.d.ts.map +1 -0
- package/out/sdk/client.js +239 -0
- package/out/sdk/client.js.map +1 -0
- package/out/sdk/download.d.ts +51 -0
- package/out/sdk/download.d.ts.map +1 -0
- package/out/sdk/download.js +57 -0
- package/out/sdk/download.js.map +1 -0
- package/out/sdk/index.d.ts +15 -0
- package/out/sdk/index.d.ts.map +1 -0
- package/out/sdk/index.js +15 -0
- package/out/sdk/index.js.map +1 -0
- package/out/sdk/ingest-chunk.d.ts +130 -0
- package/out/sdk/ingest-chunk.d.ts.map +1 -0
- package/out/sdk/ingest-chunk.js +206 -0
- package/out/sdk/ingest-chunk.js.map +1 -0
- package/out/sdk/ingest.d.ts +191 -0
- package/out/sdk/ingest.d.ts.map +1 -0
- package/out/sdk/ingest.js +238 -0
- package/out/sdk/ingest.js.map +1 -0
- package/out/sdk/measure-resolutions.d.ts +51 -0
- package/out/sdk/measure-resolutions.d.ts.map +1 -0
- package/out/sdk/measure-resolutions.js +64 -0
- package/out/sdk/measure-resolutions.js.map +1 -0
- package/out/sdk/verify.d.ts +176 -0
- package/out/sdk/verify.d.ts.map +1 -0
- package/out/sdk/verify.js +202 -0
- package/out/sdk/verify.js.map +1 -0
- package/out/test-kit.d.ts +97 -0
- package/out/test-kit.d.ts.map +1 -0
- package/out/test-kit.js +180 -0
- package/out/test-kit.js.map +1 -0
- package/out/vocabulary.d.ts +221 -0
- package/out/vocabulary.d.ts.map +1 -0
- package/out/vocabulary.js +299 -0
- package/out/vocabulary.js.map +1 -0
- package/package.json +245 -0
package/out/index.js
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
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`.
|
|
50
|
+
*/
|
|
51
|
+
import { assertCoverageLicensesNoExclusion, assertNoCellsFinerThanIndex, CoverageBasis, parseManifestRows, } from "@mailwoman/core/layers";
|
|
52
|
+
import { ancestorChainCells, bboxContains, recoverShortCellResolution, shortCellToInt, } from "@mailwoman/spatial";
|
|
53
|
+
import { readCoverageAt } from "@mailwoman/spatial/h3/coverage";
|
|
54
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
55
|
+
import { latLngToCell } from "h3-js";
|
|
56
|
+
import { pointInEncodedRings } from "#rings";
|
|
57
|
+
import { ZoningCellContainment } from "#schema";
|
|
58
|
+
import { GZT_COVERAGE_LIMIT, GZT_CROSSWALK_SCHEME, GZT_LAYER_NAME, GZT_PRODUCT_LIMITS, GZT_UNZONED_LOCAL_CODE, } from "#vocabulary";
|
|
59
|
+
export { GZT_LAYER_NAME, ProvenanceGrade } from "#vocabulary";
|
|
60
|
+
/**
|
|
61
|
+
* What the layer can say about a coordinate.
|
|
62
|
+
*/
|
|
63
|
+
export const ZoningReadingKind = {
|
|
64
|
+
/**
|
|
65
|
+
* An adopted plan places this location inside a zoning polygon.
|
|
66
|
+
*/
|
|
67
|
+
Designated: "designated",
|
|
68
|
+
/**
|
|
69
|
+
* No zoning polygon contains the point. NEVER an absence reading — see this file's header.
|
|
70
|
+
*/
|
|
71
|
+
Unknown: "unknown",
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* How containment was established.
|
|
75
|
+
*/
|
|
76
|
+
export const ZoningContainmentPath = {
|
|
77
|
+
/**
|
|
78
|
+
* The cell lies wholly inside the zone; no geometry was read.
|
|
79
|
+
*/
|
|
80
|
+
WholeCell: "whole_cell",
|
|
81
|
+
/**
|
|
82
|
+
* The cell is crossed by a boundary; the point was ray-cast against the polygons named for that cell.
|
|
83
|
+
*/
|
|
84
|
+
RayCast: "ray_cast",
|
|
85
|
+
/**
|
|
86
|
+
* No zone reaches this cell at all.
|
|
87
|
+
*/
|
|
88
|
+
NoZoneCell: "no_zone_cell",
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Read a sealed `zoning-ireland.db`.
|
|
92
|
+
*
|
|
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.
|
|
98
|
+
*/
|
|
99
|
+
export class ZoningLookup {
|
|
100
|
+
identity;
|
|
101
|
+
#database;
|
|
102
|
+
#selectCell;
|
|
103
|
+
#selectArea;
|
|
104
|
+
#selectAreaRings;
|
|
105
|
+
#selectPlan;
|
|
106
|
+
#selectCoverage;
|
|
107
|
+
#crosswalkTerms;
|
|
108
|
+
constructor(options) {
|
|
109
|
+
this.#database = new DatabaseClient(options.databasePath, { readOnly: true });
|
|
110
|
+
try {
|
|
111
|
+
this.identity = readIdentity(this.#database, options.databasePath);
|
|
112
|
+
this.#crosswalkTerms = readCrosswalkTerms(this.#database);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
this.#database.destroy();
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
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.
|
|
123
|
+
this.#selectArea = this.#database.prepare("SELECT area_id, jurisdiction_id, plan_id, local_code, local_description, local_code_url, crosswalk_code, " +
|
|
124
|
+
"crosswalk_scheme, crosswalk_description, crosswalk_rollup, provenance_grade, min_lat, min_lon, max_lat, max_lon " +
|
|
125
|
+
"FROM zoning_area WHERE area_id = ?");
|
|
126
|
+
this.#selectAreaRings = this.#database.prepare("SELECT rings FROM zoning_area WHERE area_id = ?");
|
|
127
|
+
this.#selectPlan = this.#database.prepare("SELECT plan_id, plan_name, plan_level, valid_from, valid_to, current_plan FROM zoning_plan WHERE plan_id = ?");
|
|
128
|
+
this.#selectCoverage = this.#database.prepare("SELECT h3_cell, completeness, basis, observed_rows FROM layer_coverage WHERE h3_cell = ?");
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* What an adopted plan assigns at this coordinate.
|
|
132
|
+
*/
|
|
133
|
+
lookup(latitude, longitude) {
|
|
134
|
+
const indexCell = latLngToCell(latitude, longitude, this.identity.indexResolution);
|
|
135
|
+
const coverage = this.#readCoverage(indexCell);
|
|
136
|
+
const resolved = this.#resolveDesignations(indexCell, latitude, longitude);
|
|
137
|
+
return {
|
|
138
|
+
kind: resolved.designations.length ? ZoningReadingKind.Designated : ZoningReadingKind.Unknown,
|
|
139
|
+
designations: resolved.designations,
|
|
140
|
+
containment: resolved.containment,
|
|
141
|
+
...(coverage ? { coverage } : {}),
|
|
142
|
+
indexCellIndex: indexCell,
|
|
143
|
+
limits: GZT_PRODUCT_LIMITS,
|
|
144
|
+
coverageLimit: GZT_COVERAGE_LIMIT,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
[Symbol.dispose]() {
|
|
148
|
+
this.#database.destroy();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The coverage row for the index cell's parent at the coverage resolution.
|
|
152
|
+
*/
|
|
153
|
+
#readCoverage(indexCell) {
|
|
154
|
+
return readCoverageAt(this.#selectCoverage, indexCell, this.identity.coverageResolution);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Walk the index, falling through to the geometry only for a cell a boundary crosses.
|
|
158
|
+
*/
|
|
159
|
+
#resolveDesignations(indexCell, latitude, longitude) {
|
|
160
|
+
const whole = new Set();
|
|
161
|
+
const partial = new Set();
|
|
162
|
+
for (const cell of ancestorChainCells(indexCell, this.identity.indexResolution, this.identity.cellResolutions)) {
|
|
163
|
+
const rows = this.#selectCell.all(shortCellToInt(cell));
|
|
164
|
+
for (const row of rows) {
|
|
165
|
+
if (row.containment === ZoningCellContainment.Whole) {
|
|
166
|
+
whole.add(row.area_id);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
partial.add(row.area_id);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const designations = [];
|
|
174
|
+
for (const areaID of [...whole].toSorted()) {
|
|
175
|
+
const area = this.#selectArea.get(areaID);
|
|
176
|
+
if (area) {
|
|
177
|
+
designations.push(this.#toDesignation(area, ZoningContainmentPath.WholeCell));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
let rayCastRan = false;
|
|
181
|
+
for (const areaID of [...partial].toSorted()) {
|
|
182
|
+
// A polygon that already answered `whole` higher in the chain needs no geometry read.
|
|
183
|
+
if (whole.has(areaID))
|
|
184
|
+
continue;
|
|
185
|
+
const area = this.#selectArea.get(areaID);
|
|
186
|
+
if (!area)
|
|
187
|
+
continue;
|
|
188
|
+
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
|
+
if (!bboxContains(area, longitude, latitude)) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const geometry = this.#selectAreaRings.get(areaID);
|
|
195
|
+
if (!geometry)
|
|
196
|
+
continue;
|
|
197
|
+
if (pointInEncodedRings(geometry.rings, longitude, latitude)) {
|
|
198
|
+
designations.push(this.#toDesignation(area, ZoningContainmentPath.RayCast));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (designations.length) {
|
|
202
|
+
designations.sort((left, right) => (left.areaID < right.areaID ? -1 : 1));
|
|
203
|
+
return {
|
|
204
|
+
designations,
|
|
205
|
+
containment: whole.size ? ZoningContainmentPath.WholeCell : ZoningContainmentPath.RayCast,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
designations,
|
|
210
|
+
containment: rayCastRan ? ZoningContainmentPath.RayCast : ZoningContainmentPath.NoZoneCell,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* One stored row as a designation, with its plan and its authority attached.
|
|
215
|
+
*/
|
|
216
|
+
#toDesignation(area, containment) {
|
|
217
|
+
const plan = this.#selectPlan.get(area.plan_id);
|
|
218
|
+
const jurisdiction = this.identity.jurisdictions.get(area.jurisdiction_id) ?? {
|
|
219
|
+
jurisdictionID: area.jurisdiction_id,
|
|
220
|
+
name: area.jurisdiction_id,
|
|
221
|
+
sourceCode: area.jurisdiction_id,
|
|
222
|
+
country: "",
|
|
223
|
+
};
|
|
224
|
+
const term = area.crosswalk_code === null ? undefined : this.#crosswalkTerms.get(area.crosswalk_code);
|
|
225
|
+
return {
|
|
226
|
+
areaID: area.area_id,
|
|
227
|
+
localCode: area.local_code,
|
|
228
|
+
localDescription: area.local_description,
|
|
229
|
+
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
|
+
? {}
|
|
234
|
+
: {
|
|
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
|
+
}),
|
|
244
|
+
provenanceGrade: area.provenance_grade,
|
|
245
|
+
jurisdiction,
|
|
246
|
+
plan: {
|
|
247
|
+
planID: area.plan_id,
|
|
248
|
+
name: plan?.plan_name ?? area.plan_id,
|
|
249
|
+
level: plan?.plan_level ?? "",
|
|
250
|
+
validFrom: plan?.valid_from ?? null,
|
|
251
|
+
validTo: plan?.valid_to ?? null,
|
|
252
|
+
currentPlan: plan?.current_plan ?? 0,
|
|
253
|
+
},
|
|
254
|
+
unzoned: area.local_code === GZT_UNZONED_LOCAL_CODE,
|
|
255
|
+
containment,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* The publisher's crosswalk domain, by code — its label and whether the publisher DECLARED it.
|
|
261
|
+
*/
|
|
262
|
+
function readCrosswalkTerms(database) {
|
|
263
|
+
const rows = database
|
|
264
|
+
.prepare("SELECT code, label, declared FROM zoning_vocabulary WHERE scheme = ?")
|
|
265
|
+
.all(GZT_CROSSWALK_SCHEME);
|
|
266
|
+
return new Map(rows.map((row) => [row.code, { label: row.label, declared: row.declared === 1 }]));
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Read and check the layer's identity.
|
|
270
|
+
*/
|
|
271
|
+
function readIdentity(database, databasePath) {
|
|
272
|
+
const manifest = parseManifestRows(database.prepare("SELECT * FROM layer_manifest").all(), GZT_LAYER_NAME, `zoning reader: ${databasePath}`);
|
|
273
|
+
const spineKeys = manifest.spineKeys;
|
|
274
|
+
if (!spineKeys.h3) {
|
|
275
|
+
throw new Error(`zoning reader: ${databasePath} declares no h3 spine key`);
|
|
276
|
+
}
|
|
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.
|
|
281
|
+
assertCoverageLicensesNoExclusion(database.prepare("SELECT DISTINCT basis FROM layer_coverage").all().map((coverageRow) => coverageRow.basis), `zoning reader: ${databasePath}`, GZT_COVERAGE_LIMIT);
|
|
282
|
+
const extentRows = database.prepare("SELECT * FROM zoning_mapped_extent ORDER BY extent_id").all();
|
|
283
|
+
const cellResolutions = database.prepare("SELECT DISTINCT resolution FROM zoning_cell ORDER BY resolution").all().map((entry) => entry.resolution);
|
|
284
|
+
const indexResolution = spineKeys.h3.resolution;
|
|
285
|
+
assertNoCellsFinerThanIndex(cellResolutions, indexResolution, `zoning reader: ${databasePath}`);
|
|
286
|
+
const jurisdictionRows = database
|
|
287
|
+
.prepare("SELECT jurisdiction_id, name, source_code, country FROM zoning_jurisdiction ORDER BY jurisdiction_id")
|
|
288
|
+
.all();
|
|
289
|
+
if (!jurisdictionRows.length) {
|
|
290
|
+
throw new Error(`zoning reader: ${databasePath} names no jurisdiction — a designation whose authority a reader cannot see is a designation nobody can check`);
|
|
291
|
+
}
|
|
292
|
+
const crosswalkScheme = database
|
|
293
|
+
.prepare("SELECT DISTINCT crosswalk_scheme FROM zoning_area WHERE crosswalk_scheme IS NOT NULL")
|
|
294
|
+
.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.
|
|
299
|
+
const coverageResolution = recoverShortCellResolution(database.prepare("SELECT h3_cell FROM layer_coverage").all().map((coverageRow) => coverageRow.h3_cell), `zoning reader: ${databasePath}`);
|
|
300
|
+
return {
|
|
301
|
+
manifest,
|
|
302
|
+
indexResolution,
|
|
303
|
+
coverageResolution,
|
|
304
|
+
cellResolutions,
|
|
305
|
+
jurisdictions: new Map(jurisdictionRows.map((entry) => [
|
|
306
|
+
entry.jurisdiction_id,
|
|
307
|
+
{
|
|
308
|
+
jurisdictionID: entry.jurisdiction_id,
|
|
309
|
+
name: entry.name,
|
|
310
|
+
sourceCode: entry.source_code,
|
|
311
|
+
country: entry.country,
|
|
312
|
+
},
|
|
313
|
+
])),
|
|
314
|
+
...(crosswalkScheme[0] ? { crosswalkScheme: crosswalkScheme[0] } : {}),
|
|
315
|
+
mappedExtents: extentRows.map((extentRow) => ({
|
|
316
|
+
extentID: String(extentRow.extent_id),
|
|
317
|
+
source: String(extentRow.source),
|
|
318
|
+
statement: String(extentRow.statement),
|
|
319
|
+
statementURL: String(extentRow.statement_url),
|
|
320
|
+
})),
|
|
321
|
+
coverageBasis: CoverageBasis.SourcePresent,
|
|
322
|
+
databasePath,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
//# sourceMappingURL=index.js.map
|
package/out/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EACN,iCAAiC,EACjC,2BAA2B,EAC3B,aAAa,EACb,iBAAiB,GAGjB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACN,kBAAkB,EAClB,YAAY,EACZ,0BAA0B,EAC1B,cAAc,GAEd,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAA;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAC/C,OAAO,EACN,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC;;OAEG;IACH,UAAU,EAAE,YAAY;IACxB;;OAEG;IACH,OAAO,EAAE,SAAS;CACT,CAAA;AAIV;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC;;OAEG;IACH,SAAS,EAAE,YAAY;IACvB;;OAEG;IACH,OAAO,EAAE,UAAU;IACnB;;OAEG;IACH,UAAU,EAAE,cAAc;CACjB,CAAA;AAsLV;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAY;IACf,QAAQ,CAAqB;IAE7B,SA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EAAE,KAAK,CAAC,OAAO;aACtB;SACD,CAAC,CACF;QACD,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,aAAa,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YAC7C,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;YACrC,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;YAChC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;YACtC,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC;SAC7C,CAAC,CAAC;QACH,aAAa,EAAE,aAAa,CAAC,aAAa;QAC1C,YAAY;KACZ,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Resolve which of a feature's rings are EXTERIORS and which are HOLES, from ring orientation — the one
|
|
7
|
+
* piece of this layer that no sibling builder already has, and the one whose absence is silent.
|
|
8
|
+
*
|
|
9
|
+
* THE SERVICE ENCODES HOLE ROLES BY ORIENTATION RATHER THAN BY NESTING, AND IT DOES IT ON MOST FEATURES.
|
|
10
|
+
* Measured over the whole national export (85,330 features, 93,483 rings): 89,967 rings are clockwise and
|
|
11
|
+
* 3,516 counter-clockwise; 84,021 features are wholly clockwise; and 1,309 features carry both windings.
|
|
12
|
+
* Of those, 1,210 nest their holes inside one polygon part the way RFC 7946 expects, and the rest put every
|
|
13
|
+
* ring in its own `MultiPolygon` part — the largest feature in the country, Meath's `RA - Rural Area`,
|
|
14
|
+
* arrives as 107 single-ring parts of which 5 are clockwise and 102 counter-clockwise. So the source uses
|
|
15
|
+
* BOTH encodings, the orientation is the only signal common to them, and a reader that took the nesting at
|
|
16
|
+
* face value would read 102 holes as 102 separate zoned areas.
|
|
17
|
+
*
|
|
18
|
+
* CLOCKWISE IS EXTERIOR, WHICH IS THE INVERSE OF RFC 7946, AND THE PUBLISHER'S OWN ARITHMETIC PROVES IT.
|
|
19
|
+
* Summing every ring's signed area over the export gives 5,444.492956 km²; the Department's own
|
|
20
|
+
* `Shape__Area` column sums to 5,444.492956 km². Summing the same rings' ABSOLUTE areas gives 5,666.569
|
|
21
|
+
* km². The signed reading matches the publisher to eight significant figures and the absolute one is 4.1%
|
|
22
|
+
* too large, so the counter-clockwise rings subtract under the publisher's own accounting: they are holes.
|
|
23
|
+
*
|
|
24
|
+
* THE HARMLESS HALF OF GETTING IT WRONG IS THE AREA. The harmful half is that a ray cast reading all 107 of
|
|
25
|
+
* Meath's rings as exteriors answers "inside `P5` rural zoning" for every location the plan carved out.
|
|
26
|
+
*
|
|
27
|
+
* AND GDAL CANNOT BE ASKED TO PRESERVE THIS. Its GeoJSON writer enforces the RFC 7946 winding
|
|
28
|
+
* unconditionally — `-lco RFC7946=NO` is not a GeoJSONSeq option and `--config OGR_ORGANIZE_POLYGONS SKIP`
|
|
29
|
+
* changes nothing — so a reprojected GeoJSON stream returns Meath as 107 counter-clockwise exteriors
|
|
30
|
+
* totalling 2,371.9 km² against the Department's 2,232.1 km². The same conversion written as WKT keeps the
|
|
31
|
+
* source's 5/102 split intact, which is why `sdk/ingest.ts` streams WKT.
|
|
32
|
+
*/
|
|
33
|
+
import { type MultiPolygonRings } from "@mailwoman/spatial";
|
|
34
|
+
/**
|
|
35
|
+
* One feature's rings, with the publisher's own hole roles resolved.
|
|
36
|
+
*/
|
|
37
|
+
export interface ResolvedRingRoles {
|
|
38
|
+
/**
|
|
39
|
+
* `[exterior, ...holes]` per polygon — the shape the ring blob stores and the point test reads.
|
|
40
|
+
*/
|
|
41
|
+
polygons: MultiPolygonRings;
|
|
42
|
+
exteriorCount: number;
|
|
43
|
+
holeCount: number;
|
|
44
|
+
/**
|
|
45
|
+
* Holes placed under an exterior that contains a majority of their sampled vertices.
|
|
46
|
+
*/
|
|
47
|
+
nestedHoles: number;
|
|
48
|
+
/**
|
|
49
|
+
* Holes NO exterior contains a majority of, placed under the smallest exterior of the same feature and counted here.
|
|
50
|
+
*
|
|
51
|
+
* Measured at 9 of 3,516 nationally, every one a sliver under 1.7 m² sitting on its parent's boundary. They are
|
|
52
|
+
* carried rather than dropped: the publisher's own area accounting subtracts them, so dropping one would add ground
|
|
53
|
+
* the plan carved out, and a feature with exactly one exterior — 8 of the 9 — has no ambiguity at all.
|
|
54
|
+
*/
|
|
55
|
+
adjacentHoles: number;
|
|
56
|
+
/**
|
|
57
|
+
* `1` where the feature's exterior was chosen by MAGNITUDE because no ring read as one by orientation.
|
|
58
|
+
*
|
|
59
|
+
* MEASURED AT ONE FEATURE OF 85,330, and its size is the reason the fallback exists rather than a refusal. `OBJECTID`
|
|
60
|
+
* 74040 — Galway County Council, `Agriculture` — is a single three-vertex ring enclosing 3.0 × 10⁻⁷ m², a third of a
|
|
61
|
+
* square micrometre. At that magnitude a ring's winding is floating-point noise rather than something the publisher
|
|
62
|
+
* stated: the same ring reads clockwise in the source's own Irish Transverse Mercator metres and counter-clockwise
|
|
63
|
+
* after reprojection. Refusing it would fail the build on the publisher's own data; dropping it would invent an
|
|
64
|
+
* absence. So the largest ring by magnitude becomes the exterior, which is also the correct reading for a feature
|
|
65
|
+
* published wholly inverted, and the count rides on the receipt rather than being implied to be zero.
|
|
66
|
+
*/
|
|
67
|
+
exteriorByMagnitude: number;
|
|
68
|
+
/**
|
|
69
|
+
* The signed ring sum over the source's rings AS PUBLISHED, in square metres — POSITIVE under this service's
|
|
70
|
+
* clockwise-exterior convention.
|
|
71
|
+
*
|
|
72
|
+
* The ingest's own receipt, stored on the row. It is what the build compares against the Department's `Shape__Area`
|
|
73
|
+
* sum, and its SIGN is the record that the orientation was read: a source that started publishing counter-clockwise
|
|
74
|
+
* exteriors would flip it, which is a fact about the source rather than a rounding difference.
|
|
75
|
+
*/
|
|
76
|
+
signedAreaM2: number;
|
|
77
|
+
ringCount: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Resolve one feature's hole roles from ring orientation.
|
|
81
|
+
*
|
|
82
|
+
* @param featureID Named in every refusal, so a build log says which feature rather than only that one failed.
|
|
83
|
+
* @throws {Error} When the feature carries no ring at all. That is the one case with no reading: a feature reduced to
|
|
84
|
+
* nothing reads downstream as an absence of zoning, which is the one answer this layer must never invent. A feature
|
|
85
|
+
* whose rings all read as holes DOES have a reading — see {@link ResolvedRingRoles.exteriorByMagnitude}.
|
|
86
|
+
*/
|
|
87
|
+
export declare function resolveRingRoles(polygons: MultiPolygonRings, featureID: string): ResolvedRingRoles;
|
|
88
|
+
//# sourceMappingURL=ring-roles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ring-roles.d.ts","sourceRoot":"","sources":["../lib/ring-roles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAiC,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAa1F;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB;;;;;;;;;;OAUG;IACH,mBAAmB,EAAE,MAAM,CAAA;IAC3B;;;;;;;OAOG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;CACjB;AAyCD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,CA6FlG"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Resolve which of a feature's rings are EXTERIORS and which are HOLES, from ring orientation — the one
|
|
7
|
+
* piece of this layer that no sibling builder already has, and the one whose absence is silent.
|
|
8
|
+
*
|
|
9
|
+
* THE SERVICE ENCODES HOLE ROLES BY ORIENTATION RATHER THAN BY NESTING, AND IT DOES IT ON MOST FEATURES.
|
|
10
|
+
* Measured over the whole national export (85,330 features, 93,483 rings): 89,967 rings are clockwise and
|
|
11
|
+
* 3,516 counter-clockwise; 84,021 features are wholly clockwise; and 1,309 features carry both windings.
|
|
12
|
+
* Of those, 1,210 nest their holes inside one polygon part the way RFC 7946 expects, and the rest put every
|
|
13
|
+
* ring in its own `MultiPolygon` part — the largest feature in the country, Meath's `RA - Rural Area`,
|
|
14
|
+
* arrives as 107 single-ring parts of which 5 are clockwise and 102 counter-clockwise. So the source uses
|
|
15
|
+
* BOTH encodings, the orientation is the only signal common to them, and a reader that took the nesting at
|
|
16
|
+
* face value would read 102 holes as 102 separate zoned areas.
|
|
17
|
+
*
|
|
18
|
+
* CLOCKWISE IS EXTERIOR, WHICH IS THE INVERSE OF RFC 7946, AND THE PUBLISHER'S OWN ARITHMETIC PROVES IT.
|
|
19
|
+
* Summing every ring's signed area over the export gives 5,444.492956 km²; the Department's own
|
|
20
|
+
* `Shape__Area` column sums to 5,444.492956 km². Summing the same rings' ABSOLUTE areas gives 5,666.569
|
|
21
|
+
* km². The signed reading matches the publisher to eight significant figures and the absolute one is 4.1%
|
|
22
|
+
* too large, so the counter-clockwise rings subtract under the publisher's own accounting: they are holes.
|
|
23
|
+
*
|
|
24
|
+
* THE HARMLESS HALF OF GETTING IT WRONG IS THE AREA. The harmful half is that a ray cast reading all 107 of
|
|
25
|
+
* Meath's rings as exteriors answers "inside `P5` rural zoning" for every location the plan carved out.
|
|
26
|
+
*
|
|
27
|
+
* AND GDAL CANNOT BE ASKED TO PRESERVE THIS. Its GeoJSON writer enforces the RFC 7946 winding
|
|
28
|
+
* unconditionally — `-lco RFC7946=NO` is not a GeoJSONSeq option and `--config OGR_ORGANIZE_POLYGONS SKIP`
|
|
29
|
+
* changes nothing — so a reprojected GeoJSON stream returns Meath as 107 counter-clockwise exteriors
|
|
30
|
+
* totalling 2,371.9 km² against the Department's 2,232.1 km². The same conversion written as WKT keeps the
|
|
31
|
+
* source's 5/102 split intact, which is why `sdk/ingest.ts` streams WKT.
|
|
32
|
+
*/
|
|
33
|
+
import { pointInRing, ringSignedAreaM2 } from "@mailwoman/spatial";
|
|
34
|
+
/**
|
|
35
|
+
* How many of a hole's vertices are tested against a candidate exterior.
|
|
36
|
+
*
|
|
37
|
+
* ONE VERTEX IS NOT ENOUGH, AND THAT WAS MEASURED. Holes in this product routinely share vertices with the exterior
|
|
38
|
+
* they sit in, and a ray cast at a point exactly on an edge is implementation-defined — so a first-vertex test leaves
|
|
39
|
+
* 26 of the 3,516 holes unplaced, while a majority vote over nine of their own vertices leaves 9. Every one of those 9
|
|
40
|
+
* is a degenerate sliver of between 0.0008 m² and 1.7 m², and the publisher's own area accounting subtracts all of
|
|
41
|
+
* them.
|
|
42
|
+
*/
|
|
43
|
+
const HOLE_VERTEX_SAMPLES = 9;
|
|
44
|
+
/**
|
|
45
|
+
* Flatten a feature's rings, whichever way the source nested them.
|
|
46
|
+
*
|
|
47
|
+
* DELIBERATELY DISCARDS THE ARRIVING NESTING. Both encodings reach here — a properly nested polygon and a pile of
|
|
48
|
+
* single-ring parts — and the orientation is the only signal that means the same thing in both. Keeping the nesting for
|
|
49
|
+
* the features that have it and inferring it for the ones that do not would put two rules over one artifact.
|
|
50
|
+
*/
|
|
51
|
+
function flattenRings(polygons) {
|
|
52
|
+
const rings = [];
|
|
53
|
+
for (const part of polygons) {
|
|
54
|
+
for (const ring of part) {
|
|
55
|
+
rings.push(ring);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return rings;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Does `outer` contain a majority of `ring`'s sampled vertices?
|
|
62
|
+
*/
|
|
63
|
+
function containsMajority(ring, outer) {
|
|
64
|
+
const stride = Math.max(1, Math.floor(ring.length / HOLE_VERTEX_SAMPLES));
|
|
65
|
+
let inside = 0;
|
|
66
|
+
let tested = 0;
|
|
67
|
+
for (let index = 0; index < ring.length; index += stride) {
|
|
68
|
+
tested++;
|
|
69
|
+
if (pointInRing(ring[index][0], ring[index][1], outer)) {
|
|
70
|
+
inside++;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return inside * 2 > tested;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Resolve one feature's hole roles from ring orientation.
|
|
77
|
+
*
|
|
78
|
+
* @param featureID Named in every refusal, so a build log says which feature rather than only that one failed.
|
|
79
|
+
* @throws {Error} When the feature carries no ring at all. That is the one case with no reading: a feature reduced to
|
|
80
|
+
* nothing reads downstream as an absence of zoning, which is the one answer this layer must never invent. A feature
|
|
81
|
+
* whose rings all read as holes DOES have a reading — see {@link ResolvedRingRoles.exteriorByMagnitude}.
|
|
82
|
+
*/
|
|
83
|
+
export function resolveRingRoles(polygons, featureID) {
|
|
84
|
+
const rings = flattenRings(polygons);
|
|
85
|
+
if (!rings.length) {
|
|
86
|
+
throw new Error(`zoning rings: feature ${featureID} carries no ring`);
|
|
87
|
+
}
|
|
88
|
+
const exteriors = [];
|
|
89
|
+
const holes = [];
|
|
90
|
+
let signedAreaM2 = 0;
|
|
91
|
+
for (const ring of rings) {
|
|
92
|
+
const signed = ringSignedAreaM2(ring);
|
|
93
|
+
signedAreaM2 += signed;
|
|
94
|
+
// CLOCKWISE IS EXTERIOR UNDER THIS SERVICE, and `ringSignedAreaM2` signs clockwise POSITIVE — see its docstring.
|
|
95
|
+
// A zero-area ring is degenerate rather than either role, and is carried as a hole so it can never enclose anything.
|
|
96
|
+
if (signed > 0) {
|
|
97
|
+
exteriors.push({ ring, area: signed, holes: [] });
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
holes.push(ring);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
let exteriorByMagnitude = 0;
|
|
104
|
+
// NO RING READ AS AN EXTERIOR, SO MAGNITUDE DECIDES — measured at exactly one feature of 85,330. The largest ring is
|
|
105
|
+
// the one that encloses the area, which is the correct reading both for a degenerate sliver whose winding is
|
|
106
|
+
// floating-point noise and for a feature published wholly inverted. Refusing here would fail the build on the
|
|
107
|
+
// publisher's own data, and skipping the feature would invent an absence.
|
|
108
|
+
if (!exteriors.length) {
|
|
109
|
+
let largestIndex = 0;
|
|
110
|
+
let largestArea = Math.abs(ringSignedAreaM2(holes[0]));
|
|
111
|
+
for (let index = 1; index < holes.length; index++) {
|
|
112
|
+
const area = Math.abs(ringSignedAreaM2(holes[index]));
|
|
113
|
+
if (area > largestArea) {
|
|
114
|
+
largestIndex = index;
|
|
115
|
+
largestArea = area;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const [largest] = holes.splice(largestIndex, 1);
|
|
119
|
+
exteriors.push({ ring: largest, area: largestArea, holes: [] });
|
|
120
|
+
exteriorByMagnitude = 1;
|
|
121
|
+
}
|
|
122
|
+
// SMALLEST CONTAINING EXTERIOR, so a hole inside an island inside a hole lands on the island rather than on the outer
|
|
123
|
+
// ring. Sorting once is cheaper than choosing per hole, and it makes the choice deterministic on a tie.
|
|
124
|
+
const bySize = [...exteriors].toSorted((left, right) => left.area - right.area);
|
|
125
|
+
let nestedHoles = 0;
|
|
126
|
+
let adjacentHoles = 0;
|
|
127
|
+
for (const hole of holes) {
|
|
128
|
+
const parent = bySize.find((exterior) => containsMajority(hole, exterior.ring));
|
|
129
|
+
if (parent) {
|
|
130
|
+
parent.holes.push(hole);
|
|
131
|
+
nestedHoles++;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
// A hole no exterior contains a majority of sits ON its parent's boundary — measured at 9 of 3,516 nationally, all
|
|
135
|
+
// under 1.7 m². It goes to the smallest exterior of the same feature, which is the only exterior at all on 8 of the
|
|
136
|
+
// 9, and is counted so a receipt can carry the number rather than imply it is zero.
|
|
137
|
+
bySize[0].holes.push(hole);
|
|
138
|
+
adjacentHoles++;
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
polygons: exteriors.map((exterior) => [exterior.ring, ...exterior.holes]),
|
|
142
|
+
exteriorCount: exteriors.length,
|
|
143
|
+
holeCount: holes.length,
|
|
144
|
+
nestedHoles,
|
|
145
|
+
adjacentHoles,
|
|
146
|
+
exteriorByMagnitude,
|
|
147
|
+
signedAreaM2,
|
|
148
|
+
ringCount: rings.length,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=ring-roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ring-roles.js","sourceRoot":"","sources":["../lib/ring-roles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAA0B,MAAM,oBAAoB,CAAA;AAE1F;;;;;;;;GAQG;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAA;AAgD7B;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,QAA2B;IAChD,MAAM,KAAK,GAA4C,EAAE,CAAA;IAEzD,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC7B,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjB,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAA;AACb,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CAAC,IAAsC,EAAE,KAAuC;IACxG,MAAM,MAAM,GAAG,I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AAa,GAAG,CAAC,CAAA;IAErB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;QAE/E,IAAI,MAAM,EAAE,CAAC;YACZ,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAEvB,WAAW,EAAE,CAAA;YAEb,SAAQ;QACT,CAAC;QAED,mHAAmH;QACnH,oHAAoH;QACpH,oFAAoF;QACpF,MAAM,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAE3B,aAAa,EAAE,CAAA;IAChB,CAAC;IAED,OAAO;QACN,QAAQ,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QACzE,aAAa,EAAE,SAAS,CAAC,MAAM;QAC/B,SAAS,EAAE,KAAK,CAAC,MAAM;QACvB,WAAW;QACX,aAAa;QACb,mBAAmB;QACnB,YAAY;QACZ,SAAS,EAAE,KAAK,CAAC,MAAM;KACvB,CAAA;AACF,CAAC"}
|
package/out/rings.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* `zoning_area.rings` — the blob layout and the point test that reads it.
|
|
7
|
+
*
|
|
8
|
+
* THE CODE ITSELF LIVES IN `@mailwoman/spatial`, re-exported here so this package's call sites and its
|
|
9
|
+
* `@mailwoman/zoning/rings` subpath keep reading the same. Nothing in it is zoning-specific: it is byte
|
|
10
|
+
* layout plus spherical geometry, and a second copy of the alignment arithmetic or of the signed-area
|
|
11
|
+
* reading is a second place for either to stop being right. Both failure modes are silent — a mis-read blob
|
|
12
|
+
* answers a containment question wrongly, and a hole-blind area reading answers "inside" for every point in
|
|
13
|
+
* a hole.
|
|
14
|
+
*
|
|
15
|
+
* WHAT IS NOT SHARED IS {@linkcode resolveRingRoles}, and the reason is that it is a fact about THIS
|
|
16
|
+
* PUBLISHER rather than about geometry: the service encodes hole roles by ring ORIENTATION, clockwise
|
|
17
|
+
* exterior, which is the inverse of RFC 7946's convention. `ring-roles.ts` carries it with the measurement
|
|
18
|
+
* that establishes it.
|
|
19
|
+
*/
|
|
20
|
+
export { decodeRings, encodeRings, pointInEncodedRings, RING_BLOB_VERSION, ringAreaReadings, ringSignedAreaM2, ringsBoundingBox, type DecodedRings, type MultiPolygonRings, type PolygonRings, } from "@mailwoman/spatial";
|
|
21
|
+
export { resolveRingRoles, type ResolvedRingRoles } from "#ring-roles";
|
|
22
|
+
//# sourceMappingURL=rings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rings.d.ts","sourceRoot":"","sources":["../lib/rings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACN,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,YAAY,GACjB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAA"}
|
package/out/rings.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* `zoning_area.rings` — the blob layout and the point test that reads it.
|
|
7
|
+
*
|
|
8
|
+
* THE CODE ITSELF LIVES IN `@mailwoman/spatial`, re-exported here so this package's call sites and its
|
|
9
|
+
* `@mailwoman/zoning/rings` subpath keep reading the same. Nothing in it is zoning-specific: it is byte
|
|
10
|
+
* layout plus spherical geometry, and a second copy of the alignment arithmetic or of the signed-area
|
|
11
|
+
* reading is a second place for either to stop being right. Both failure modes are silent — a mis-read blob
|
|
12
|
+
* answers a containment question wrongly, and a hole-blind area reading answers "inside" for every point in
|
|
13
|
+
* a hole.
|
|
14
|
+
*
|
|
15
|
+
* WHAT IS NOT SHARED IS {@linkcode resolveRingRoles}, and the reason is that it is a fact about THIS
|
|
16
|
+
* PUBLISHER rather than about geometry: the service encodes hole roles by ring ORIENTATION, clockwise
|
|
17
|
+
* exterior, which is the inverse of RFC 7946's convention. `ring-roles.ts` carries it with the measurement
|
|
18
|
+
* that establishes it.
|
|
19
|
+
*/
|
|
20
|
+
export { decodeRings, encodeRings, pointInEncodedRings, RING_BLOB_VERSION, ringAreaReadings, ringSignedAreaM2, ringsBoundingBox, } from "@mailwoman/spatial";
|
|
21
|
+
export { resolveRingRoles } from "#ring-roles";
|
|
22
|
+
//# sourceMappingURL=rings.js.map
|
package/out/rings.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rings.js","sourceRoot":"","sources":["../lib/rings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACN,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GAIhB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,gBAAgB,EAA0B,MAAM,aAAa,CAAA"}
|