@mailwoman/zoning 9.4.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +169 -163
- package/lib/index.ts +89 -120
- package/lib/paths.ts +24 -0
- package/lib/ring-roles.ts +30 -71
- package/lib/rings.ts +2 -13
- package/lib/schema.ts +96 -114
- package/lib/vocabulary.ts +52 -130
- package/out/index.d.ts +75 -95
- package/out/index.d.ts.map +1 -1
- package/out/index.js +25 -82
- package/out/index.js.map +1 -1
- package/out/paths.d.ts +19 -0
- package/out/paths.d.ts.map +1 -0
- package/out/paths.js +21 -0
- package/out/paths.js.map +1 -0
- package/out/ring-roles.d.ts +16 -50
- package/out/ring-roles.d.ts.map +1 -1
- package/out/ring-roles.js +18 -51
- package/out/ring-roles.js.map +1 -1
- package/out/rings.d.ts +2 -13
- package/out/rings.d.ts.map +1 -1
- package/out/rings.js +2 -13
- package/out/rings.js.map +1 -1
- package/out/schema.d.ts +93 -108
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js +16 -44
- package/out/schema.js.map +1 -1
- package/out/sdk/build-zoning.d.ts +58 -111
- package/out/sdk/build-zoning.d.ts.map +1 -1
- package/out/sdk/build-zoning.js +48 -137
- package/out/sdk/build-zoning.js.map +1 -1
- package/out/sdk/cells.d.ts +20 -61
- package/out/sdk/cells.d.ts.map +1 -1
- package/out/sdk/cells.js +13 -50
- package/out/sdk/cells.js.map +1 -1
- package/out/sdk/client.d.ts +23 -67
- package/out/sdk/client.d.ts.map +1 -1
- package/out/sdk/client.js +29 -77
- package/out/sdk/client.js.map +1 -1
- package/out/sdk/download.d.ts +7 -27
- package/out/sdk/download.d.ts.map +1 -1
- package/out/sdk/download.js +7 -27
- package/out/sdk/download.js.map +1 -1
- package/out/sdk/ingest/chunk.d.ts +106 -0
- package/out/sdk/ingest/chunk.d.ts.map +1 -0
- package/out/sdk/{ingest-chunk.js → ingest/chunk.js} +17 -50
- package/out/sdk/ingest/chunk.js.map +1 -0
- package/out/sdk/ingest/worker.d.ts +9 -0
- package/out/sdk/ingest/worker.d.ts.map +1 -0
- package/out/{scripts/ingest-chunk.js → sdk/ingest/worker.js} +5 -7
- package/out/sdk/ingest/worker.js.map +1 -0
- package/out/sdk/ingest.d.ts +54 -77
- package/out/sdk/ingest.d.ts.map +1 -1
- package/out/sdk/ingest.js +50 -87
- package/out/sdk/ingest.js.map +1 -1
- package/out/sdk/measure-resolutions.d.ts +6 -23
- package/out/sdk/measure-resolutions.d.ts.map +1 -1
- package/out/sdk/measure-resolutions.js +4 -21
- package/out/sdk/measure-resolutions.js.map +1 -1
- package/out/sdk/test-kit.d.ts +75 -0
- package/out/sdk/test-kit.d.ts.map +1 -0
- package/out/{test-kit.js → sdk/test-kit.js} +20 -43
- package/out/sdk/test-kit.js.map +1 -0
- package/out/sdk/verify.d.ts +74 -56
- package/out/sdk/verify.d.ts.map +1 -1
- package/out/sdk/verify.js +70 -57
- package/out/sdk/verify.js.map +1 -1
- package/out/vocabulary.d.ts +52 -120
- package/out/vocabulary.d.ts.map +1 -1
- package/out/vocabulary.js +47 -125
- package/out/vocabulary.js.map +1 -1
- package/package.json +37 -161
- package/{lib/sdk → sdk}/build-zoning.ts +100 -186
- package/{lib/sdk → sdk}/cells.ts +24 -63
- package/{lib/sdk → sdk}/client.ts +34 -82
- package/sdk/download.ts +58 -0
- package/{lib/sdk/ingest-chunk.ts → sdk/ingest/chunk.ts} +32 -61
- package/{lib/scripts/ingest-chunk.ts → sdk/ingest/worker.ts} +4 -6
- package/sdk/ingest.ts +366 -0
- package/{lib/sdk → sdk}/measure-resolutions.ts +8 -25
- package/{lib → sdk}/test-kit.ts +20 -43
- package/{lib/sdk → sdk}/verify.ts +102 -75
- package/lib/sdk/download.ts +0 -78
- package/lib/sdk/index.ts +0 -15
- package/lib/sdk/ingest.ts +0 -398
- package/out/scripts/ingest-chunk.d.ts +0 -11
- package/out/scripts/ingest-chunk.d.ts.map +0 -1
- package/out/scripts/ingest-chunk.js.map +0 -1
- package/out/sdk/index.d.ts +0 -15
- package/out/sdk/index.d.ts.map +0 -1
- package/out/sdk/index.js +0 -15
- package/out/sdk/index.js.map +0 -1
- package/out/sdk/ingest-chunk.d.ts +0 -130
- package/out/sdk/ingest-chunk.d.ts.map +0 -1
- package/out/sdk/ingest-chunk.js.map +0 -1
- package/out/test-kit.d.ts +0 -96
- package/out/test-kit.d.ts.map +0 -1
- package/out/test-kit.js.map +0 -1
package/out/sdk/download.js
CHANGED
|
@@ -3,44 +3,24 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* THIS IS A FILE TRANSFER, NOT AN API REQUEST, AND IT KEEPS RAW `fetch` ON PURPOSE. The repo's rule sends
|
|
9
|
-
* HTTP clients through `@mailwoman/core/api`'s `APIClient`, and the rule draws its line at what that class
|
|
10
|
-
* is for: pacing, bounded retry, response caching and error mapping over small bodies and repeated calls.
|
|
11
|
-
* None of it applies here. Caching a 247 MB body through a JSON-validating disk cache would write a second,
|
|
12
|
-
* unreadable copy of a file already on disk; there is nothing to pace, because this runs once per product
|
|
13
|
-
* vintage; and axios buffers any non-stream response type in memory. `packages/osm/lib/sdk/fetch.ts`,
|
|
14
|
-
* `packages/tiger/lib/sdk/download.ts`, `packages/flood/lib/sdk/download.ts` and `packages/coastal/lib/sdk/download.ts`
|
|
15
|
-
* are the existing transfers that say the same thing in the same place. The JOB that produces this URL, and
|
|
16
|
-
* every other metadata read around it, DO go through `APIClient` — see `client.ts`.
|
|
17
|
-
*
|
|
18
|
-
* THE RESULT URL REDIRECTS AND THE FETCH MUST FOLLOW IT. The Hub download job answers
|
|
19
|
-
* `{"status":"Completed","resultUrl":…}`; the result URL itself 302s to the generated file. Node's `fetch`
|
|
20
|
-
* follows redirects by default, and the option is passed explicitly anyway — a transfer that stopped at the
|
|
21
|
-
* redirect would write a short body to disk and report a successful download.
|
|
22
|
-
*
|
|
23
|
-
* FRESHNESS IS THE ITEM'S OWN MODIFIED DATE, NEVER A LENGTH PROBE. The cache is keyed on the vintage the
|
|
24
|
-
* item declares, so a re-run against the same vintage never re-transfers and a new vintage never overwrites
|
|
25
|
-
* the old one in place.
|
|
6
|
+
* Acquire the Department's bulk GeoJSON export with raw `fetch` rather than `APIClient`, following the result URL's redirect and keying the cache on the item's own modified date.
|
|
26
7
|
*/
|
|
27
8
|
import { tryStat } from "@mailwoman/core/fs/readers";
|
|
28
9
|
import { makeDirectories } from "@mailwoman/core/fs/writers";
|
|
29
10
|
import { streamToDisk } from "@mailwoman/core/utils";
|
|
30
|
-
import {
|
|
11
|
+
import { PathBuilder } from "path-ts";
|
|
31
12
|
/**
|
|
32
13
|
* The file name one vintage's export is kept under.
|
|
33
14
|
*/
|
|
34
15
|
export const GZT_EXPORT_FILE = "gzt-current-plan.geojson";
|
|
35
16
|
/**
|
|
36
|
-
* Download the bulk export for one product vintage
|
|
37
|
-
*
|
|
38
|
-
* Downloads to a `.part` file and renames only on a clean finish, so an interrupted transfer never presents as a
|
|
39
|
-
* complete export — the same discipline the database build uses, for the same reason.
|
|
17
|
+
* Download the bulk export for one product vintage and return the path of the GeoJSON file, renaming a
|
|
18
|
+
* `.part` file only on a clean finish so an interrupted transfer never presents as a complete export.
|
|
40
19
|
*/
|
|
41
20
|
export async function downloadZoningExport(options) {
|
|
42
|
-
const vintageDir =
|
|
43
|
-
|
|
21
|
+
const vintageDir = PathBuilder.from(options.cacheRoot)(options.vintage);
|
|
22
|
+
// A string, because the build records the export path it read.
|
|
23
|
+
const exportPath = vintageDir(GZT_EXPORT_FILE).toString();
|
|
44
24
|
if (await tryStat(exportPath)) {
|
|
45
25
|
options.onProgress?.(`export for ${options.vintage} already downloaded`);
|
|
46
26
|
return exportPath;
|
package/out/sdk/download.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../
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
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The streaming pass, bounded to one process per range of the authority's own feature ids because h3's wasm heap cannot be reset from JavaScript and a build that completes only by luck is not reproducible.
|
|
7
|
+
*/
|
|
8
|
+
import type { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
9
|
+
import type { ZoningDatabase } from "#schema";
|
|
10
|
+
import type { ZoningFeatureSource, ZoningSourceFeature } from "#sdk/ingest";
|
|
11
|
+
/**
|
|
12
|
+
* One observed vocabulary value.
|
|
13
|
+
*
|
|
14
|
+
* It records the scheme and code.
|
|
15
|
+
* It also records the publisher's label and row count.
|
|
16
|
+
*/
|
|
17
|
+
export type ObservedTerm = [scheme: string, code: string, label: string, rows: number];
|
|
18
|
+
/**
|
|
19
|
+
* One (authority, local code) pair and every generic type the publisher assigned to it.
|
|
20
|
+
*/
|
|
21
|
+
export type CrosswalkPair = [authorityCode: string, localCode: string, crosswalkCodes: string[]];
|
|
22
|
+
/**
|
|
23
|
+
* What one chunk produced, every field JSON-serializable because a chunk normally
|
|
24
|
+
* reports across a process boundary.
|
|
25
|
+
*/
|
|
26
|
+
export interface ZoningChunkResult {
|
|
27
|
+
features: number;
|
|
28
|
+
/**
|
|
29
|
+
* Features whose bounding box forced a resolution coarser than the target.
|
|
30
|
+
*/
|
|
31
|
+
coarsened: number;
|
|
32
|
+
/**
|
|
33
|
+
* Cell rows written, split by tier.
|
|
34
|
+
*/
|
|
35
|
+
wholeCellRows: number;
|
|
36
|
+
partialCellRows: number;
|
|
37
|
+
/**
|
|
38
|
+
* `[coverageCell, polygonsReachingIt]` pairs — an array rather than a `Map`
|
|
39
|
+
* so it survives the process boundary.
|
|
40
|
+
*/
|
|
41
|
+
observedByCoverageCell: Array<[number, number]>;
|
|
42
|
+
/**
|
|
43
|
+
* Square-meter area readings from the polygon rings.
|
|
44
|
+
*
|
|
45
|
+
* `signed` is the raw ring sum as published.
|
|
46
|
+
* `nested` accounts for holes in each polygon.
|
|
47
|
+
*
|
|
48
|
+
* `allExterior` reads the same rings as exterior boundaries without holes.
|
|
49
|
+
*/
|
|
50
|
+
area: {
|
|
51
|
+
signedM2: number;
|
|
52
|
+
nestedM2: number;
|
|
53
|
+
allExteriorM2: number;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* The ring-role census — the receipt that the orientation was read rather than assumed.
|
|
57
|
+
*/
|
|
58
|
+
rings: {
|
|
59
|
+
total: number;
|
|
60
|
+
exteriors: number;
|
|
61
|
+
holes: number;
|
|
62
|
+
nestedHoles: number;
|
|
63
|
+
adjacentHoles: number;
|
|
64
|
+
/**
|
|
65
|
+
* Features whose exterior was chosen by magnitude because no ring read as one by orientation.
|
|
66
|
+
*/
|
|
67
|
+
exteriorByMagnitude: number;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The authorities this chunk saw, by their own code.
|
|
71
|
+
*/
|
|
72
|
+
jurisdictions: Array<[code: string, name: string]>;
|
|
73
|
+
plans: Array<{
|
|
74
|
+
planID: string;
|
|
75
|
+
authorityCode: string;
|
|
76
|
+
name: string;
|
|
77
|
+
level: string;
|
|
78
|
+
from: string | null;
|
|
79
|
+
to: string | null;
|
|
80
|
+
currentPlan: number;
|
|
81
|
+
}>;
|
|
82
|
+
vocabulary: ObservedTerm[];
|
|
83
|
+
crosswalkPairs: CrosswalkPair[];
|
|
84
|
+
}
|
|
85
|
+
export interface IngestZoningChunkOptions {
|
|
86
|
+
source: ZoningFeatureSource;
|
|
87
|
+
indexResolution: number;
|
|
88
|
+
coverageResolution: number;
|
|
89
|
+
onProgress?: (message: string) => void;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Stream one chunk of the source into `database`.
|
|
93
|
+
*
|
|
94
|
+
* @throws {Error} On a feature the classifier or the ring-role resolver refuses.
|
|
95
|
+
*/
|
|
96
|
+
export declare function ingestZoningChunk(database: DatabaseClient<ZoningDatabase>, options: IngestZoningChunkOptions): Promise<ZoningChunkResult>;
|
|
97
|
+
/**
|
|
98
|
+
* One feature's own contribution, for a caller that wants the numbers without a database —
|
|
99
|
+
* the fixture rung's arithmetic and no more.
|
|
100
|
+
*/
|
|
101
|
+
export declare function featureAreaReadings(feature: ZoningSourceFeature): {
|
|
102
|
+
signed: number;
|
|
103
|
+
nested: number;
|
|
104
|
+
allExterior: number;
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=chunk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../../sdk/ingest/chunk.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAW3E;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;AAEtF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC,CAAA;AAEhG;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB;;;OAGG;IACH,sBAAsB,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAC/C;;;;;;;OAOG;IACH,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,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AE,MAAM,CAAA;CACnB,CAIA"}
|
|
@@ -3,46 +3,16 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* run over PART of the source.
|
|
8
|
-
*
|
|
9
|
-
* WHY THIS IS A CHUNK RATHER THAN THE WHOLE FILE. h3's WASM heap cannot be reset from JavaScript, and it
|
|
10
|
-
* does not survive an unbounded number of polyfill calls: over a sibling product, runs died after roughly
|
|
11
|
-
* 510,000 and 798,000 features on geometry that classifies in milliseconds in a fresh process. A build that
|
|
12
|
-
* completes only when fragmentation happens to stay low is not a reproducible build, so the classification
|
|
13
|
-
* is bounded BY CONSTRUCTION — one process per range of the authority's own feature ids. This product's
|
|
14
|
-
* 85,330 features fit inside the default bound; the bound ships anyway, because determinism by construction
|
|
15
|
-
* is not the same fact as determinism by luck.
|
|
16
|
-
*
|
|
17
|
-
* THE VOCABULARY IS A CENSUS, NOT A CHECK. The declared generic-type domain is closed and the source
|
|
18
|
-
* already breaks it — `N/A` appears on 4 rows and in no domain — so an undeclared value is RECORDED as
|
|
19
|
-
* observed-but-undeclared rather than throwing. That is the opposite of the sibling layers' rule and it is
|
|
20
|
-
* the publisher's own doing: refusing here would refuse the Department's own data. What DOES throw is a
|
|
21
|
-
* blank local code, because the local code is the claim.
|
|
22
|
-
*
|
|
23
|
-
* THE CROSSWALK PAIRS ARE COUNTED HERE BECAUSE THEY ARE THE ARGUMENT FOR THE SCHEMA. If a local code
|
|
24
|
-
* determined a generic type, the mapping could ship as an edge table and the local column would be
|
|
25
|
-
* redundant. It does not: measured nationally, 52 of 795 (authority, local code) pairs take more than one
|
|
26
|
-
* generic type. The chunk reports the pairs it saw and the build refuses to write an edge table while any
|
|
27
|
-
* such pair exists, so the empty `zoning_crosswalk_edge` is a checked consequence rather than an omission.
|
|
28
|
-
*
|
|
29
|
-
* THE CHUNK OWNS NO ARTIFACT. It appends rows to a database the parent created and will seal, and returns
|
|
30
|
-
* counts the parent adds up. Chunks run one at a time against that file, so there is no concurrent writer
|
|
31
|
-
* and no locking to reason about. The jurisdiction, plan and vocabulary rows are RETURNED rather than
|
|
32
|
-
* written: they are per-chunk partials that have to be merged before insertion, and 30 authorities, 63
|
|
33
|
-
* plans and about 880 vocabulary rows cross a process boundary for nothing.
|
|
6
|
+
* The streaming pass, bounded to one process per range of the authority's own feature ids because h3's wasm heap cannot be reset from JavaScript and a build that completes only by luck is not reproducible.
|
|
34
7
|
*/
|
|
35
8
|
import { addCoverageCells, encodeRings, ringAreaReadings, ringsBoundingBox, classifyFeatureCells, featureCellRows, } from "@mailwoman/spatial";
|
|
36
9
|
import { beginBatched } from "@mailwoman/sqlite/batched";
|
|
37
10
|
import { GZT_CROSSWALK_SCHEME, GZT_PROVENANCE_GRADE, GZT_ROLLUP_SCHEME, localSchemeFor } from "#vocabulary";
|
|
38
11
|
/**
|
|
39
|
-
* Rows per bulk-insert transaction
|
|
40
|
-
* the write-ahead file without improving throughput.
|
|
12
|
+
* Rows per bulk-insert transaction, chosen for the geometry table whose rows contain a blob
|
|
13
|
+
* because a larger transaction grows the write-ahead file without improving throughput.
|
|
41
14
|
*/
|
|
42
15
|
const INSERT_TRANSACTION_ROWS = 5000;
|
|
43
|
-
/**
|
|
44
|
-
* Features between progress reports.
|
|
45
|
-
*/
|
|
46
16
|
const PROGRESS_STRIDE = 5000;
|
|
47
17
|
/**
|
|
48
18
|
* Stream one chunk of the source into `database`.
|
|
@@ -58,9 +28,9 @@ export async function ingestZoningChunk(database, options) {
|
|
|
58
28
|
const observedByCoverageCell = new Map();
|
|
59
29
|
const jurisdictions = new Map();
|
|
60
30
|
const plans = new Map();
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
31
|
+
// Keyed on a NUL-joined pair and never split back apart, because a local code is
|
|
32
|
+
// free text that routinely contains spaces and a key a reader had to re-split
|
|
33
|
+
// would mangle the vocabulary this layer preserves verbatim.
|
|
64
34
|
const vocabulary = new Map();
|
|
65
35
|
const crosswalkPairs = new Map();
|
|
66
36
|
let features = 0;
|
|
@@ -77,8 +47,8 @@ export async function ingestZoningChunk(database, options) {
|
|
|
77
47
|
let exteriorByMagnitude = 0;
|
|
78
48
|
let adjacentHoles = 0;
|
|
79
49
|
/**
|
|
80
|
-
* Record one observed vocabulary value
|
|
81
|
-
*
|
|
50
|
+
* Record one observed vocabulary value, keeping the first label so a later row's
|
|
51
|
+
* description leaves the publisher's vocabulary unchanged.
|
|
82
52
|
*/
|
|
83
53
|
const observe = (scheme, code, label) => {
|
|
84
54
|
const key = `${scheme}\u0000${code}`;
|
|
@@ -104,9 +74,9 @@ export async function ingestZoningChunk(database, options) {
|
|
|
104
74
|
exteriorByMagnitude += feature.rings.exteriorByMagnitude;
|
|
105
75
|
adjacentHoles += feature.rings.adjacentHoles;
|
|
106
76
|
insertArea.run(feature.areaID, feature.authorityCode, feature.planID, feature.localCode, feature.localDescription, feature.localCodeURL, feature.crosswalkCode, feature.crosswalkCode === null ? null : GZT_CROSSWALK_SCHEME, feature.crosswalkDescription, feature.crosswalkRollup,
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
// `layer_manifest.name
|
|
77
|
+
// One grade per claim: every row of this artifact is `authoritative`,
|
|
78
|
+
// and an observed land-use layer is a different database with a different
|
|
79
|
+
// `layer_manifest.name` rather than a row with a second grade in this table.
|
|
110
80
|
GZT_PROVENANCE_GRADE, bbox.minLat, bbox.minLon, bbox.maxLat, bbox.maxLon, feature.rings.ringCount, feature.rings.signedAreaM2, encodeRings(feature.rings.polygons));
|
|
111
81
|
const classified = classifyFeatureCells(feature.rings.polygons, options.indexResolution, feature.areaID, "zoning cells");
|
|
112
82
|
if (classified.resolution !== options.indexResolution) {
|
|
@@ -121,10 +91,8 @@ export async function ingestZoningChunk(database, options) {
|
|
|
121
91
|
partialCellRows++;
|
|
122
92
|
}
|
|
123
93
|
}
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
// all are — so counting off the stored rows and counting off the classification agree here, and the classification
|
|
127
|
-
// is the one that cannot be changed by a compaction decision.
|
|
94
|
+
// Coverage is derived from the uncompacted classification rather than the stored rows,
|
|
95
|
+
// since the classification is the one compaction cannot change.
|
|
128
96
|
const coverageCells = new Set();
|
|
129
97
|
for (const cell of classified.whole) {
|
|
130
98
|
addCoverageCells(coverageCells, cell, classified.resolution, options.coverageResolution);
|
|
@@ -147,8 +115,7 @@ export async function ingestZoningChunk(database, options) {
|
|
|
147
115
|
currentPlan: feature.currentPlan,
|
|
148
116
|
});
|
|
149
117
|
}
|
|
150
|
-
// The local vocabulary is per
|
|
151
|
-
// Cork County Council's plan and another in Westmeath's.
|
|
118
|
+
// The local vocabulary is per authority, because codes collide across them.
|
|
152
119
|
observe(localSchemeFor(feature.authorityCode), feature.localCode, feature.localDescription ?? feature.localCode);
|
|
153
120
|
if (feature.crosswalkCode !== null) {
|
|
154
121
|
observe(GZT_CROSSWALK_SCHEME, feature.crosswalkCode, feature.crosswalkDescription ?? feature.crosswalkCode);
|
|
@@ -195,11 +162,11 @@ export async function ingestZoningChunk(database, options) {
|
|
|
195
162
|
};
|
|
196
163
|
}
|
|
197
164
|
/**
|
|
198
|
-
* One feature's own contribution, for a caller that wants the numbers without a database —
|
|
199
|
-
* arithmetic and
|
|
165
|
+
* One feature's own contribution, for a caller that wants the numbers without a database —
|
|
166
|
+
* the fixture rung's arithmetic and no more.
|
|
200
167
|
*/
|
|
201
168
|
export function featureAreaReadings(feature) {
|
|
202
169
|
const areas = ringAreaReadings(feature.rings.polygons);
|
|
203
170
|
return { signed: feature.rings.signedAreaM2, nested: areas.nested, allExterior: areas.allExterior };
|
|
204
171
|
}
|
|
205
|
-
//# sourceMappingURL=
|
|
172
|
+
//# sourceMappingURL=chunk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../../sdk/ingest/chunk.ts"],"names":[],"mappings":"AAAA;;;;;;G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K,CAAC,QAAQ,CAAC,CAAA;IAEtD,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAA;AACpG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../sdk/ingest/worker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* One chunk of the zoning ingest, as its own process — spawned by `buildZoningDatabase`, never run by
|
|
7
|
-
* hand. The process boundary and the stdout contract live with `runIngestChunkScript`; what stays here is
|
|
8
|
-
* only this product's flags and its feature-source constructor.
|
|
6
|
+
* One chunk of the zoning ingest, as its own process — spawned by `buildZoningDatabase`, never run by hand.
|
|
9
7
|
*/
|
|
10
8
|
import { requiredArgument } from "@mailwoman/core/scripting/arguments";
|
|
11
9
|
import { INGEST_CHUNK_FLAGS, runIngestChunkScript } from "@mailwoman/core/scripting/ingest-chunk-script";
|
|
12
10
|
import { createExportFeatureSource } from "#sdk/ingest";
|
|
13
|
-
import { ingestZoningChunk } from "#sdk/ingest
|
|
11
|
+
import { ingestZoningChunk } from "#sdk/ingest/chunk";
|
|
14
12
|
await runIngestChunkScript({
|
|
15
13
|
context: "zoning ingest-chunk",
|
|
16
14
|
options: {
|
|
@@ -24,8 +22,8 @@ await runIngestChunkScript({
|
|
|
24
22
|
exportPath: requiredArgument("zoning ingest-chunk", "export", values.export),
|
|
25
23
|
...(values["object-id-from"] === undefined ? {} : { objectIDFrom: Number(values["object-id-from"]) }),
|
|
26
24
|
...(values["object-id-to"] === undefined ? {} : { objectIDTo: Number(values["object-id-to"]) }),
|
|
27
|
-
// A
|
|
28
|
-
//
|
|
25
|
+
// A range's count is not knowable up front: the source reports only the layer total,
|
|
26
|
+
// so the parent checks the sum against the whole file.
|
|
29
27
|
declaredFeatureCount: 0,
|
|
30
28
|
}),
|
|
31
29
|
indexResolution: chunk.indexResolution,
|
|
@@ -33,4 +31,4 @@ await runIngestChunkScript({
|
|
|
33
31
|
onProgress: chunk.onProgress,
|
|
34
32
|
}),
|
|
35
33
|
});
|
|
36
|
-
//# sourceMappingURL=
|
|
34
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../sdk/ingest/worker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAA;AAIxG,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAErD,MAAM,oBAAoB,CAAC;IAC1B,OAAO,EAAE,qBAAqB;IAC9B,OAAO,EAAE;QACR,GAAG,kBAAkB;QACrB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACpC,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAClC;IACD,GAAG,EAAE,KAAK,EAAE,QAAwC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CACtE,iBAAiB,CAAC,QAAQ,EAAE;QAC3B,MAAM,EAAE,MAAM,yBAAyB,CAAC;YACvC,UAAU,EAAE,gBAAgB,CAAC,qBAAqB,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;YAC5E,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC;YACrG,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC;YAC/F,qFAAqF;YACrF,uDAAuD;YACvD,oBAAoB,EAAE,CAAC;SACvB,CAAC;QACF,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;QAC5C,UAAU,EAAE,KAAK,CAAC,UAAU;KAC5B,CAAC;CACH,CAAC,CAAA"}
|
package/out/sdk/ingest.d.ts
CHANGED
|
@@ -3,41 +3,11 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Streams the Department's bulk zoning export through ogr2ogr as reprojected WGS84 features.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* THE STREAM IS WKT, NOT GEOJSON, AND THAT IS A CORRECTNESS CHOICE RATHER THAN A TASTE ONE. This service
|
|
12
|
-
* encodes hole roles by ring ORIENTATION — clockwise exterior, the inverse of RFC 7946 — and puts each ring
|
|
13
|
-
* in its own `MultiPolygon` part on the features that carry holes that way. GDAL's GeoJSON writer enforces
|
|
14
|
-
* the RFC 7946 winding unconditionally: `-lco RFC7946=NO` is not a GeoJSONSeq option, and
|
|
15
|
-
* `--config OGR_ORGANIZE_POLYGONS SKIP` changes nothing. Measured on the largest feature in the country,
|
|
16
|
-
* Meath's `RA - Rural Area`: through GeoJSONSeq it arrives as 107 counter-clockwise rings totalling
|
|
17
|
-
* 2,371.9 km², through CSV/WKT as the source's own 5 clockwise and 102 counter-clockwise totalling
|
|
18
|
-
* 2,223.1 km² against the Department's published 2,232.1 km². The GeoJSON path has silently turned 102
|
|
19
|
-
* holes into 102 zoned areas.
|
|
20
|
-
*
|
|
21
|
-
* AND THE TRANSPORT IS NOT THE SLOW HALF. Measured on this lab over the whole national export: ogr2ogr
|
|
22
|
-
* reprojects to 224,066,621 bytes of WKT CSV in 13.2 s, and `CSVSpliterator` plus the WKT parse reads
|
|
23
|
-
* 85,330 rows, 93,483 rings and 6,327,256 positions back out of it in 2.2 s.
|
|
24
|
-
*
|
|
25
|
-
* THE SOURCE IS NOT IN WGS84 AND SAYING SO IS THE CHECK. The bulk export is IRENET95 / Irish Transverse
|
|
26
|
-
* Mercator — metres, easting/northing, EPSG:2157 — declared in a top-level `crs` member RFC 7946 removed
|
|
27
|
-
* from the format. GDAL honours the legacy member; a strict reader ignores it and places Ireland's zoning
|
|
28
|
-
* at latitude 735,435. So the projection is asserted against the source's declared authority code before a
|
|
29
|
-
* single feature is read, and every reprojected vertex is asserted inside the Department's own declared
|
|
30
|
-
* extent — which is the check that catches a coordinate-order mistake the projection check cannot see.
|
|
31
|
-
*
|
|
32
|
-
* THE DATUM SHIFT NEEDS A GRID, AND ITS ABSENCE IS SILENT. PROJ substitutes a ballpark offset when the
|
|
33
|
-
* accurate transformation is unavailable and produces coordinates that are metres wrong and
|
|
34
|
-
* indistinguishable from correct ones. {@linkcode assertDatumTransformationAvailable} asks `projinfo` what
|
|
35
|
-
* PROJ would choose and refuses a ballpark; for this source it names
|
|
36
|
-
* `Inverse of Irish Transverse Mercator + IRENET95 to WGS 84 (1), 1 m`.
|
|
37
|
-
*
|
|
38
|
-
* THE PUBLISHER'S OWN AREA COLUMN IS NOT IN THE ARCHIVE. `Shape__Area` is a service field and the export
|
|
39
|
-
* drops it, so the area cross-check reads it from the live service instead — which makes it a genuine
|
|
40
|
-
* two-path check rather than the archive agreeing with itself. See `sdk/client.ts`.
|
|
8
|
+
* The stream uses CSV with WKT geometry because the source marks holes by ring orientation. GDAL's
|
|
9
|
+
* GeoJSON writer rewinds every ring to RFC 7946 order. That turns holes into zoned areas. The source is
|
|
10
|
+
* in EPSG:2157, declared in a legacy top-level `crs` member that GDAL honors.
|
|
41
11
|
*/
|
|
42
12
|
import { type ResolvedRingRoles } from "#rings";
|
|
43
13
|
/**
|
|
@@ -45,11 +15,12 @@ import { type ResolvedRingRoles } from "#rings";
|
|
|
45
15
|
*/
|
|
46
16
|
export interface ZoningSourceFeature {
|
|
47
17
|
/**
|
|
48
|
-
* The authority's
|
|
18
|
+
* The authority's `objectid` as a string.
|
|
49
19
|
*/
|
|
50
20
|
areaID: string;
|
|
51
21
|
/**
|
|
52
|
-
* `LA_CODE
|
|
22
|
+
* The `LA_CODE` value, verbatim.
|
|
23
|
+
* Fingal's unusual `Fl` code is kept as published.
|
|
53
24
|
*/
|
|
54
25
|
authorityCode: string;
|
|
55
26
|
authorityName: string;
|
|
@@ -60,126 +31,132 @@ export interface ZoningSourceFeature {
|
|
|
60
31
|
planTo: string | null;
|
|
61
32
|
currentPlan: number;
|
|
62
33
|
/**
|
|
63
|
-
* `ZONE_ORIG
|
|
34
|
+
* The `ZONE_ORIG` value, verbatim.
|
|
35
|
+
*
|
|
36
|
+
* Case and trailing spaces are kept because some codes differ only by them.
|
|
64
37
|
*/
|
|
65
38
|
localCode: string;
|
|
66
39
|
localDescription: string | null;
|
|
67
40
|
localCodeURL: string | null;
|
|
68
41
|
/**
|
|
69
|
-
* `ZONE_GZT`
|
|
42
|
+
* The `ZONE_GZT` value.
|
|
43
|
+
*
|
|
44
|
+
* It is the Department's national generic type for this polygon.
|
|
70
45
|
*/
|
|
71
46
|
crosswalkCode: string | null;
|
|
72
47
|
crosswalkDescription: string | null;
|
|
73
48
|
/**
|
|
74
|
-
* `SZO`
|
|
49
|
+
* The `SZO` value.
|
|
50
|
+
* It is the coarser national code as published.
|
|
75
51
|
*/
|
|
76
52
|
crosswalkRollup: string | null;
|
|
77
53
|
/**
|
|
78
|
-
* The rings
|
|
54
|
+
* The rings with hole roles resolved from their orientation, plus a record of that resolution.
|
|
79
55
|
*/
|
|
80
56
|
rings: ResolvedRingRoles;
|
|
81
57
|
}
|
|
82
58
|
/**
|
|
83
|
-
*
|
|
59
|
+
* Options for reading the bulk export.
|
|
84
60
|
*/
|
|
85
61
|
export interface ZoningIngestOptions {
|
|
86
62
|
/**
|
|
87
|
-
*
|
|
63
|
+
* The path of the bulk GeoJSON export.
|
|
88
64
|
*/
|
|
89
65
|
exportPath: string;
|
|
90
66
|
/**
|
|
91
|
-
*
|
|
67
|
+
* The maximum number of features to read.
|
|
68
|
+
* Fixture and smoke runs use it.
|
|
92
69
|
*/
|
|
93
70
|
limit?: number;
|
|
94
71
|
/**
|
|
95
|
-
* The EPSG code the source must declare.
|
|
96
|
-
*
|
|
72
|
+
* The EPSG code that the source must declare.
|
|
73
|
+
* A different code means the product has changed.
|
|
97
74
|
*/
|
|
98
75
|
expectEPSG?: number;
|
|
99
76
|
/**
|
|
100
|
-
* The extent every reprojected vertex must
|
|
77
|
+
* The extent that every reprojected vertex must fall inside.
|
|
78
|
+
* The default is the Department's declared extent.
|
|
101
79
|
*/
|
|
102
80
|
declaredBBox?: readonly [number, number, number, number];
|
|
103
81
|
/**
|
|
104
|
-
*
|
|
82
|
+
* The inclusive range of authority `objectid` values to read.
|
|
105
83
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* source's stable key — a range names the same features on every run, which an offset into a result set does not.
|
|
84
|
+
* The h3 wasm heap cannot be reset from JavaScript, so the build runs one child process per range.
|
|
85
|
+
* It uses `objectid` ranges because they select the same features on every run.
|
|
109
86
|
*
|
|
110
|
-
*
|
|
111
|
-
* scans all 247 MB for every range. The national set fits inside one chunk at the default bound, so that cost is not
|
|
112
|
-
* paid on a full build.
|
|
87
|
+
* Every range costs a full scan of the export, because the export is one GeoJSON document.
|
|
113
88
|
*/
|
|
114
89
|
objectIDFrom?: number;
|
|
115
90
|
objectIDTo?: number;
|
|
116
91
|
/**
|
|
117
|
-
*
|
|
92
|
+
* Restricts the read to one local authority's `LA_CODE`, for smoke runs.
|
|
118
93
|
*/
|
|
119
94
|
authorityCode?: string;
|
|
120
95
|
}
|
|
121
96
|
/**
|
|
122
|
-
*
|
|
97
|
+
* The metadata that the source declares, read before any feature.
|
|
123
98
|
*/
|
|
124
99
|
export interface ZoningSourceIdentity {
|
|
125
100
|
epsg: number;
|
|
126
101
|
featureCount: number;
|
|
127
102
|
layer: string;
|
|
128
103
|
/**
|
|
129
|
-
* The source's
|
|
130
|
-
* empty column rather than refuse, so the query is built from the set rather than from a schema read off a sibling
|
|
131
|
-
* publication.
|
|
104
|
+
* The source's attribute field names.
|
|
132
105
|
*/
|
|
133
106
|
fields: ReadonlySet<string>;
|
|
134
107
|
}
|
|
135
108
|
/**
|
|
136
|
-
* The attribute columns the ingest reads.
|
|
137
|
-
*
|
|
109
|
+
* The attribute columns that the ingest reads.
|
|
110
|
+
* Every column is required.
|
|
138
111
|
*/
|
|
139
112
|
export declare const ZONING_SOURCE_FIELDS: ReadonlyArray<string>;
|
|
140
113
|
/**
|
|
141
|
-
*
|
|
114
|
+
* Reads the source's declared projection, feature count and field list.
|
|
142
115
|
*
|
|
143
|
-
* @throws {Error} When the export is unreadable, its declared EPSG
|
|
144
|
-
*
|
|
116
|
+
* @throws {Error} When the export is unreadable, when its declared EPSG code differs
|
|
117
|
+
* from `expectEPSG`, or when it lacks a field that the ingest reads.
|
|
145
118
|
*/
|
|
146
119
|
export declare function readZoningSourceIdentity(options: ZoningIngestOptions): Promise<ZoningSourceIdentity>;
|
|
147
120
|
/**
|
|
148
|
-
*
|
|
121
|
+
* Streams the export through ogr2ogr as reprojected WKT and checks every vertex against the declared extent.
|
|
149
122
|
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
123
|
+
* The extent check catches swapped coordinate axes.
|
|
124
|
+
* The projection check misses that error.
|
|
152
125
|
*
|
|
153
|
-
* @throws {Error} When ogr2ogr fails, when a feature
|
|
154
|
-
*
|
|
126
|
+
* @throws {Error} When ogr2ogr fails, when a feature has no geometry or a blank local code, when
|
|
127
|
+
* a reprojected vertex falls outside the declared extent, or when a feature's rings have no exterior.
|
|
155
128
|
*/
|
|
156
129
|
export declare function readZoningFeatures(options: ZoningIngestOptions): AsyncGenerator<ZoningSourceFeature>;
|
|
157
130
|
/**
|
|
158
|
-
*
|
|
131
|
+
* Supplies a zoning build with its features and the source's declared identity.
|
|
159
132
|
*
|
|
160
|
-
* The builder takes
|
|
161
|
-
*
|
|
162
|
-
* the cell classification, the coverage rows, the manifest and the seal. A fixture rung that could only run through
|
|
163
|
-
* ogr2ogr would test the conversion on the machines that have it and nothing at all on the ones that do not.
|
|
133
|
+
* The builder takes this instead of a path so that fixtures can run the database
|
|
134
|
+
* build without network access or GDAL.
|
|
164
135
|
*/
|
|
165
136
|
export interface ZoningFeatureSource {
|
|
166
137
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
138
|
+
* The feature count that the source declares.
|
|
139
|
+
*
|
|
140
|
+
* The build throws when its streamed total differs from this count.
|
|
169
141
|
*/
|
|
170
142
|
declaredFeatureCount: number;
|
|
171
143
|
epsg: number;
|
|
172
144
|
/**
|
|
173
|
-
* A description of where
|
|
145
|
+
* A description of where the features came from, such as the export path.
|
|
174
146
|
*/
|
|
175
147
|
origin: string;
|
|
176
148
|
features: () => AsyncIterable<ZoningSourceFeature>;
|
|
177
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Options for {@link createExportFeatureSource}.
|
|
152
|
+
*/
|
|
178
153
|
export interface ExportSourceOptions extends ZoningIngestOptions {
|
|
179
154
|
declaredFeatureCount?: number;
|
|
180
155
|
}
|
|
181
156
|
/**
|
|
182
|
-
*
|
|
157
|
+
* Creates a {@link ZoningFeatureSource} for the bulk export.
|
|
158
|
+
*
|
|
159
|
+
* It reads the export's identity immediately and streams features when asked.
|
|
183
160
|
*/
|
|
184
161
|
export declare function createExportFeatureSource(options: ExportSourceOptions): Promise<ZoningFeatureSource>;
|
|
185
162
|
//# sourceMappingURL=ingest.d.ts.map
|
package/out/sdk/ingest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../../
|
|
1
|
+
{"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../../sdk/ingest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAGjE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B;;;;OAIG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAA;IACnC;;;OAGG;IACH,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B;;OAEG;IACH,KAAK,EAAE,iBAAiB,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,E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