@mailwoman/zoning 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +315 -0
- package/lib/index.ts +616 -0
- package/lib/ring-roles.ts +233 -0
- package/lib/rings.ts +34 -0
- package/lib/schema.ts +449 -0
- package/lib/scripts/ingest-chunk.ts +41 -0
- package/lib/sdk/build-zoning.ts +790 -0
- package/lib/sdk/cells.ts +276 -0
- package/lib/sdk/client.ts +335 -0
- package/lib/sdk/download.ts +78 -0
- package/lib/sdk/index.ts +15 -0
- package/lib/sdk/ingest-chunk.ts +360 -0
- package/lib/sdk/ingest.ts +402 -0
- package/lib/sdk/measure-resolutions.ts +100 -0
- package/lib/sdk/verify.ts +350 -0
- package/lib/test-kit.ts +207 -0
- package/lib/vocabulary.ts +342 -0
- package/out/index.d.ts +257 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +325 -0
- package/out/index.js.map +1 -0
- package/out/ring-roles.d.ts +88 -0
- package/out/ring-roles.d.ts.map +1 -0
- package/out/ring-roles.js +151 -0
- package/out/ring-roles.js.map +1 -0
- package/out/rings.d.ts +22 -0
- package/out/rings.d.ts.map +1 -0
- package/out/rings.js +22 -0
- package/out/rings.js.map +1 -0
- package/out/schema.d.ts +325 -0
- package/out/schema.d.ts.map +1 -0
- package/out/schema.js +186 -0
- package/out/schema.js.map +1 -0
- package/out/scripts/ingest-chunk.d.ts +11 -0
- package/out/scripts/ingest-chunk.d.ts.map +1 -0
- package/out/scripts/ingest-chunk.js +36 -0
- package/out/scripts/ingest-chunk.js.map +1 -0
- package/out/sdk/build-zoning.d.ts +283 -0
- package/out/sdk/build-zoning.d.ts.map +1 -0
- package/out/sdk/build-zoning.js +462 -0
- package/out/sdk/build-zoning.js.map +1 -0
- package/out/sdk/cells.d.ts +137 -0
- package/out/sdk/cells.d.ts.map +1 -0
- package/out/sdk/cells.js +176 -0
- package/out/sdk/cells.js.map +1 -0
- package/out/sdk/client.d.ts +151 -0
- package/out/sdk/client.d.ts.map +1 -0
- package/out/sdk/client.js +239 -0
- package/out/sdk/client.js.map +1 -0
- package/out/sdk/download.d.ts +51 -0
- package/out/sdk/download.d.ts.map +1 -0
- package/out/sdk/download.js +57 -0
- package/out/sdk/download.js.map +1 -0
- package/out/sdk/index.d.ts +15 -0
- package/out/sdk/index.d.ts.map +1 -0
- package/out/sdk/index.js +15 -0
- package/out/sdk/index.js.map +1 -0
- package/out/sdk/ingest-chunk.d.ts +130 -0
- package/out/sdk/ingest-chunk.d.ts.map +1 -0
- package/out/sdk/ingest-chunk.js +206 -0
- package/out/sdk/ingest-chunk.js.map +1 -0
- package/out/sdk/ingest.d.ts +191 -0
- package/out/sdk/ingest.d.ts.map +1 -0
- package/out/sdk/ingest.js +238 -0
- package/out/sdk/ingest.js.map +1 -0
- package/out/sdk/measure-resolutions.d.ts +51 -0
- package/out/sdk/measure-resolutions.d.ts.map +1 -0
- package/out/sdk/measure-resolutions.js +64 -0
- package/out/sdk/measure-resolutions.js.map +1 -0
- package/out/sdk/verify.d.ts +176 -0
- package/out/sdk/verify.d.ts.map +1 -0
- package/out/sdk/verify.js +202 -0
- package/out/sdk/verify.js.map +1 -0
- package/out/test-kit.d.ts +97 -0
- package/out/test-kit.d.ts.map +1 -0
- package/out/test-kit.js +180 -0
- package/out/test-kit.js.map +1 -0
- package/out/vocabulary.d.ts +221 -0
- package/out/vocabulary.d.ts.map +1 -0
- package/out/vocabulary.js +299 -0
- package/out/vocabulary.js.map +1 -0
- package/package.json +245 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Build `zoning-ireland.db` — the sealed two-tier polygon layer, from the Department's bulk export.
|
|
7
|
+
*
|
|
8
|
+
* THE COVERAGE IS `source_present` AND THE TIER IS `build-local`, AND THE TWO ARE INDEPENDENT REFUSALS.
|
|
9
|
+
* The coverage basis is about what the source can support: the Department publishes its coverage detail only
|
|
10
|
+
* inside a map viewer, so an absent zoning polygon is one of at least four different things and
|
|
11
|
+
* {@linkcode assertNoNegativeClaim} refuses anything stronger before a row is written. The tier is about
|
|
12
|
+
* what the LICENCE supports: three published statements disagree about the grant, so
|
|
13
|
+
* {@linkcode assertTierMatchesLicense} refuses a `shipped` build. Resolving either one does not resolve the
|
|
14
|
+
* other.
|
|
15
|
+
*
|
|
16
|
+
* THE AREA CHECK IS THE HOLE CHECK AND THE ONE THING HERE THAT IS EXACT. The service encodes hole
|
|
17
|
+
* roles by ring orientation, and reading them wrong is silent — a hole read as an exterior produces a
|
|
18
|
+
* well-formed polygon that answers "inside" for every location the plan carved out. Measured over the whole
|
|
19
|
+
* national export: the rings read WITH their holes total 5,444.5 km² and the Department's own `Shape__Area`
|
|
20
|
+
* sums to 5,444.5 km²; the same rings read WITHOUT their holes total 5,666.6 km². The publisher's figure has
|
|
21
|
+
* to come from the live service, because the bulk export drops the column — which is what makes this a
|
|
22
|
+
* two-path check rather than the archive agreeing with itself.
|
|
23
|
+
*
|
|
24
|
+
* THERE IS NO BUILD-TIME TOUCH TABLE. A zoning cell row names ONE POLYGON, so it is final the moment that
|
|
25
|
+
* polygon is classified. The rows go straight in, and memory stays flat in row count with nothing to resolve
|
|
26
|
+
* afterwards.
|
|
27
|
+
*
|
|
28
|
+
* THE INGEST IS BOUNDED ANYWAY. h3's WASM heap cannot be reset from JavaScript and does not survive an
|
|
29
|
+
* unbounded number of polyfill calls; a sibling product died twice on that, after roughly 510,000 and
|
|
30
|
+
* 798,000 features. This product holds 85,330, so the whole country fits inside the 100,000-id default with
|
|
31
|
+
* room to spare — and the bound still ships, because a build that stays inside a ceiling by luck is not the
|
|
32
|
+
* same fact as one that cannot cross it.
|
|
33
|
+
*
|
|
34
|
+
* THE JURISDICTION, PLAN AND VOCABULARY ROWS ARE WRITTEN BY THE PARENT, once, from the merged chunk
|
|
35
|
+
* reports. They are the only tables whose rows are partials across chunks — an authority and a plan appear
|
|
36
|
+
* in every chunk that touches them — and merging them in the parent is what keeps the chunk append-only.
|
|
37
|
+
*/
|
|
38
|
+
import { readFileSize } from "@mailwoman/core/fs/readers";
|
|
39
|
+
import { areaAgreementFrom, assertNoNegativeClaim as assertCoverageNoNegativeClaim, CoverageBasis, createLayerCoverageTable, createLayerManifestTable, LayerTier, polygonLayerManifest, sourcePresentCoverageCells, writeLayerCoverage, writeLayerManifest, } from "@mailwoman/core/layers";
|
|
40
|
+
import { resolveModulePath } from "@mailwoman/core/module/resolvers";
|
|
41
|
+
import { ingestChunkArguments, mergeCountsInto, runChunkProcess } from "@mailwoman/core/utils";
|
|
42
|
+
import { M2_PER_KM2 } from "@mailwoman/spatial";
|
|
43
|
+
import { buildSealedArtifact } from "@mailwoman/sqlite/sealed-build";
|
|
44
|
+
import { createZoningTables } from "#schema";
|
|
45
|
+
import { ingestZoningChunk } from "#sdk/ingest-chunk";
|
|
46
|
+
import { assertTierMatchesLicense, GZT_ATTRIBUTION, GZT_COVERAGE_LIMIT, GZT_CROSSWALK_SCHEME, GZT_DECLARED_CODES, GZT_DECLARED_CODE_SET, GZT_ITEM_ID, GZT_LAYER_NAME, GZT_LICENSE, GZT_PLAN_LEVELS, } from "#vocabulary";
|
|
47
|
+
/**
|
|
48
|
+
* Schema version of the domain tables. Bumped when a column changes meaning, never for an added column a reader can
|
|
49
|
+
* ignore.
|
|
50
|
+
*/
|
|
51
|
+
export const ZONING_SCHEMA_VERSION = 1;
|
|
52
|
+
/**
|
|
53
|
+
* The plan-level vocabulary scheme.
|
|
54
|
+
*/
|
|
55
|
+
export const PLAN_LEVEL_SCHEME = "IE-PLAN-LEVEL";
|
|
56
|
+
/**
|
|
57
|
+
* Feature ids per chunk process.
|
|
58
|
+
*
|
|
59
|
+
* Sized against the measured ceiling on a sibling product rather than guessed: single-process runs over that layer died
|
|
60
|
+
* after roughly 510,000 and 798,000 features as h3's WASM heap fragmented. This product holds 85,330 features, so this
|
|
61
|
+
* default puts the whole country in one process — and it is the ceiling that makes the build reproducible rather than
|
|
62
|
+
* the fact that this product happens to sit below it.
|
|
63
|
+
*
|
|
64
|
+
* A SMALLER CHUNK COSTS A FULL PASS EACH. The source is one 247 MB GeoJSON document rather than an indexed store, so
|
|
65
|
+
* ogr2ogr scans all of it per range: measured at 13.2 s per pass on this lab.
|
|
66
|
+
*/
|
|
67
|
+
export const DEFAULT_CHUNK_SIZE = 100_000;
|
|
68
|
+
/**
|
|
69
|
+
* The relative gap between the two area readings that fails the build.
|
|
70
|
+
*
|
|
71
|
+
* The comparison is a SPHERICAL ring area against the publisher's PLANAR figure in Irish Transverse Mercator, so the
|
|
72
|
+
* two never agree exactly: ITM's scale factor runs 0.99982 at its central meridian and above 1 towards the edges of the
|
|
73
|
+
* island, which contributes a few tenths of a percent to an area, and the spherical approximation contributes a similar
|
|
74
|
+
* amount against the ellipsoid. Measured on the largest feature in the country: 2,223.1 km² spherical against the
|
|
75
|
+
* Department's 2,232.1 km², 0.40% apart. One percent leaves that comfortably inside the tolerance while sitting well
|
|
76
|
+
* below the 4.1% a hole-blind read produces over the same set.
|
|
77
|
+
*/
|
|
78
|
+
const AREA_TOLERANCE = 0.01;
|
|
79
|
+
/**
|
|
80
|
+
* How many non-functional crosswalk pairs the receipt names.
|
|
81
|
+
*/
|
|
82
|
+
const WORST_PAIRS_REPORTED = 8;
|
|
83
|
+
/**
|
|
84
|
+
* Build the layer.
|
|
85
|
+
*
|
|
86
|
+
* @throws {Error} On a feature that reaches no cell, a feature count that disagrees with the source's own declaration,
|
|
87
|
+
* an area total that disagrees with the publisher's, a coverage row that would license a negative claim, a crosswalk
|
|
88
|
+
* edge table written while the mapping is not a function, or a `shipped` tier asked for under an unresolved licence.
|
|
89
|
+
*/
|
|
90
|
+
export async function buildZoningDatabase(options) {
|
|
91
|
+
const tier = options.tier ?? LayerTier.BuildLocal;
|
|
92
|
+
assertTierMatchesLicense(tier, GZT_LICENSE);
|
|
93
|
+
if (options.coverageResolution >= options.indexResolution) {
|
|
94
|
+
throw new Error(`zoning build: the coverage resolution (${options.coverageResolution}) must be coarser than the index resolution (${options.indexResolution}) — a row's coverage cell is the PARENT of its index cell`);
|
|
95
|
+
}
|
|
96
|
+
const batched = "batched" in options ? options.batched : undefined;
|
|
97
|
+
const source = "batched" in options ? undefined : options.source;
|
|
98
|
+
const declaredFeatureCount = batched ? batched.declaredFeatureCount : source.declaredFeatureCount;
|
|
99
|
+
options.onProgress?.(batched
|
|
100
|
+
? `source: ${batched.exportPath} · ${declaredFeatureCount.toLocaleString()} features`
|
|
101
|
+
: `source: EPSG:${source.epsg} · ${declaredFeatureCount.toLocaleString()} features · ${source.origin}`);
|
|
102
|
+
const built = await buildSealedArtifact({
|
|
103
|
+
out: options.out,
|
|
104
|
+
createTables: async (kdb) => {
|
|
105
|
+
await createZoningTables(kdb);
|
|
106
|
+
await createLayerManifestTable(kdb);
|
|
107
|
+
await createLayerCoverageTable(kdb);
|
|
108
|
+
},
|
|
109
|
+
ingest: async (kdb) => {
|
|
110
|
+
if (!source)
|
|
111
|
+
return undefined;
|
|
112
|
+
return aggregateChunks([
|
|
113
|
+
await ingestZoningChunk(kdb, {
|
|
114
|
+
source,
|
|
115
|
+
indexResolution: options.indexResolution,
|
|
116
|
+
coverageResolution: options.coverageResolution,
|
|
117
|
+
...(options.onProgress ? { onProgress: options.onProgress } : {}),
|
|
118
|
+
}),
|
|
119
|
+
]);
|
|
120
|
+
},
|
|
121
|
+
...(batched ? { batched: (tmpPath) => runBatchedIngest(tmpPath, options, batched) } : {}),
|
|
122
|
+
finish: async (kdb, ingested) => buildZoningResult(kdb, options, tier, declaredFeatureCount, ingested),
|
|
123
|
+
});
|
|
124
|
+
return { ...built, sizeBytes: await readFileSize(options.out) };
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The post-ingest half of the build, under the second handle: the assertions over what was streamed, then every
|
|
128
|
+
* artifact table beyond the truth tables.
|
|
129
|
+
*/
|
|
130
|
+
async function buildZoningResult(kdb, options, tier, declaredFeatureCount, ingested) {
|
|
131
|
+
if (ingested.features !== declaredFeatureCount) {
|
|
132
|
+
throw new Error(`zoning build: streamed ${ingested.features} features, the source declares ${declaredFeatureCount} — a short read builds a smaller country and reports success`);
|
|
133
|
+
}
|
|
134
|
+
if (options.expectedFeatureCount !== undefined && ingested.features !== options.expectedFeatureCount) {
|
|
135
|
+
throw new Error(`zoning build: streamed ${ingested.features} features and the live service reports ${options.expectedFeatureCount} — the archive is a different vintage from the one the service is publishing`);
|
|
136
|
+
}
|
|
137
|
+
const area = assertAreaAgreement(ingested, options.expectedSourceAreaM2);
|
|
138
|
+
// THE CROSSWALK IS NOT A TABLE, AND THE BUILD CHECKS IT RATHER THAN ASSUMING IT. Writing no edges while the mapping
|
|
139
|
+
// happens not to be a function would be an accident; refusing to write them while it is not is a statement.
|
|
140
|
+
const nonFunctional = nonFunctionalPairs(ingested.crosswalkPairs);
|
|
141
|
+
assertCrosswalkIsNotATable(ingested.crosswalkPairs, 0);
|
|
142
|
+
options.onProgress?.(`${ingested.features.toLocaleString()} zoning polygons written · ${ingested.rings.total.toLocaleString()} rings ` +
|
|
143
|
+
`(${ingested.rings.exteriors.toLocaleString()} exterior, ${ingested.rings.holes.toLocaleString()} hole)`);
|
|
144
|
+
writeJurisdictionRows(kdb, ingested.jurisdictions);
|
|
145
|
+
writePlanRows(kdb, ingested.plans);
|
|
146
|
+
const vocabulary = writeVocabularyRows(kdb, ingested.vocabulary);
|
|
147
|
+
const coverage = sourcePresentCoverageCells(ingested.observedByCoverageCell);
|
|
148
|
+
assertNoNegativeClaim(coverage);
|
|
149
|
+
await writeLayerCoverage(kdb, coverage);
|
|
150
|
+
await writeLayerManifest(kdb, polygonLayerManifest(options, {
|
|
151
|
+
name: GZT_LAYER_NAME,
|
|
152
|
+
schemaVersion: ZONING_SCHEMA_VERSION,
|
|
153
|
+
license: GZT_LICENSE,
|
|
154
|
+
attribution: GZT_ATTRIBUTION,
|
|
155
|
+
source: `arcgis.com item ${GZT_ITEM_ID}`,
|
|
156
|
+
cellColumn: "zoning_cell.h3_cell",
|
|
157
|
+
tier,
|
|
158
|
+
}));
|
|
159
|
+
const storedResolutions = kdb.prepare("SELECT DISTINCT resolution FROM zoning_cell ORDER BY resolution").all().map((row) => row.resolution);
|
|
160
|
+
// NO SECONDARY INDEXES, AND THAT IS A DECISION RATHER THAN AN OMISSION. Both probes this artifact serves are already
|
|
161
|
+
// primary-key probes: the cell table's `(h3_cell, area_id)` key answers `WHERE h3_cell = ?` as a range scan of a
|
|
162
|
+
// handful of rows, and the geometry table is probed by `area_id`, its own key. An index over a `WITHOUT ROWID` table
|
|
163
|
+
// carries the primary key in every entry, so it would roughly double the cell tier to serve a scan that is already
|
|
164
|
+
// short.
|
|
165
|
+
const totalCellRows = ingested.wholeCellRows + ingested.partialCellRows;
|
|
166
|
+
return {
|
|
167
|
+
out: options.out,
|
|
168
|
+
features: ingested.features,
|
|
169
|
+
jurisdictions: ingested.jurisdictions.length,
|
|
170
|
+
plans: ingested.plans.length,
|
|
171
|
+
indexResolution: options.indexResolution,
|
|
172
|
+
coverageResolution: options.coverageResolution,
|
|
173
|
+
wholeCellRows: ingested.wholeCellRows,
|
|
174
|
+
partialCellRows: ingested.partialCellRows,
|
|
175
|
+
storedPartialShare: totalCellRows ? ingested.partialCellRows / totalCellRows : 0,
|
|
176
|
+
coarsenedFeatures: ingested.coarsened,
|
|
177
|
+
storedResolutions,
|
|
178
|
+
coverageCells: coverage.length,
|
|
179
|
+
coverageBasis: CoverageBasis.SourcePresent,
|
|
180
|
+
tier,
|
|
181
|
+
license: GZT_LICENSE,
|
|
182
|
+
rings: ingested.rings,
|
|
183
|
+
area,
|
|
184
|
+
vocabulary,
|
|
185
|
+
crosswalk: {
|
|
186
|
+
pairs: ingested.crosswalkPairs.length,
|
|
187
|
+
nonFunctionalPairs: nonFunctional.length,
|
|
188
|
+
worst: nonFunctional
|
|
189
|
+
.toSorted((left, right) => right[2].length - left[2].length)
|
|
190
|
+
.slice(0, WORST_PAIRS_REPORTED)
|
|
191
|
+
.map(([authorityCode, localCode, crosswalkCodes]) => ({ authorityCode, localCode, crosswalkCodes })),
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Add up what the chunks reported.
|
|
197
|
+
*
|
|
198
|
+
* Exported for its own test: the coverage-cell arithmetic and the crosswalk-pair merge are the parts of the batched
|
|
199
|
+
* path a fixture build cannot reach, and getting either wrong produces a well-formed artifact — one that under-reports
|
|
200
|
+
* how many polygons a cell holds, or one that reports a mapping as a function because no single chunk saw it break.
|
|
201
|
+
*/
|
|
202
|
+
export function aggregateChunks(chunks) {
|
|
203
|
+
const observedByCoverageCell = new Map();
|
|
204
|
+
const jurisdictions = new Map();
|
|
205
|
+
const plans = new Map();
|
|
206
|
+
const vocabulary = new Map();
|
|
207
|
+
const crosswalkPairs = new Map();
|
|
208
|
+
const pairNames = new Map();
|
|
209
|
+
let features = 0;
|
|
210
|
+
let coarsened = 0;
|
|
211
|
+
let wholeCellRows = 0;
|
|
212
|
+
let partialCellRows = 0;
|
|
213
|
+
let signedArea = 0;
|
|
214
|
+
let nestedArea = 0;
|
|
215
|
+
let allExteriorArea = 0;
|
|
216
|
+
let ringsTotal = 0;
|
|
217
|
+
let exteriors = 0;
|
|
218
|
+
let holes = 0;
|
|
219
|
+
let nestedHoles = 0;
|
|
220
|
+
let adjacentHoles = 0;
|
|
221
|
+
let exteriorByMagnitude = 0;
|
|
222
|
+
for (const chunk of chunks) {
|
|
223
|
+
features += chunk.features;
|
|
224
|
+
coarsened += chunk.coarsened;
|
|
225
|
+
wholeCellRows += chunk.wholeCellRows;
|
|
226
|
+
partialCellRows += chunk.partialCellRows;
|
|
227
|
+
signedArea += chunk.area.signedM2;
|
|
228
|
+
nestedArea += chunk.area.nestedM2;
|
|
229
|
+
allExteriorArea += chunk.area.allExteriorM2;
|
|
230
|
+
ringsTotal += chunk.rings.total;
|
|
231
|
+
exteriors += chunk.rings.exteriors;
|
|
232
|
+
holes += chunk.rings.holes;
|
|
233
|
+
nestedHoles += chunk.rings.nestedHoles;
|
|
234
|
+
adjacentHoles += chunk.rings.adjacentHoles;
|
|
235
|
+
exteriorByMagnitude += chunk.rings.exteriorByMagnitude;
|
|
236
|
+
// A coverage cell straddles chunk boundaries, so the counts ADD rather than replace. Taking the last chunk's value
|
|
237
|
+
// would report a cell as holding only the last chunk's polygons.
|
|
238
|
+
mergeCountsInto(observedByCoverageCell, chunk.observedByCoverageCell);
|
|
239
|
+
for (const [code, name] of chunk.jurisdictions) {
|
|
240
|
+
jurisdictions.set(code, name);
|
|
241
|
+
}
|
|
242
|
+
for (const plan of chunk.plans) {
|
|
243
|
+
if (!plans.has(plan.planID)) {
|
|
244
|
+
plans.set(plan.planID, plan);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
for (const [scheme, code, label, rows] of chunk.vocabulary) {
|
|
248
|
+
const key = `${scheme}\u0000${code}`;
|
|
249
|
+
const existing = vocabulary.get(key);
|
|
250
|
+
vocabulary.set(key, existing ? [scheme, code, existing[2], existing[3] + rows] : [scheme, code, label, rows]);
|
|
251
|
+
}
|
|
252
|
+
// THE PAIRS MERGE AS A UNION, and that is the whole point of doing it here. A mapping that is not a function can look
|
|
253
|
+
// like one inside any single chunk: Cork's `Special Policy Area` takes 14 generic types across the county, and a
|
|
254
|
+
// chunk holding a prefix of its feature ids may well have seen only one of them.
|
|
255
|
+
for (const [authorityCode, localCode, codes] of chunk.crosswalkPairs) {
|
|
256
|
+
const key = `${authorityCode}\u0000${localCode}`;
|
|
257
|
+
const existing = crosswalkPairs.get(key);
|
|
258
|
+
pairNames.set(key, [authorityCode, localCode]);
|
|
259
|
+
if (existing) {
|
|
260
|
+
for (const code of codes) {
|
|
261
|
+
existing.add(code);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
crosswalkPairs.set(key, new Set(codes));
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
features,
|
|
271
|
+
coarsened,
|
|
272
|
+
wholeCellRows,
|
|
273
|
+
partialCellRows,
|
|
274
|
+
observedByCoverageCell,
|
|
275
|
+
area: { signedM2: signedArea, nestedM2: nestedArea, allExteriorM2: allExteriorArea },
|
|
276
|
+
rings: { total: ringsTotal, exteriors, holes, nestedHoles, adjacentHoles, exteriorByMagnitude },
|
|
277
|
+
jurisdictions: [...jurisdictions],
|
|
278
|
+
plans: [...plans.values()],
|
|
279
|
+
vocabulary: [...vocabulary.values()],
|
|
280
|
+
crosswalkPairs: [...crosswalkPairs].map(([key, codes]) => {
|
|
281
|
+
const [authorityCode, localCode] = pairNames.get(key);
|
|
282
|
+
return [authorityCode, localCode, [...codes].toSorted()];
|
|
283
|
+
}),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* The (authority, local code) pairs that take more than one generic type.
|
|
288
|
+
*/
|
|
289
|
+
export function nonFunctionalPairs(pairs) {
|
|
290
|
+
return pairs.filter((pair) => pair[2].length > 1);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Refuse a crosswalk EDGE TABLE while the publisher's mapping is not a function of the (authority, code) pair.
|
|
294
|
+
*
|
|
295
|
+
* An edge table asserts that a code determines a type. Measured nationally, 52 of 795 pairs take more than one — Cork
|
|
296
|
+
* County Council's `Special Policy Area` takes 14 — so an edge table built from this data would have to pick one type
|
|
297
|
+
* per pair and would be this package's invention rather than the Department's mapping. The mapping lives per polygon,
|
|
298
|
+
* on `zoning_area`, where the Department put it.
|
|
299
|
+
*
|
|
300
|
+
* @throws {Error} When edges would be written while any pair is non-functional.
|
|
301
|
+
*/
|
|
302
|
+
export function assertCrosswalkIsNotATable(pairs, edgeCount) {
|
|
303
|
+
if (!edgeCount)
|
|
304
|
+
return;
|
|
305
|
+
const broken = nonFunctionalPairs(pairs);
|
|
306
|
+
if (!broken.length)
|
|
307
|
+
return;
|
|
308
|
+
const worst = broken.toSorted((left, right) => right[2].length - left[2].length)[0];
|
|
309
|
+
throw new Error(`zoning build: ${edgeCount} crosswalk edge(s) would be written while ${broken.length} of ${pairs.length} ` +
|
|
310
|
+
`(authority, local code) pairs take more than one generic type — ${worst[0]} ${JSON.stringify(worst[1])} takes ` +
|
|
311
|
+
`${worst[2].length} (${worst[2].join(", ")}). An edge table asserts that a code determines a type, and this ` +
|
|
312
|
+
"publisher assigns the type per polygon, so the table would be this build's invention rather than the authority's mapping");
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Refuse an artifact whose rings do not add up to the area the publisher itself reports.
|
|
316
|
+
*
|
|
317
|
+
* The message carries the hole-blind total beside the nested one, because the gap between them is the diagnosis: a hole
|
|
318
|
+
* read as an exterior ring answers "inside" for every point in it.
|
|
319
|
+
*/
|
|
320
|
+
function assertAreaAgreement(streamed, expectedSourceAreaM2) {
|
|
321
|
+
const signedKM2 = streamed.area.signedM2 / M2_PER_KM2;
|
|
322
|
+
// THE PUBLISHER'S FIGURE IS ABSENT RATHER THAN DEFAULTED — the reading's own type says so. Filling it with this
|
|
323
|
+
// build's own reading would make the receipt print "0.000% apart" for a check that never ran, which is the one shape
|
|
324
|
+
// a reader cannot tell from a pass.
|
|
325
|
+
const reading = areaAgreementFrom({ nestedM2: streamed.area.nestedM2, allExteriorM2: streamed.area.allExteriorM2 }, expectedSourceAreaM2);
|
|
326
|
+
const area = { ...reading, signedKM2 };
|
|
327
|
+
if (reading.witness === "absent" || reading.relativeGap <= AREA_TOLERANCE)
|
|
328
|
+
return area;
|
|
329
|
+
throw new Error(`zoning build: the encoded rings total ${reading.nestedKM2.toFixed(1)} km² against the publisher's ${reading.sourceKM2.toFixed(1)} km² ` +
|
|
330
|
+
`(${(reading.relativeGap * 100).toFixed(2)}% apart, tolerance ${(AREA_TOLERANCE * 100).toFixed(0)}%). Read without their holes the same rings total ` +
|
|
331
|
+
`${reading.allExteriorKM2.toFixed(1)} km², so compare the two: a hole-blind read answers "inside" for every point in a hole`);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Run the ingest as a sequence of bounded child processes, over ranges of the authority's own feature ids.
|
|
335
|
+
*
|
|
336
|
+
* THE PARENT HOLDS NO HANDLE WHILE THEY RUN — its caller closed one before this and opens another after. Each child
|
|
337
|
+
* opens the same file and appends; chunks run one at a time, so there is exactly one writer at every instant and no
|
|
338
|
+
* locking to reason about.
|
|
339
|
+
*
|
|
340
|
+
* @throws {Error} When a chunk exits non-zero, or prints no result line — a chunk that died mid-range has written a
|
|
341
|
+
* partial set of rows, and continuing would seal an artifact missing features nobody could name.
|
|
342
|
+
*/
|
|
343
|
+
async function runBatchedIngest(tmpPath, options, batched) {
|
|
344
|
+
const chunkSize = batched.chunkSize ?? DEFAULT_CHUNK_SIZE;
|
|
345
|
+
const script = resolveModulePath("@mailwoman/zoning/scripts/ingest-chunk");
|
|
346
|
+
const chunks = [];
|
|
347
|
+
// The upper bound is deliberately open — the source reports a count, not a maximum id, and a range that stopped at the
|
|
348
|
+
// count would drop every feature past a gap in the numbering.
|
|
349
|
+
let from = 1;
|
|
350
|
+
for (;;) {
|
|
351
|
+
const to = from + chunkSize - 1;
|
|
352
|
+
options.onProgress?.(`chunk OBJECTID ${from}–${to}`);
|
|
353
|
+
const result = await runChunkProcess({
|
|
354
|
+
script,
|
|
355
|
+
context: "zoning build",
|
|
356
|
+
args: ingestChunkArguments({
|
|
357
|
+
database: tmpPath,
|
|
358
|
+
args: ["--export", batched.exportPath, "--object-id-from", String(from), "--object-id-to", String(to)],
|
|
359
|
+
indexResolution: options.indexResolution,
|
|
360
|
+
coverageResolution: options.coverageResolution,
|
|
361
|
+
}),
|
|
362
|
+
});
|
|
363
|
+
chunks.push(result);
|
|
364
|
+
if (!result.features)
|
|
365
|
+
break;
|
|
366
|
+
from = to + 1;
|
|
367
|
+
}
|
|
368
|
+
return aggregateChunks(chunks);
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Refuse a coverage row that would license a negative claim.
|
|
372
|
+
*
|
|
373
|
+
* THIS IS THE CHECK THE MEANING-OF-ZERO RULE TURNS ON, and it is a condition rather than a convention. The Department
|
|
374
|
+
* publishes its coverage detail only inside a map viewer, so no row of this layer may support an exclusion — a
|
|
375
|
+
* `designated` or `surveyed` basis here would let an absent zoning polygon be read as a statement that no restriction
|
|
376
|
+
* applies, over most of the map. The reader checks the same thing at open time, so an artifact built by some other path
|
|
377
|
+
* cannot get past it either.
|
|
378
|
+
*/
|
|
379
|
+
export function assertNoNegativeClaim(cells) {
|
|
380
|
+
assertCoverageNoNegativeClaim("zoning build", cells, GZT_COVERAGE_LIMIT);
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Insert the authorities.
|
|
384
|
+
*/
|
|
385
|
+
function writeJurisdictionRows(database, jurisdictions) {
|
|
386
|
+
const insert = database.prepare("INSERT INTO zoning_jurisdiction (jurisdiction_id, name, source_code, country) VALUES (?, ?, ?, ?)");
|
|
387
|
+
for (const [code, name] of jurisdictions.toSorted((left, right) => (left[0] < right[0] ? -1 : 1))) {
|
|
388
|
+
// The id IS the publisher's own code. `Fl` for Fingal against `CL`, `CO`, `DU` for the rest — carried in both
|
|
389
|
+
// columns rather than repaired in one, because a repaired code is this package's spelling in a column that claims to
|
|
390
|
+
// be the publisher's.
|
|
391
|
+
insert.run(code, name, code, "IE");
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Insert the plans.
|
|
396
|
+
*/
|
|
397
|
+
function writePlanRows(database, plans) {
|
|
398
|
+
const insert = database.prepare("INSERT INTO zoning_plan (plan_id, jurisdiction_id, plan_name, plan_level, valid_from, valid_to, current_plan) " +
|
|
399
|
+
"VALUES (?, ?, ?, ?, ?, ?, ?)");
|
|
400
|
+
for (const plan of plans.toSorted((left, right) => (left.planID < right.planID ? -1 : 1))) {
|
|
401
|
+
insert.run(plan.planID, plan.authorityCode, plan.name, plan.level, plan.from, plan.to, plan.currentPlan);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Insert the vocabulary: every code the publisher DECLARES, plus every code the DATA uses, with the difference recorded
|
|
406
|
+
* rather than folded away.
|
|
407
|
+
*
|
|
408
|
+
* A declared code the data never uses is kept at `observed_rows = 0`, because the domain is the publisher's statement
|
|
409
|
+
* of what a value may be rather than a census of what it is — Ireland's `SDZ` plan level is exactly that. A used code
|
|
410
|
+
* the publisher never declared is kept at `declared = 0`, because inventing a declaration would make a source-schema
|
|
411
|
+
* change indistinguishable from the publisher's own vocabulary.
|
|
412
|
+
*/
|
|
413
|
+
function writeVocabularyRows(database, observed) {
|
|
414
|
+
const insert = database.prepare("INSERT INTO zoning_vocabulary (scheme, code, label, definition, definition_url, declared, observed_rows) " +
|
|
415
|
+
"VALUES (?, ?, ?, ?, ?, ?, ?)");
|
|
416
|
+
const rows = new Map();
|
|
417
|
+
const declare = (scheme, code, label) => {
|
|
418
|
+
rows.set(`${scheme}\u0000${code}`, { scheme, code, label, declared: 1, observedRows: 0 });
|
|
419
|
+
};
|
|
420
|
+
for (const term of GZT_DECLARED_CODES) {
|
|
421
|
+
declare(GZT_CROSSWALK_SCHEME, term.code, term.label);
|
|
422
|
+
}
|
|
423
|
+
for (const term of GZT_PLAN_LEVELS) {
|
|
424
|
+
declare(PLAN_LEVEL_SCHEME, term.code, term.label);
|
|
425
|
+
}
|
|
426
|
+
for (const [scheme, code, label, observedRows] of observed) {
|
|
427
|
+
const key = `${scheme}\u0000${code}`;
|
|
428
|
+
const existing = rows.get(key);
|
|
429
|
+
if (existing) {
|
|
430
|
+
existing.observedRows += observedRows;
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
rows.set(key, {
|
|
434
|
+
scheme,
|
|
435
|
+
code,
|
|
436
|
+
label,
|
|
437
|
+
// DECLARED IS A PROPERTY OF THE PUBLISHER'S DOMAIN, NOT OF THE SCHEME. A local authority's own codes are observed
|
|
438
|
+
// rather than declared — the Department publishes no domain for them — and an undeclared generic type is the event
|
|
439
|
+
// this column exists to make visible.
|
|
440
|
+
declared: scheme === GZT_CROSSWALK_SCHEME && GZT_DECLARED_CODE_SET.has(code) ? 1 : 0,
|
|
441
|
+
observedRows,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
const bySchema = new Map();
|
|
445
|
+
for (const row of [...rows.values()].toSorted((left, right) => left.scheme === right.scheme ? (left.code < right.code ? -1 : 1) : left.scheme < right.scheme ? -1 : 1)) {
|
|
446
|
+
// NULL, not a plausible URL. Every one of the 85,330 rows links its generic type's definition to `viewer.myplan.ie`,
|
|
447
|
+
// which has no DNS record, and three candidate replacements on the live host answer HTTP 404 — so the definitions
|
|
448
|
+
// behind the code-to-label pairs were not retrievable and this column says so by being empty.
|
|
449
|
+
insert.run(row.scheme, row.code, row.label, null, null, row.declared, row.observedRows);
|
|
450
|
+
const census = bySchema.get(row.scheme) ?? { codes: 0, undeclared: 0, undeclaredCodes: [] };
|
|
451
|
+
census.codes++;
|
|
452
|
+
// A LOCAL SCHEME IS UNDECLARED BY CONSTRUCTION and reporting it as such would bury the one that matters. The census
|
|
453
|
+
// counts an undeclared code only where the publisher DOES publish a domain to be outside of.
|
|
454
|
+
if (!row.declared && row.scheme === GZT_CROSSWALK_SCHEME) {
|
|
455
|
+
census.undeclared++;
|
|
456
|
+
census.undeclaredCodes.push(row.code);
|
|
457
|
+
}
|
|
458
|
+
bySchema.set(row.scheme, census);
|
|
459
|
+
}
|
|
460
|
+
return [...bySchema].map(([scheme, census]) => ({ scheme, ...census }));
|
|
461
|
+
}
|
|
462
|
+
//# sourceMappingURL=build-zoning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-zoning.js","sourceRoot":"","sources":["../../lib/sdk/build-zoning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAA;AACxE,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The cell index, and the measurement the index resolution is chosen from.
|
|
7
|
+
*
|
|
8
|
+
* THE CLASSIFIER ITSELF LIVES IN `@mailwoman/spatial`, re-exported below so this package's call sites and
|
|
9
|
+
* its `@mailwoman/zoning/sdk/cells` subpath keep reading the same. `classifyFeatureCells`, the per-PART
|
|
10
|
+
* zero-cell guard and the allocator-avoiding shortcuts around it are properties of h3-js rather than of
|
|
11
|
+
* this product — the layer contract's polygon-builder section states them as requirements on EVERY polygon
|
|
12
|
+
* builder — and a second copy of the zero-cell guard is a second place for it to stop guarding.
|
|
13
|
+
*
|
|
14
|
+
* WHAT THIS LAYER ADDS IS THE NUMBER THE RESOLUTION IS ACTUALLY CHOSEN FROM, AND IT IS NOT THE `partial`
|
|
15
|
+
* SHARE. The inherited size contract picks a resolution from the measured `partial` share, and for this
|
|
16
|
+
* subject that statistic carries no signal: computed over all 85,330 Irish features, the median zoning
|
|
17
|
+
* polygon is 4,497 m² against an average res-9 cell of 105,333 m², so 95.7% of them are smaller than a cell
|
|
18
|
+
* and the `partial` share is near 100% at every candidate. Two numbers do carry signal —
|
|
19
|
+
* CANDIDATES PER CELL, which is how much geometry a probe reads, and the POLYFILL-ONLY ZERO-CELL COUNT,
|
|
20
|
+
* which is how many features a centre-in-polygon index would have dropped — so both are measured here and
|
|
21
|
+
* the `partial` share is reported beside them rather than in place of them.
|
|
22
|
+
*
|
|
23
|
+
* THE ZERO-CELL COUNT IS A MEASUREMENT OF THE ALTERNATIVE, NOT OF THIS INDEX. `classifyFeatureCells` takes
|
|
24
|
+
* overlapping containment and REFUSES a feature that reaches no cell, so this index's own zero-cell count is
|
|
25
|
+
* zero by construction. What the column reports is what `polygonToCells` — the centre-in-polygon polyfill a
|
|
26
|
+
* builder reaches for first — would have returned nothing for, and every one of those would have read
|
|
27
|
+
* downstream as an absence of zoning.
|
|
28
|
+
*/
|
|
29
|
+
import { type FeatureCells } from "@mailwoman/spatial";
|
|
30
|
+
import type { MultiPolygonRings } from "#rings";
|
|
31
|
+
export { addCoverageCells, CELL_ESTIMATE_BUDGET, classifyFeatureCells, coverageCellFor, estimateCellCount, featureCellRows, MIN_INDEX_RESOLUTION, resolutionForFeature, type FeatureCells, } from "@mailwoman/spatial";
|
|
32
|
+
/**
|
|
33
|
+
* Would a CENTRE-IN-POLYGON polyfill return nothing for this feature?
|
|
34
|
+
*
|
|
35
|
+
* The measurement that forced this layer's index to take cell-touches-polygon: at resolution 9 `polygonToCells` returns
|
|
36
|
+
* an empty set for the great majority of Irish zoning polygons, because no cell centre falls inside them. A builder
|
|
37
|
+
* indexing only the polyfill output would drop every one of them silently.
|
|
38
|
+
*/
|
|
39
|
+
export declare function polyfillFindsNothing(polygons: MultiPolygonRings, resolution: number): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* What one resolution came out as over the whole set — the numbers the resolution choice is made from.
|
|
42
|
+
*/
|
|
43
|
+
export interface CellIndexMeasurement {
|
|
44
|
+
resolution: number;
|
|
45
|
+
features: number;
|
|
46
|
+
/**
|
|
47
|
+
* Cells the layer reaches at all.
|
|
48
|
+
*/
|
|
49
|
+
touchedCells: number;
|
|
50
|
+
/**
|
|
51
|
+
* Cells answered by the index alone, before compaction.
|
|
52
|
+
*/
|
|
53
|
+
wholeCells: number;
|
|
54
|
+
/**
|
|
55
|
+
* Cells needing the ray cast.
|
|
56
|
+
*/
|
|
57
|
+
partialCells: number;
|
|
58
|
+
/**
|
|
59
|
+
* `partialCells / touchedCells`. Reported, and NOT what the resolution is chosen on — see this file's header.
|
|
60
|
+
*/
|
|
61
|
+
partialShare: number;
|
|
62
|
+
/**
|
|
63
|
+
* Whole cells after per-feature `compactCells` — the rows actually stored on the whole side.
|
|
64
|
+
*/
|
|
65
|
+
compactedWholeCells: number;
|
|
66
|
+
/**
|
|
67
|
+
* Cell rows the artifact would store at this resolution: the compacted whole rows plus the partial rows.
|
|
68
|
+
*/
|
|
69
|
+
storedCellRows: number;
|
|
70
|
+
/**
|
|
71
|
+
* How many polygons name a cell, over the cells the layer reaches. This is what a probe pays: a cell naming eight
|
|
72
|
+
* candidates is eight bounding-box tests and up to eight ray casts.
|
|
73
|
+
*/
|
|
74
|
+
candidatesPerCell: {
|
|
75
|
+
mean: number;
|
|
76
|
+
p90: number;
|
|
77
|
+
max: number;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Cells naming more than one polygon, and their share of the touched cells.
|
|
81
|
+
*/
|
|
82
|
+
multiCandidateCells: number;
|
|
83
|
+
multiCandidateShare: number;
|
|
84
|
+
/**
|
|
85
|
+
* Features a centre-in-polygon polyfill would have returned NOTHING for — see {@link polyfillFindsNothing}.
|
|
86
|
+
* `undefined` where the measurement did not run it.
|
|
87
|
+
*/
|
|
88
|
+
polyfillZeroCellFeatures?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Features whose bounding box forced a coarser resolution than the target — see `CELL_ESTIMATE_BUDGET`.
|
|
91
|
+
*/
|
|
92
|
+
coarsenedFeatures: number;
|
|
93
|
+
/**
|
|
94
|
+
* Features this index returned no cell for. ZERO BY CONSTRUCTION: `classifyFeatureCells` throws rather than returning
|
|
95
|
+
* an empty set, so a non-zero value here means the guard was bypassed.
|
|
96
|
+
*/
|
|
97
|
+
zeroCellFeatures: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Accumulate one resolution's cell index over a stream of features.
|
|
101
|
+
*
|
|
102
|
+
* The whole set is held as short-cell STRINGS rather than the integers the tables store, because `compactCells` is an
|
|
103
|
+
* h3-js function over full indexes and round-tripping at every step would cost more than the strings do. The candidate
|
|
104
|
+
* counter is keyed by the 48-bit INTEGER instead: it is the larger of the two at every candidate resolution, and it is
|
|
105
|
+
* never handed back to h3.
|
|
106
|
+
*/
|
|
107
|
+
export declare class ZoningCellIndex {
|
|
108
|
+
#private;
|
|
109
|
+
readonly resolution: number;
|
|
110
|
+
constructor(resolution: number);
|
|
111
|
+
/**
|
|
112
|
+
* Fold one feature's classification in.
|
|
113
|
+
*/
|
|
114
|
+
add(cells: FeatureCells): void;
|
|
115
|
+
/**
|
|
116
|
+
* Record that a centre-in-polygon polyfill found nothing for one feature.
|
|
117
|
+
*/
|
|
118
|
+
addPolyfillProbe(foundNothing: boolean): void;
|
|
119
|
+
/**
|
|
120
|
+
* The measurement.
|
|
121
|
+
*
|
|
122
|
+
* The compacted count is an approximation of what the build stores and is reported as one: the build compacts each
|
|
123
|
+
* FEATURE's whole set, while this compacts the union of them. The union can only compact at least as far, so this is
|
|
124
|
+
* a lower bound on the stored row count — the direction a size estimate should err in — and the build's own receipt
|
|
125
|
+
* reports the real number.
|
|
126
|
+
*/
|
|
127
|
+
finish(): CellIndexMeasurement;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The measurement as markdown table ROWS — what a build receipt carries, one line per element so a caller printing them
|
|
131
|
+
* never has to split a joined string back apart.
|
|
132
|
+
*
|
|
133
|
+
* THE ZERO-CELL COLUMN IS FIRST AFTER THE COUNTS, because it is the column the resolution is chosen on and the one a
|
|
134
|
+
* reader most needs to see is not zero for the alternative index.
|
|
135
|
+
*/
|
|
136
|
+
export declare function formatResolutionRows(measurements: readonly CellIndexMeasurement[]): string[];
|
|
137
|
+
//# sourceMappingURL=cells.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cells.d.ts","sourceRoot":"","sources":["../../lib/sdk/cells.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAA4C,KAAK,YAAY,EAAe,MAAM,oBAAoB,CAAA;AAG7G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,Q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