@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/sdk/cells.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
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 { compactAcrossResolutions, shortCellToInt } from "@mailwoman/spatial";
|
|
30
|
+
import { polygonToCells } from "h3-js";
|
|
31
|
+
export { addCoverageCells, CELL_ESTIMATE_BUDGET, classifyFeatureCells, coverageCellFor, estimateCellCount, featureCellRows, MIN_INDEX_RESOLUTION, resolutionForFeature, } 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 function polyfillFindsNothing(polygons, resolution) {
|
|
40
|
+
for (const rings of polygons) {
|
|
41
|
+
// `isGeoJSON = true`: the rings are already `[lon, lat]`, which is the order the ingest emits.
|
|
42
|
+
if (polygonToCells(rings, resolution, true).length)
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Accumulate one resolution's cell index over a stream of features.
|
|
49
|
+
*
|
|
50
|
+
* The whole set is held as short-cell STRINGS rather than the integers the tables store, because `compactCells` is an
|
|
51
|
+
* h3-js function over full indexes and round-tripping at every step would cost more than the strings do. The candidate
|
|
52
|
+
* counter is keyed by the 48-bit INTEGER instead: it is the larger of the two at every candidate resolution, and it is
|
|
53
|
+
* never handed back to h3.
|
|
54
|
+
*/
|
|
55
|
+
export class ZoningCellIndex {
|
|
56
|
+
resolution;
|
|
57
|
+
#whole = new Set();
|
|
58
|
+
#wholeShort = new Set();
|
|
59
|
+
#candidates = new Map();
|
|
60
|
+
#features = 0;
|
|
61
|
+
#coarsened = 0;
|
|
62
|
+
#zeroCell = 0;
|
|
63
|
+
#polyfillZeroCell = 0;
|
|
64
|
+
#measuredPolyfill = false;
|
|
65
|
+
constructor(resolution) {
|
|
66
|
+
this.resolution = resolution;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Fold one feature's classification in.
|
|
70
|
+
*/
|
|
71
|
+
add(cells) {
|
|
72
|
+
this.#features++;
|
|
73
|
+
if (cells.resolution !== this.resolution) {
|
|
74
|
+
this.#coarsened++;
|
|
75
|
+
}
|
|
76
|
+
if (!cells.whole.length && !cells.partial.length) {
|
|
77
|
+
this.#zeroCell++;
|
|
78
|
+
}
|
|
79
|
+
for (const cell of cells.whole) {
|
|
80
|
+
this.#whole.add(cell);
|
|
81
|
+
this.#wholeShort.add(shortCellToInt(cell));
|
|
82
|
+
this.#count(cell);
|
|
83
|
+
}
|
|
84
|
+
for (const cell of cells.partial) {
|
|
85
|
+
this.#count(cell);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Record that a centre-in-polygon polyfill found nothing for one feature.
|
|
90
|
+
*/
|
|
91
|
+
addPolyfillProbe(foundNothing) {
|
|
92
|
+
this.#measuredPolyfill = true;
|
|
93
|
+
if (foundNothing) {
|
|
94
|
+
this.#polyfillZeroCell++;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The measurement.
|
|
99
|
+
*
|
|
100
|
+
* The compacted count is an approximation of what the build stores and is reported as one: the build compacts each
|
|
101
|
+
* FEATURE's whole set, while this compacts the union of them. The union can only compact at least as far, so this is
|
|
102
|
+
* a lower bound on the stored row count — the direction a size estimate should err in — and the build's own receipt
|
|
103
|
+
* reports the real number.
|
|
104
|
+
*/
|
|
105
|
+
finish() {
|
|
106
|
+
const compacted = compactAcrossResolutions(this.#whole).length;
|
|
107
|
+
const counts = [];
|
|
108
|
+
let total = 0;
|
|
109
|
+
let max = 0;
|
|
110
|
+
let multi = 0;
|
|
111
|
+
let partial = 0;
|
|
112
|
+
for (const [cell, count] of this.#candidates) {
|
|
113
|
+
counts.push(count);
|
|
114
|
+
total += count;
|
|
115
|
+
if (count > max) {
|
|
116
|
+
max = count;
|
|
117
|
+
}
|
|
118
|
+
if (count > 1) {
|
|
119
|
+
multi++;
|
|
120
|
+
}
|
|
121
|
+
if (!this.#wholeShort.has(cell)) {
|
|
122
|
+
partial++;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
counts.sort((left, right) => left - right);
|
|
126
|
+
const touched = this.#candidates.size;
|
|
127
|
+
return {
|
|
128
|
+
resolution: this.resolution,
|
|
129
|
+
features: this.#features,
|
|
130
|
+
touchedCells: touched,
|
|
131
|
+
wholeCells: this.#whole.size,
|
|
132
|
+
partialCells: partial,
|
|
133
|
+
partialShare: touched ? partial / touched : 0,
|
|
134
|
+
compactedWholeCells: compacted,
|
|
135
|
+
storedCellRows: compacted + partial,
|
|
136
|
+
candidatesPerCell: {
|
|
137
|
+
mean: touched ? total / touched : 0,
|
|
138
|
+
// Nearest-rank p90 over the candidate counts, which is the shape `@mailwoman/core/stats` uses.
|
|
139
|
+
p90: counts.length ? counts[Math.min(counts.length - 1, Math.ceil(0.9 * counts.length) - 1)] : 0,
|
|
140
|
+
max,
|
|
141
|
+
},
|
|
142
|
+
multiCandidateCells: multi,
|
|
143
|
+
multiCandidateShare: touched ? multi / touched : 0,
|
|
144
|
+
...(this.#measuredPolyfill ? { polyfillZeroCellFeatures: this.#polyfillZeroCell } : {}),
|
|
145
|
+
coarsenedFeatures: this.#coarsened,
|
|
146
|
+
zeroCellFeatures: this.#zeroCell,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
#count(cell) {
|
|
150
|
+
const short = shortCellToInt(cell);
|
|
151
|
+
this.#candidates.set(short, (this.#candidates.get(short) ?? 0) + 1);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The measurement as markdown table ROWS — what a build receipt carries, one line per element so a caller printing them
|
|
156
|
+
* never has to split a joined string back apart.
|
|
157
|
+
*
|
|
158
|
+
* THE ZERO-CELL COLUMN IS FIRST AFTER THE COUNTS, because it is the column the resolution is chosen on and the one a
|
|
159
|
+
* reader most needs to see is not zero for the alternative index.
|
|
160
|
+
*/
|
|
161
|
+
export function formatResolutionRows(measurements) {
|
|
162
|
+
return [
|
|
163
|
+
"| res | features | polyfill-only zero-cell | stored cell rows | touched cells | candidates/cell mean | p90 | max | cells >1 candidate | partial share | coarsened |",
|
|
164
|
+
"| --- | -------- | ----------------------- | ---------------- | ------------- | -------------------- | --- | --- | ------------------ | ------------- | --------- |",
|
|
165
|
+
...measurements.map((measurement) => `| ${measurement.resolution} | ${measurement.features.toLocaleString()} | ` +
|
|
166
|
+
`${measurement.polyfillZeroCellFeatures === undefined
|
|
167
|
+
? "not measured"
|
|
168
|
+
: `${measurement.polyfillZeroCellFeatures.toLocaleString()} (${((measurement.polyfillZeroCellFeatures / Math.max(1, measurement.features)) *
|
|
169
|
+
100).toFixed(1)}%)`} | ` +
|
|
170
|
+
`${measurement.storedCellRows.toLocaleString()} | ${measurement.touchedCells.toLocaleString()} | ` +
|
|
171
|
+
`${measurement.candidatesPerCell.mean.toFixed(2)} | ${measurement.candidatesPerCell.p90} | ${measurement.candidatesPerCell.max} | ` +
|
|
172
|
+
`${measurement.multiCandidateCells.toLocaleString()} (${(measurement.multiCandidateShare * 100).toFixed(1)}%) | ` +
|
|
173
|
+
`${(measurement.partialShare * 100).toFixed(1)}% | ${measurement.coarsenedFeatures.toLocaleString()} |`),
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=cells.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cells.js","sourceRoot":"","sources":["../../lib/sdk/cells.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAkC,MAAM,oBAAoB,CAAA;AAC7G,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAItC,OAAO,EACN,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,GAEpB,MAAM,oBAAoB,CAAA;AAE3B;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAA2B,EAAE,UAAk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
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The Department's ArcGIS item, its feature service and the Hub download job, read through
|
|
7
|
+
* {@linkcode APIClient}.
|
|
8
|
+
*
|
|
9
|
+
* THESE ARE API REQUESTS AND THEY GO THROUGH `APIClient`. Small bodies, repeated calls, a third-party
|
|
10
|
+
* host — the pacing, bounded retry, response caching and `ResourceError` mapping are exactly what they
|
|
11
|
+
* need. The 247 MB bulk export is NOT one of them: it is a file transfer, it streams to disk on raw
|
|
12
|
+
* `fetch`, and `download.ts` says so in place.
|
|
13
|
+
*
|
|
14
|
+
* FOUR MEASURED CLIENT BEHAVIORS ARE ENCODED HERE RATHER THAN WRITTEN DOWN SOMEWHERE ELSE.
|
|
15
|
+
*
|
|
16
|
+
* 1. THE HUB DOWNLOAD JOB ANSWERS WITH A `resultUrl` THAT 302s. `…/api/download/v1/items/<id>/geojson?
|
|
17
|
+
* redirect=false&layers=0` returns `{"status":"Completed","resultUrl":…}` in 249 bytes; the result URL
|
|
18
|
+
* itself redirects, so the transfer needs `redirect: "follow"`. A client that took the first response as
|
|
19
|
+
* the file writes a redirect page to disk and reports a successful download.
|
|
20
|
+
* 2. THE BULK EXPORT IS EPSG:2157 UNDER A `crs` MEMBER RFC 7946 REMOVED. The file's own header carries
|
|
21
|
+
* `"crs":{"type":"name","properties":{"name":"EPSG:2157"}}` and its coordinates are Irish Transverse
|
|
22
|
+
* Mercator metres. A strict RFC 7946 reader ignores the member and places Ireland at latitude 735,435;
|
|
23
|
+
* GDAL honours it, which is why `sdk/ingest.ts` reads the archive through ogr2ogr and asserts the
|
|
24
|
+
* reprojected result lands inside the Department's own declared extent.
|
|
25
|
+
* 3. THE PUBLISHER'S OWN AREA STATISTIC IS NOT IN THE ARCHIVE. `Shape__Area` is a service field and the
|
|
26
|
+
* GeoJSON export drops it, so the area cross-check has to come from {@linkcode readShapeAreaSum} — which
|
|
27
|
+
* makes it a genuine two-path check rather than the archive agreeing with itself. Measured:
|
|
28
|
+
* 5,444,492,956.40 m² over 85,330 features.
|
|
29
|
+
* 4. `GZT_LINK` POINTS AT A HOST WITH NO DNS RECORD. All 85,330 rows link their generic type's definition to
|
|
30
|
+
* `viewer.myplan.ie`, which has no A or AAAA record, and three candidate replacements on the live host
|
|
31
|
+
* answer HTTP 404. So `zoning_vocabulary.definition_url` cannot be populated from it and is left NULL
|
|
32
|
+
* rather than filled with a plausible one.
|
|
33
|
+
*/
|
|
34
|
+
import { APIClient, type APIClientConfig } from "@mailwoman/core/api";
|
|
35
|
+
import { type CreatePacedCachedClientOptions } from "@mailwoman/core/api/paced-client";
|
|
36
|
+
export { isTransientResourceError } from "@mailwoman/core/api";
|
|
37
|
+
export { ResourceError } from "@mailwoman/core/errors";
|
|
38
|
+
/**
|
|
39
|
+
* The ArcGIS Online sharing API, where the item's licence and attribution fields are readable.
|
|
40
|
+
*/
|
|
41
|
+
export declare const ARCGIS_ITEM_API_BASE_URL = "https://www.arcgis.com/sharing/rest/content/items";
|
|
42
|
+
/**
|
|
43
|
+
* The Hub download API, which is how the whole layer is exported in one file.
|
|
44
|
+
*/
|
|
45
|
+
export declare const HUB_DOWNLOAD_API_BASE_URL = "https://hub.arcgis.com/api/download/v1/items";
|
|
46
|
+
/**
|
|
47
|
+
* Minimum spacing between requests to the Department's hosts, in milliseconds.
|
|
48
|
+
*
|
|
49
|
+
* The Department publishes no rate limit for this service, so this is courtesy pacing rather than a published ceiling —
|
|
50
|
+
* stated as such rather than dressed up as a measured limit. Two requests a second is far below anything a hosted
|
|
51
|
+
* ArcGIS feature service is provisioned for and costs a build nothing: the acquisition path makes single-digit numbers
|
|
52
|
+
* of calls and the verification a few dozen.
|
|
53
|
+
*/
|
|
54
|
+
export declare const GZT_MIN_REQUEST_INTERVAL_MS = 500;
|
|
55
|
+
export type CreateZoningClientOptions = CreatePacedCachedClientOptions;
|
|
56
|
+
/**
|
|
57
|
+
* What the item says about the product.
|
|
58
|
+
*/
|
|
59
|
+
export interface ZoningItemRecord {
|
|
60
|
+
itemID: string;
|
|
61
|
+
title: string;
|
|
62
|
+
/**
|
|
63
|
+
* The item's `modified` timestamp as an ISO date — the product vintage, and the freshness signal.
|
|
64
|
+
*/
|
|
65
|
+
modifiedDate: string;
|
|
66
|
+
/**
|
|
67
|
+
* `accessInformation`, verbatim: the credit line the Department asks for.
|
|
68
|
+
*/
|
|
69
|
+
accessInformation: string;
|
|
70
|
+
/**
|
|
71
|
+
* `licenseInfo`, verbatim, with its markup stripped. Read rather than trusted from the constant, so a change in the
|
|
72
|
+
* terms is visible at build time.
|
|
73
|
+
*/
|
|
74
|
+
licenseInfo: string;
|
|
75
|
+
/**
|
|
76
|
+
* The extent the item declares, in CRS84 order.
|
|
77
|
+
*/
|
|
78
|
+
declaredBBox: [number, number, number, number];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A client for the Department's item, feature service and Hub download job.
|
|
82
|
+
*/
|
|
83
|
+
export declare class GZTClient extends APIClient<APIClientConfig> {
|
|
84
|
+
/**
|
|
85
|
+
* The item record: its vintage, its credit line, its licence text and its declared extent.
|
|
86
|
+
*
|
|
87
|
+
* @throws {Error} When the item is missing, or declares no extent.
|
|
88
|
+
*/
|
|
89
|
+
readItemRecord(): Promise<ZoningItemRecord>;
|
|
90
|
+
/**
|
|
91
|
+
* The feature count the service reports, and the EPSG code it declares.
|
|
92
|
+
*
|
|
93
|
+
* The SECOND path in the build's agreement check: the same authority, a different distribution channel. An archive
|
|
94
|
+
* whose feature count disagrees with the live service is not a file this build should be writing into a sealed
|
|
95
|
+
* artifact.
|
|
96
|
+
*/
|
|
97
|
+
readServiceIdentity(): Promise<{
|
|
98
|
+
featureCount: number;
|
|
99
|
+
epsg: number;
|
|
100
|
+
maxRecordCount: number;
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* The sum of the Department's own `Shape__Area` column, in square metres.
|
|
104
|
+
*
|
|
105
|
+
* THE ONE NUMBER THAT SETTLES THE HOLE QUESTION, and it has to come from the service because the bulk export drops
|
|
106
|
+
* the column. Read with the holes the rings total 5,444.5 km²; read without them, 5,666.6 km². The difference is 4.1%
|
|
107
|
+
* of area and, far more importantly, a ray cast that answers "inside" for every location a plan carved out.
|
|
108
|
+
*/
|
|
109
|
+
readShapeAreaSum(): Promise<number>;
|
|
110
|
+
/**
|
|
111
|
+
* Ask the Hub for a bulk GeoJSON export and return the URL it answers with.
|
|
112
|
+
*
|
|
113
|
+
* `redirect=false` asks for the job record rather than a redirect, so this call reads a small JSON body. The URL it
|
|
114
|
+
* returns is the one that 302s — see {@link downloadZoningExport}.
|
|
115
|
+
*
|
|
116
|
+
* @throws {Error} When the job is not `Completed`, or names no result URL. A partial job that answered with a status
|
|
117
|
+
* and no URL would otherwise present as an empty download.
|
|
118
|
+
*/
|
|
119
|
+
readExportURL(): Promise<string>;
|
|
120
|
+
/**
|
|
121
|
+
* The features the service publishes near a point — the verification's second path.
|
|
122
|
+
*
|
|
123
|
+
* `outSR=4326` on the query path, because the service answers in Irish Transverse Mercator otherwise and the
|
|
124
|
+
* comparison is against coordinates this package reprojected itself. The service answers a bounding box rather than a
|
|
125
|
+
* point, so the containment decision is made against the returned rings by the caller.
|
|
126
|
+
*/
|
|
127
|
+
readFeaturesNear(latitude: number, longitude: number, halfWidthDegrees: number): Promise<Array<{
|
|
128
|
+
properties?: Record<string, unknown>;
|
|
129
|
+
geometry?: {
|
|
130
|
+
type: string;
|
|
131
|
+
coordinates: unknown;
|
|
132
|
+
};
|
|
133
|
+
}>>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Refuse an attribution the published item no longer matches.
|
|
137
|
+
*
|
|
138
|
+
* READ AT BUILD TIME RATHER THAN TRUSTED FROM THE CONSTANT. The constant is what the artifact is stamped with offline;
|
|
139
|
+
* this is the live value it is reconciled with when the network is available. The check is on the DEPARTMENT'S CREDIT
|
|
140
|
+
* LINE and on the Tailte Éireann clause separately, because they are two different statements and the second is the one
|
|
141
|
+
* that holds this layer at `build-local`: an item that dropped it would be a licence change worth hearing about, and an
|
|
142
|
+
* item that dropped only the credit line would be a different one.
|
|
143
|
+
*
|
|
144
|
+
* @throws {Error} When either half of {@link GZT_ATTRIBUTION} is no longer in the item's own fields.
|
|
145
|
+
*/
|
|
146
|
+
export declare function assertAttributionUnchanged(record: Pick<ZoningItemRecord, "accessInformation" | "licenseInfo">): void;
|
|
147
|
+
/**
|
|
148
|
+
* Build a {@link GZTClient} with the disk cache and pacing this package's acquisition path expects.
|
|
149
|
+
*/
|
|
150
|
+
export declare function createGZTClient(options?: CreateZoningClientOptions): GZTClient;
|
|
151
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../lib/sdk/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,EAA2B,KAAK,8BAA8B,EAAE,MAAM,kCAAkC,CAAA;AAM/G,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,wBAAwB,sDAAsD,CAAA;AAE3F;;GAEG;AACH,eAAO,MAAM,yBAAyB,iDAAiD,CAAA;AAEvF;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,MAAM,CAAA;AAW9C,MAAM,MAAM,yBAAyB,GAAG,8BAA8B,CAAA;AAEtE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAA;IACzB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9C;AAOD;;GAEG;AACH,qBAAa,SAAU,SAAQ,SAAS,CAAC,eAAe,CAAC;IACxD;;;;OAIG;IACU,cAAc,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAgDxD;;;;;;OAMG;IACU,mBAAmB,IAAI,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,CAAC;IA2B3G;;;;;;OAMG;IACU,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAwBhD;;;;;;;;OAQG;IACU,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAkB7C;;;;;;OAMG;IACU,gBAAgB,CAC5B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,MAAM,GACtB,OAAO,CAAC,KAAK,CAAC;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,QAAQ,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,CAAC,CAAC;CA0B9G;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,mBAAmB,GAAG,aAAa,CAAC,GAAG,IAAI,CAcpH;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,yBAA8B,GAAG,SAAS,CAWlF"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The Department's ArcGIS item, its feature service and the Hub download job, read through
|
|
7
|
+
* {@linkcode APIClient}.
|
|
8
|
+
*
|
|
9
|
+
* THESE ARE API REQUESTS AND THEY GO THROUGH `APIClient`. Small bodies, repeated calls, a third-party
|
|
10
|
+
* host — the pacing, bounded retry, response caching and `ResourceError` mapping are exactly what they
|
|
11
|
+
* need. The 247 MB bulk export is NOT one of them: it is a file transfer, it streams to disk on raw
|
|
12
|
+
* `fetch`, and `download.ts` says so in place.
|
|
13
|
+
*
|
|
14
|
+
* FOUR MEASURED CLIENT BEHAVIORS ARE ENCODED HERE RATHER THAN WRITTEN DOWN SOMEWHERE ELSE.
|
|
15
|
+
*
|
|
16
|
+
* 1. THE HUB DOWNLOAD JOB ANSWERS WITH A `resultUrl` THAT 302s. `…/api/download/v1/items/<id>/geojson?
|
|
17
|
+
* redirect=false&layers=0` returns `{"status":"Completed","resultUrl":…}` in 249 bytes; the result URL
|
|
18
|
+
* itself redirects, so the transfer needs `redirect: "follow"`. A client that took the first response as
|
|
19
|
+
* the file writes a redirect page to disk and reports a successful download.
|
|
20
|
+
* 2. THE BULK EXPORT IS EPSG:2157 UNDER A `crs` MEMBER RFC 7946 REMOVED. The file's own header carries
|
|
21
|
+
* `"crs":{"type":"name","properties":{"name":"EPSG:2157"}}` and its coordinates are Irish Transverse
|
|
22
|
+
* Mercator metres. A strict RFC 7946 reader ignores the member and places Ireland at latitude 735,435;
|
|
23
|
+
* GDAL honours it, which is why `sdk/ingest.ts` reads the archive through ogr2ogr and asserts the
|
|
24
|
+
* reprojected result lands inside the Department's own declared extent.
|
|
25
|
+
* 3. THE PUBLISHER'S OWN AREA STATISTIC IS NOT IN THE ARCHIVE. `Shape__Area` is a service field and the
|
|
26
|
+
* GeoJSON export drops it, so the area cross-check has to come from {@linkcode readShapeAreaSum} — which
|
|
27
|
+
* makes it a genuine two-path check rather than the archive agreeing with itself. Measured:
|
|
28
|
+
* 5,444,492,956.40 m² over 85,330 features.
|
|
29
|
+
* 4. `GZT_LINK` POINTS AT A HOST WITH NO DNS RECORD. All 85,330 rows link their generic type's definition to
|
|
30
|
+
* `viewer.myplan.ie`, which has no A or AAAA record, and three candidate replacements on the live host
|
|
31
|
+
* answer HTTP 404. So `zoning_vocabulary.definition_url` cannot be populated from it and is left NULL
|
|
32
|
+
* rather than filled with a plausible one.
|
|
33
|
+
*/
|
|
34
|
+
import { APIClient } from "@mailwoman/core/api";
|
|
35
|
+
import { createPacedCachedClient } from "@mailwoman/core/api/paced-client";
|
|
36
|
+
import { htmlToText } from "@mailwoman/core/html/text";
|
|
37
|
+
import { GZT_ATTRIBUTION, GZT_ITEM_ID, GZT_SERVICE_URL, GZT_SOURCE_EPSG } from "#vocabulary";
|
|
38
|
+
// Re-exported so a caller branching on this client's failures needs exactly one import.
|
|
39
|
+
export { isTransientResourceError } from "@mailwoman/core/api";
|
|
40
|
+
export { ResourceError } from "@mailwoman/core/errors";
|
|
41
|
+
/**
|
|
42
|
+
* The ArcGIS Online sharing API, where the item's licence and attribution fields are readable.
|
|
43
|
+
*/
|
|
44
|
+
export const ARCGIS_ITEM_API_BASE_URL = "https://www.arcgis.com/sharing/rest/content/items";
|
|
45
|
+
/**
|
|
46
|
+
* The Hub download API, which is how the whole layer is exported in one file.
|
|
47
|
+
*/
|
|
48
|
+
export const HUB_DOWNLOAD_API_BASE_URL = "https://hub.arcgis.com/api/download/v1/items";
|
|
49
|
+
/**
|
|
50
|
+
* Minimum spacing between requests to the Department's hosts, in milliseconds.
|
|
51
|
+
*
|
|
52
|
+
* The Department publishes no rate limit for this service, so this is courtesy pacing rather than a published ceiling —
|
|
53
|
+
* stated as such rather than dressed up as a measured limit. Two requests a second is far below anything a hosted
|
|
54
|
+
* ArcGIS feature service is provisioned for and costs a build nothing: the acquisition path makes single-digit numbers
|
|
55
|
+
* of calls and the verification a few dozen.
|
|
56
|
+
*/
|
|
57
|
+
export const GZT_MIN_REQUEST_INTERVAL_MS = 500;
|
|
58
|
+
/**
|
|
59
|
+
* How long a cached metadata response stays fresh.
|
|
60
|
+
*
|
|
61
|
+
* Six hours, chosen against the product's own cadence rather than a wall-clock intuition. The Department publishes no
|
|
62
|
+
* maintenance-frequency statement at all; what is observable is that the item's `modified` date and the data's latest
|
|
63
|
+
* `UPLOAD_DATE` move a handful of times a year, so a shorter TTL buys nothing.
|
|
64
|
+
*/
|
|
65
|
+
const GZT_CACHE_TTL_MS = 6 * 60 * 60 * 1000;
|
|
66
|
+
/**
|
|
67
|
+
* Ordinates in a CRS84 bounding box: `minLon, minLat, maxLon, maxLat`.
|
|
68
|
+
*/
|
|
69
|
+
const BBOX_ORDINATES = 4;
|
|
70
|
+
/**
|
|
71
|
+
* A client for the Department's item, feature service and Hub download job.
|
|
72
|
+
*/
|
|
73
|
+
export class GZTClient extends APIClient {
|
|
74
|
+
/**
|
|
75
|
+
* The item record: its vintage, its credit line, its licence text and its declared extent.
|
|
76
|
+
*
|
|
77
|
+
* @throws {Error} When the item is missing, or declares no extent.
|
|
78
|
+
*/
|
|
79
|
+
async readItemRecord() {
|
|
80
|
+
const { data } = await this.fetch({
|
|
81
|
+
method: "GET",
|
|
82
|
+
url: `${ARCGIS_ITEM_API_BASE_URL}/${GZT_ITEM_ID}`,
|
|
83
|
+
params: { f: "json" },
|
|
84
|
+
});
|
|
85
|
+
if (data.id !== GZT_ITEM_ID) {
|
|
86
|
+
throw new Error(`zoning client: the item endpoint answered for ${JSON.stringify(data.id)}, expected ${GZT_ITEM_ID}`);
|
|
87
|
+
}
|
|
88
|
+
if (typeof data.modified !== "number") {
|
|
89
|
+
throw new TypeError("zoning client: the item carries no `modified` timestamp — the product vintage cannot be read, and guessing it would stamp an artifact with a version that means nothing");
|
|
90
|
+
}
|
|
91
|
+
const extent = data.extent;
|
|
92
|
+
if (!extent || extent.length < 2 || !extent[0] || !extent[1]) {
|
|
93
|
+
throw new TypeError("zoning client: the item declares no extent");
|
|
94
|
+
}
|
|
95
|
+
const bbox = [extent[0][0], extent[0][1], extent[1][0], extent[1][1]];
|
|
96
|
+
if (bbox.some((ordinate) => !Number.isFinite(ordinate)) || bbox.length !== BBOX_ORDINATES) {
|
|
97
|
+
throw new TypeError(`zoning client: the item's extent is not a 2D bounding box (${JSON.stringify(extent)})`);
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
itemID: data.id,
|
|
101
|
+
title: data.title ?? "",
|
|
102
|
+
modifiedDate: new Date(data.modified).toISOString().slice(0, 10),
|
|
103
|
+
accessInformation: data.accessInformation ?? "",
|
|
104
|
+
licenseInfo: htmlToText(data.licenseInfo ?? ""),
|
|
105
|
+
declaredBBox: bbox,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The feature count the service reports, and the EPSG code it declares.
|
|
110
|
+
*
|
|
111
|
+
* The SECOND path in the build's agreement check: the same authority, a different distribution channel. An archive
|
|
112
|
+
* whose feature count disagrees with the live service is not a file this build should be writing into a sealed
|
|
113
|
+
* artifact.
|
|
114
|
+
*/
|
|
115
|
+
async readServiceIdentity() {
|
|
116
|
+
const { data } = await this.fetch({ method: "GET", url: GZT_SERVICE_URL, params: { f: "json" } });
|
|
117
|
+
const epsg = data.extent?.spatialReference?.latestWkid ?? data.extent?.spatialReference?.wkid;
|
|
118
|
+
if (epsg !== GZT_SOURCE_EPSG) {
|
|
119
|
+
throw new Error(`zoning client: the service declares EPSG:${epsg}, expected EPSG:${GZT_SOURCE_EPSG} — the source's projection changed, which is a product change rather than a variation to absorb`);
|
|
120
|
+
}
|
|
121
|
+
const { data: counted } = await this.fetch({
|
|
122
|
+
method: "GET",
|
|
123
|
+
url: `${GZT_SERVICE_URL}/query`,
|
|
124
|
+
params: { where: "1=1", returnCountOnly: "true", f: "json" },
|
|
125
|
+
});
|
|
126
|
+
if (typeof counted.count !== "number") {
|
|
127
|
+
throw new TypeError("zoning client: the service returned no feature count");
|
|
128
|
+
}
|
|
129
|
+
return { featureCount: counted.count, epsg, maxRecordCount: data.maxRecordCount ?? 0 };
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The sum of the Department's own `Shape__Area` column, in square metres.
|
|
133
|
+
*
|
|
134
|
+
* THE ONE NUMBER THAT SETTLES THE HOLE QUESTION, and it has to come from the service because the bulk export drops
|
|
135
|
+
* the column. Read with the holes the rings total 5,444.5 km²; read without them, 5,666.6 km². The difference is 4.1%
|
|
136
|
+
* of area and, far more importantly, a ray cast that answers "inside" for every location a plan carved out.
|
|
137
|
+
*/
|
|
138
|
+
async readShapeAreaSum() {
|
|
139
|
+
const { data } = await this.fetch({
|
|
140
|
+
method: "GET",
|
|
141
|
+
url: `${GZT_SERVICE_URL}/query`,
|
|
142
|
+
params: {
|
|
143
|
+
where: "1=1",
|
|
144
|
+
outStatistics: JSON.stringify([
|
|
145
|
+
{ statisticType: "sum", onStatisticField: "Shape__Area", outStatisticFieldName: "area_sum" },
|
|
146
|
+
]),
|
|
147
|
+
f: "json",
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
const sum = data.features?.[0]?.attributes?.area_sum;
|
|
151
|
+
if (typeof sum !== "number" || !Number.isFinite(sum)) {
|
|
152
|
+
throw new TypeError("zoning client: the service returned no Shape__Area sum — without the publisher's own figure the hole-orientation check has nothing to compare against, and reading every ring as an exterior is silent");
|
|
153
|
+
}
|
|
154
|
+
return sum;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Ask the Hub for a bulk GeoJSON export and return the URL it answers with.
|
|
158
|
+
*
|
|
159
|
+
* `redirect=false` asks for the job record rather than a redirect, so this call reads a small JSON body. The URL it
|
|
160
|
+
* returns is the one that 302s — see {@link downloadZoningExport}.
|
|
161
|
+
*
|
|
162
|
+
* @throws {Error} When the job is not `Completed`, or names no result URL. A partial job that answered with a status
|
|
163
|
+
* and no URL would otherwise present as an empty download.
|
|
164
|
+
*/
|
|
165
|
+
async readExportURL() {
|
|
166
|
+
const { data } = await this.fetch({
|
|
167
|
+
method: "GET",
|
|
168
|
+
url: `${HUB_DOWNLOAD_API_BASE_URL}/${GZT_ITEM_ID}/geojson`,
|
|
169
|
+
params: { redirect: "false", layers: "0" },
|
|
170
|
+
});
|
|
171
|
+
if (data.status !== "Completed" || !data.resultUrl) {
|
|
172
|
+
throw new Error(`zoning client: the Hub download job answered status ${JSON.stringify(data.status)} with ${data.resultUrl ? "a" : "no"} result URL${data.message ? ` (${data.message})` : ""}`);
|
|
173
|
+
}
|
|
174
|
+
return data.resultUrl;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* The features the service publishes near a point — the verification's second path.
|
|
178
|
+
*
|
|
179
|
+
* `outSR=4326` on the query path, because the service answers in Irish Transverse Mercator otherwise and the
|
|
180
|
+
* comparison is against coordinates this package reprojected itself. The service answers a bounding box rather than a
|
|
181
|
+
* point, so the containment decision is made against the returned rings by the caller.
|
|
182
|
+
*/
|
|
183
|
+
async readFeaturesNear(latitude, longitude, halfWidthDegrees) {
|
|
184
|
+
const { data } = await this.fetch({
|
|
185
|
+
method: "GET",
|
|
186
|
+
url: `${GZT_SERVICE_URL}/query`,
|
|
187
|
+
params: {
|
|
188
|
+
geometry: JSON.stringify({
|
|
189
|
+
xmin: longitude - halfWidthDegrees,
|
|
190
|
+
ymin: latitude - halfWidthDegrees,
|
|
191
|
+
xmax: longitude + halfWidthDegrees,
|
|
192
|
+
ymax: latitude + halfWidthDegrees,
|
|
193
|
+
spatialReference: { wkid: 4326 },
|
|
194
|
+
}),
|
|
195
|
+
geometryType: "esriGeometryEnvelope",
|
|
196
|
+
inSR: "4326",
|
|
197
|
+
outSR: "4326",
|
|
198
|
+
spatialRel: "esriSpatialRelIntersects",
|
|
199
|
+
outFields: "OBJECTID,ZONE_ORIG,ZONE_GZT,LA_CODE",
|
|
200
|
+
returnGeometry: "true",
|
|
201
|
+
f: "geojson",
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
return data.features ?? [];
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Refuse an attribution the published item no longer matches.
|
|
209
|
+
*
|
|
210
|
+
* READ AT BUILD TIME RATHER THAN TRUSTED FROM THE CONSTANT. The constant is what the artifact is stamped with offline;
|
|
211
|
+
* this is the live value it is reconciled with when the network is available. The check is on the DEPARTMENT'S CREDIT
|
|
212
|
+
* LINE and on the Tailte Éireann clause separately, because they are two different statements and the second is the one
|
|
213
|
+
* that holds this layer at `build-local`: an item that dropped it would be a licence change worth hearing about, and an
|
|
214
|
+
* item that dropped only the credit line would be a different one.
|
|
215
|
+
*
|
|
216
|
+
* @throws {Error} When either half of {@link GZT_ATTRIBUTION} is no longer in the item's own fields.
|
|
217
|
+
*/
|
|
218
|
+
export function assertAttributionUnchanged(record) {
|
|
219
|
+
if (!GZT_ATTRIBUTION.includes(record.accessInformation.trim()) || !record.accessInformation.trim()) {
|
|
220
|
+
throw new Error(`zoning client: the item's accessInformation reads ${JSON.stringify(record.accessInformation)}, and this build ships ` +
|
|
221
|
+
`${JSON.stringify(GZT_ATTRIBUTION)} — the credit line is what a re-user has to publish, so a change in it is a change in the terms`);
|
|
222
|
+
}
|
|
223
|
+
if (!record.licenseInfo.includes("Tailte Éireann")) {
|
|
224
|
+
throw new Error("zoning client: the item's licenseInfo no longer names Tailte Éireann as a licensor. That clause is the reason " +
|
|
225
|
+
"this layer is built locally rather than shipped, so its disappearance is a licence change to read rather than absorb");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Build a {@link GZTClient} with the disk cache and pacing this package's acquisition path expects.
|
|
230
|
+
*/
|
|
231
|
+
export function createGZTClient(options = {}) {
|
|
232
|
+
return createPacedCachedClient(GZTClient, {
|
|
233
|
+
displayName: "GZT",
|
|
234
|
+
minRequestIntervalMs: GZT_MIN_REQUEST_INTERVAL_MS,
|
|
235
|
+
cacheTTLMs: GZT_CACHE_TTL_MS,
|
|
236
|
+
cacheDirectory: ["zoning", "cache", "http"],
|
|
237
|
+
}, options);
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=client.js.map
|
|
@@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MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACd,gHAAgH;YAC/G,sHAAsH,CACvH,CAAA;IACF,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,UAAqC,EAAE;IACtE,OAAO,uBAAuB,CAC7B,SAAS,EACT;QACC,WAAW,EAAE,KAAK;QAClB,oBAAoB,EAAE,2BAA2B;QACjD,UAAU,EAAE,gBAAgB;QAC5B,cAAc,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC;KAC3C,EACD,OAAO,CACP,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Acquire the Department's bulk GeoJSON export — a 247,452,342-byte file streamed to disk.
|
|
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.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* The file name one vintage's export is kept under.
|
|
29
|
+
*/
|
|
30
|
+
export declare const GZT_EXPORT_FILE = "gzt-current-plan.geojson";
|
|
31
|
+
export interface DownloadZoningExportOptions {
|
|
32
|
+
/**
|
|
33
|
+
* The Hub job's `resultUrl`, read rather than assembled — it carries a generated file id with no relationship to the
|
|
34
|
+
* item id, so a hard-coded URL survives a republish by pointing at a file that is no longer the product.
|
|
35
|
+
*/
|
|
36
|
+
url: string;
|
|
37
|
+
/**
|
|
38
|
+
* The product vintage the cache is keyed on.
|
|
39
|
+
*/
|
|
40
|
+
vintage: string;
|
|
41
|
+
cacheRoot: string;
|
|
42
|
+
onProgress?: (message: string) => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Download the bulk export for one product vintage, returning the path of the GeoJSON file.
|
|
46
|
+
*
|
|
47
|
+
* Downloads to a `.part` file and renames only on a clean finish, so an interrupted transfer never presents as a
|
|
48
|
+
* complete export — the same discipline the database build uses, for the same reason.
|
|
49
|
+
*/
|
|
50
|
+
export declare function downloadZoningExport(options: DownloadZoningExportOptions): Promise<string>;
|
|
51
|
+
//# sourceMappingURL=download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../lib/sdk/download.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAOH;;GAEG;AACH,eAAO,MAAM,eAAe,6BAA6B,CAAA;AAEzD,MAAM,WAAW,2BAA2B;IAC3C;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CACtC;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBhG"}
|