@mailwoman/zoning 10.0.0 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +169 -163
  2. package/lib/index.ts +103 -135
  3. package/lib/paths.ts +24 -0
  4. package/lib/ring-roles.ts +30 -71
  5. package/lib/rings.ts +2 -13
  6. package/lib/schema.ts +98 -139
  7. package/lib/vocabulary.ts +52 -130
  8. package/out/index.d.ts +81 -101
  9. package/out/index.d.ts.map +1 -1
  10. package/out/index.js +37 -96
  11. package/out/index.js.map +1 -1
  12. package/out/paths.d.ts +19 -0
  13. package/out/paths.d.ts.map +1 -0
  14. package/out/paths.js +21 -0
  15. package/out/paths.js.map +1 -0
  16. package/out/ring-roles.d.ts +16 -50
  17. package/out/ring-roles.d.ts.map +1 -1
  18. package/out/ring-roles.js +18 -51
  19. package/out/ring-roles.js.map +1 -1
  20. package/out/rings.d.ts +2 -13
  21. package/out/rings.d.ts.map +1 -1
  22. package/out/rings.js +2 -13
  23. package/out/rings.js.map +1 -1
  24. package/out/schema.d.ts +90 -132
  25. package/out/schema.d.ts.map +1 -1
  26. package/out/schema.js +17 -45
  27. package/out/schema.js.map +1 -1
  28. package/out/sdk/build-zoning.d.ts +58 -111
  29. package/out/sdk/build-zoning.d.ts.map +1 -1
  30. package/out/sdk/build-zoning.js +50 -139
  31. package/out/sdk/build-zoning.js.map +1 -1
  32. package/out/sdk/cells.d.ts +21 -62
  33. package/out/sdk/cells.d.ts.map +1 -1
  34. package/out/sdk/cells.js +15 -52
  35. package/out/sdk/cells.js.map +1 -1
  36. package/out/sdk/client.d.ts +23 -67
  37. package/out/sdk/client.d.ts.map +1 -1
  38. package/out/sdk/client.js +29 -77
  39. package/out/sdk/client.js.map +1 -1
  40. package/out/sdk/download.d.ts +7 -27
  41. package/out/sdk/download.d.ts.map +1 -1
  42. package/out/sdk/download.js +8 -28
  43. package/out/sdk/download.js.map +1 -1
  44. package/out/sdk/ingest/chunk.d.ts +19 -43
  45. package/out/sdk/ingest/chunk.d.ts.map +1 -1
  46. package/out/sdk/ingest/chunk.js +19 -52
  47. package/out/sdk/ingest/chunk.js.map +1 -1
  48. package/out/sdk/ingest/worker.d.ts +9 -0
  49. package/out/sdk/ingest/worker.d.ts.map +1 -0
  50. package/out/{scripts/ingest-chunk.js → sdk/ingest/worker.js} +8 -10
  51. package/out/sdk/ingest/worker.js.map +1 -0
  52. package/out/sdk/ingest.d.ts +152 -0
  53. package/out/sdk/ingest.d.ts.map +1 -0
  54. package/out/sdk/ingest.js +200 -0
  55. package/out/sdk/ingest.js.map +1 -0
  56. package/out/sdk/measure-resolutions.d.ts +7 -34
  57. package/out/sdk/measure-resolutions.d.ts.map +1 -1
  58. package/out/sdk/measure-resolutions.js +5 -23
  59. package/out/sdk/measure-resolutions.js.map +1 -1
  60. package/out/sdk/test-kit.d.ts +75 -0
  61. package/out/sdk/test-kit.d.ts.map +1 -0
  62. package/out/{test-kit.js → sdk/test-kit.js} +20 -43
  63. package/out/sdk/test-kit.js.map +1 -0
  64. package/out/sdk/verify.d.ts +79 -80
  65. package/out/sdk/verify.d.ts.map +1 -1
  66. package/out/sdk/verify.js +83 -70
  67. package/out/sdk/verify.js.map +1 -1
  68. package/out/vocabulary.d.ts +52 -120
  69. package/out/vocabulary.d.ts.map +1 -1
  70. package/out/vocabulary.js +47 -125
  71. package/out/vocabulary.js.map +1 -1
  72. package/package.json +38 -162
  73. package/{lib/sdk → sdk}/build-zoning.ts +102 -188
  74. package/{lib/sdk → sdk}/cells.ts +27 -66
  75. package/{lib/sdk → sdk}/client.ts +34 -82
  76. package/sdk/download.ts +58 -0
  77. package/{lib/sdk → sdk}/ingest/chunk.ts +36 -65
  78. package/{lib/scripts/ingest-chunk.ts → sdk/ingest/worker.ts} +7 -9
  79. package/sdk/ingest.ts +354 -0
  80. package/sdk/measure-resolutions.ts +72 -0
  81. package/{lib → sdk}/test-kit.ts +21 -44
  82. package/sdk/verify.ts +367 -0
  83. package/lib/sdk/download.ts +0 -78
  84. package/lib/sdk/index.ts +0 -15
  85. package/lib/sdk/ingest/index.ts +0 -393
  86. package/lib/sdk/measure-resolutions.ts +0 -101
  87. package/lib/sdk/verify.ts +0 -357
  88. package/out/scripts/ingest-chunk.d.ts +0 -11
  89. package/out/scripts/ingest-chunk.d.ts.map +0 -1
  90. package/out/scripts/ingest-chunk.js.map +0 -1
  91. package/out/sdk/index.d.ts +0 -15
  92. package/out/sdk/index.d.ts.map +0 -1
  93. package/out/sdk/index.js +0 -15
  94. package/out/sdk/index.js.map +0 -1
  95. package/out/sdk/ingest/index.d.ts +0 -185
  96. package/out/sdk/ingest/index.d.ts.map +0 -1
  97. package/out/sdk/ingest/index.js +0 -232
  98. package/out/sdk/ingest/index.js.map +0 -1
  99. package/out/test-kit.d.ts +0 -96
  100. package/out/test-kit.d.ts.map +0 -1
  101. package/out/test-kit.js.map +0 -1
@@ -0,0 +1,200 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Streams the Department's bulk zoning export through ogr2ogr as reprojected WGS84 features.
7
+ *
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.
11
+ */
12
+ import { declaredFeatureCount } from "@mailwoman/core/layers";
13
+ import { assertRingsInsideExtent, requireArealPolygons } from "@mailwoman/spatial";
14
+ import { readOGRLayerIdentity } from "@mailwoman/spatial/tools/ogr";
15
+ import { spawnOGR2OGR } from "@mailwoman/spatial/tools/ogr/stream";
16
+ import { wellKnownGeometryToGeoJSON } from "@mailwoman/spatial/well-known-text";
17
+ import { CSVSpliterator } from "spliterator";
18
+ import { resolveRingRoles } from "#rings";
19
+ import { GZT_DECLARED_BBOX, GZT_SOURCE_EPSG } from "#vocabulary";
20
+ /**
21
+ * The number of coordinate decimals that ogr2ogr writes.
22
+ * Nine decimals is far finer than the source's precision.
23
+ */
24
+ const COORDINATE_PRECISION = 9;
25
+ /**
26
+ * The distance in degrees that a vertex may fall outside the declared extent.
27
+ *
28
+ * The published extent is rounded, so an exact test would fail on valid data.
29
+ * An unprojected or axis-swapped read lands much farther away and still fails.
30
+ */
31
+ const BBOX_MARGIN_DEGREES = 0.01;
32
+ /**
33
+ * The attribute columns that the ingest reads.
34
+ * Every column is required.
35
+ */
36
+ export const ZONING_SOURCE_FIELDS = [
37
+ "OBJECTID",
38
+ "LA_CODE",
39
+ "LA_NAME",
40
+ "PLAN_ID",
41
+ "PLAN_NAME",
42
+ "PLAN_LEVEL",
43
+ "PLAN_FROM",
44
+ "PLAN_TO",
45
+ "CURRENT_PLAN",
46
+ "ZONE_ORIG",
47
+ "ZONE_DESC",
48
+ "ZONE_LINK",
49
+ "ZONE_GZT",
50
+ "GZT_DESC",
51
+ "SZO",
52
+ ];
53
+ /**
54
+ * Reads the source's declared projection, feature count and field list.
55
+ *
56
+ * @throws {Error} When the export is unreadable, when its declared EPSG code differs
57
+ * from `expectEPSG`, or when it lacks a field that the ingest reads.
58
+ */
59
+ export async function readZoningSourceIdentity(options) {
60
+ const identity = await readOGRLayerIdentity({
61
+ path: options.exportPath,
62
+ expectEPSG: options.expectEPSG ?? GZT_SOURCE_EPSG,
63
+ context: "zoning ingest",
64
+ areaOfUse: "Ireland",
65
+ });
66
+ const missing = ZONING_SOURCE_FIELDS.filter((field) => field !== "OBJECTID" && !identity.fields.has(field));
67
+ // Given a missing column, `-select` makes ogr2ogr write an empty column without an error.
68
+ // This check turns a source schema change into an error that lists the missing columns.
69
+ if (missing.length) {
70
+ throw new Error(`zoning ingest: ${options.exportPath} carries no ${missing.join(", ")} column(s) — ogr2ogr writes a missing column as empty rather than refusing, so a schema change would arrive as a stream of blank codes`);
71
+ }
72
+ return { epsg: identity.epsg, featureCount: identity.featureCount, layer: identity.layer, fields: identity.fields };
73
+ }
74
+ /**
75
+ * Returns the `-where` arguments for a bounded chunk or a one-authority smoke run.
76
+ */
77
+ function whereClause(options) {
78
+ const bounds = [];
79
+ if (options.objectIDFrom !== undefined) {
80
+ bounds.push(`OBJECTID >= ${options.objectIDFrom}`);
81
+ }
82
+ if (options.objectIDTo !== undefined) {
83
+ bounds.push(`OBJECTID <= ${options.objectIDTo}`);
84
+ }
85
+ if (options.authorityCode) {
86
+ bounds.push(`LA_CODE = '${options.authorityCode.replaceAll("'", "''")}'`);
87
+ }
88
+ return bounds.length ? ["-where", bounds.join(" AND ")] : [];
89
+ }
90
+ /**
91
+ * Returns the value, or null when it is undefined or empty.
92
+ */
93
+ function blankToNull(value) {
94
+ if (!value)
95
+ return null;
96
+ return value ?? null;
97
+ }
98
+ /**
99
+ * Streams the export through ogr2ogr as reprojected WKT and checks every vertex against the declared extent.
100
+ *
101
+ * The extent check catches swapped coordinate axes.
102
+ * The projection check misses that error.
103
+ *
104
+ * @throws {Error} When ogr2ogr fails, when a feature has no geometry or a blank local code, when
105
+ * a reprojected vertex falls outside the declared extent, or when a feature's rings have no exterior.
106
+ */
107
+ export async function* readZoningFeatures(options) {
108
+ const [minLon, minLat, maxLon, maxLat] = options.declaredBBox ?? GZT_DECLARED_BBOX;
109
+ const args = [
110
+ "-f",
111
+ "CSV",
112
+ "/vsistdout/",
113
+ "-t_srs",
114
+ "EPSG:4326",
115
+ "-lco",
116
+ "GEOMETRY=AS_WKT",
117
+ "-lco",
118
+ "CREATE_CSVT=NO",
119
+ "-lco",
120
+ `COORDINATE_PRECISION=${COORDINATE_PRECISION}`,
121
+ "-select",
122
+ ZONING_SOURCE_FIELDS.join(","),
123
+ ...whereClause(options),
124
+ ...(options.limit === undefined ? [] : ["-limit", String(options.limit)]),
125
+ options.exportPath,
126
+ ];
127
+ const proc = spawnOGR2OGR(args, "zoning ingest");
128
+ try {
129
+ for await (const row of CSVSpliterator.fromAsync(proc.stdout)) {
130
+ const areaID = row.objectid ?? "";
131
+ if (!areaID) {
132
+ throw new Error("zoning ingest: a row carries no OBJECTID — the authority's own key is the artifact's key");
133
+ }
134
+ const wkt = row.wkt;
135
+ if (!wkt) {
136
+ throw new Error(`zoning ingest: feature ${areaID} carries no geometry`);
137
+ }
138
+ const polygons = normalizePolygons(wkt, `feature ${areaID}`);
139
+ assertRingsInsideExtent(polygons, `feature ${areaID}`, { minLon, minLat, maxLon, maxLat }, BBOX_MARGIN_DEGREES, "zoning ingest");
140
+ const localCode = row.zone_orig ?? "";
141
+ // The authority never publishes a zone without a code, so a blank code is an error.
142
+ if (!localCode) {
143
+ throw new Error(`zoning ingest: feature ${areaID} carries a blank ZONE_ORIG — the authority's own code is the claim, so a blank is refused rather than stored`);
144
+ }
145
+ yield {
146
+ areaID,
147
+ authorityCode: row.la_code ?? "",
148
+ authorityName: row.la_name ?? "",
149
+ planID: row.plan_id ?? "",
150
+ planName: row.plan_name ?? "",
151
+ planLevel: row.plan_level ?? "",
152
+ planFrom: blankToNull(row.plan_from),
153
+ planTo: blankToNull(row.plan_to),
154
+ currentPlan: Number(row.current_plan ?? 0),
155
+ // The code stays untrimmed because some distinct codes differ only by case or a trailing space.
156
+ localCode,
157
+ localDescription: blankToNull(row.zone_desc),
158
+ localCodeURL: blankToNull(row.zone_link),
159
+ crosswalkCode: blankToNull(row.zone_gzt),
160
+ crosswalkDescription: blankToNull(row.gzt_desc),
161
+ crosswalkRollup: blankToNull(row.szo),
162
+ rings: resolveRingRoles(polygons, areaID),
163
+ };
164
+ }
165
+ }
166
+ finally {
167
+ proc.kill();
168
+ }
169
+ await proc.settled;
170
+ }
171
+ /**
172
+ * Parses one WKT geometry into `MultiPolygon` rings.
173
+ *
174
+ * @throws {Error} When the geometry is neither a `Polygon` nor a `MultiPolygon`.
175
+ */
176
+ function normalizePolygons(wkt, label) {
177
+ const geometry = wellKnownGeometryToGeoJSON(wkt);
178
+ return requireArealPolygons(geometry, label, "zoning ingest");
179
+ }
180
+ /**
181
+ * Creates a {@link ZoningFeatureSource} for the bulk export.
182
+ *
183
+ * It reads the export's identity immediately and streams features when asked.
184
+ */
185
+ export async function createExportFeatureSource(options) {
186
+ const identity = await readZoningSourceIdentity(options);
187
+ return {
188
+ // The caller supplies the count for a range or one authority, because
189
+ // `ogrinfo` reports only the layer's total.
190
+ declaredFeatureCount: declaredFeatureCount({
191
+ declared: options.declaredFeatureCount,
192
+ limit: options.limit,
193
+ layerCount: identity.featureCount,
194
+ }),
195
+ epsg: identity.epsg,
196
+ origin: options.exportPath,
197
+ features: () => readZoningFeatures(options),
198
+ };
199
+ }
200
+ //# sourceMappingURL=ingest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingest.js","sourceRoot":"","sources":["../../sdk/ingest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAA0B,MAAM,oBAAoB,CAAA;AAC1G,OAAO,EAAE,oBAAoB,EAAuB,MAAM,8BAA8B,CAAA;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,EAAE,gBAAgB,EAA0B,MAAM,QAAQ,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAwFhE;;;GAGG;AACH,MAAM,oBAAoB,GAAG,CAAC,CAAA;AAE9B;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG,IAAI,CAAA;AAEhC;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA0B;IAC1D,UAAU;IACV,SAAS;IACT,SAAS;IACT,SAAS;IACT,WAAW;IACX,YAAY;IACZ,WAAW;IACX,SAAS;IACT,cAAc;IACd,WAAW;IACX,WAA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,CAAC"}
@@ -3,49 +3,22 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The index resolution is a MEASUREMENT this layer takes, not a number argued to — and for this subject the
7
- * inherited size contract's own statistic is not the one that decides it.
8
- *
9
- * THE `partial` SHARE CARRIES NO SIGNAL HERE, AND THAT WAS MEASURED. Computed over all 85,330 Irish
10
- * features, the median zoning polygon is 4,497 m² against an average res-9 cell of 105,333 m²: 95.7% of
11
- * them are smaller than a res-9 cell, 75.1% smaller than a res-10 cell and 34.5% smaller than a res-11 one.
12
- * So the `partial` share sits near 100% at every candidate and cannot choose between them.
13
- *
14
- * TWO NUMBERS CAN. CANDIDATES PER CELL is what a probe pays — a cell naming eight polygons is eight
15
- * bounding-box tests and up to eight ray casts — and the POLYFILL-ONLY ZERO-CELL COUNT is how many features
16
- * the obvious index would have dropped, each of which would read downstream as an absence of zoning. Both
17
- * are reported per resolution and the `partial` share rides beside them.
18
- *
19
- * ONE STREAM, EVERY RESOLUTION. Re-reading the export per candidate costs a full pass each and buys
20
- * nothing — the classification is per feature, so every candidate index folds the same feature in turn. The
21
- * cost is memory: each resolution holds its own cell sets, and the finest candidate dominates. A caller that
22
- * runs out of headroom runs the candidates in separate invocations.
6
+ * The `partial` share cannot choose between candidate resolutions, so each is reported by candidates per cell and by the polyfill-only zero-cell count.
23
7
  */
24
- import type { ResolutionMeasurementOptions } from "@mailwoman/core/layers";
8
+ import type { ResolutionMeasurementOptions, ResolutionMeasurementReport } from "@mailwoman/core/layers";
25
9
  import { type CellIndexMeasurement } from "#sdk/cells";
26
- import { type ZoningIngestOptions } from "#sdk/ingest/index";
10
+ import { type ZoningIngestOptions } from "#sdk/ingest";
27
11
  export interface MeasureResolutionsOptions extends ZoningIngestOptions, ResolutionMeasurementOptions {
28
12
  /**
29
- * Also run a centre-in-polygon polyfill per feature per resolution, to report what a polyfill-only index would have
30
- * dropped. On by default: it is the column the resolution is chosen on, and its cost is one extra h3 call per
31
- * feature.
13
+ * Also runs a center-in-polygon polyfill per feature per resolution at the
14
+ * cost of one extra h3 call per feature.
32
15
  */
33
16
  measurePolyfill?: boolean;
34
17
  }
35
- export interface ResolutionMeasurementReport {
36
- features: number;
37
- /**
38
- * The count the source declares for itself. A run whose streamed total differs read a truncated file.
39
- */
40
- declaredFeatureCount: number;
41
- measurements: CellIndexMeasurement[];
42
- }
43
18
  /**
44
19
  * Measure every candidate resolution over the real source.
45
20
  *
46
- * @throws {Error} When the streamed feature count does not match the count the source declares. A short read produces a
47
- * well-formed table describing a smaller country, which is the partial result that must throw.
21
+ * @throws {Error} When the streamed feature count does not match the count the source declares.
48
22
  */
49
- export declare function measureZoningCellResolutions(options: MeasureResolutionsOptions): Promise<ResolutionMeasurementReport>;
50
- export { formatResolutionRows } from "#sdk/cells";
23
+ export declare function measureZoningCellResolutions(options: MeasureResolutionsOptions): Promise<ResolutionMeasurementReport<CellIndexMeasurement>>;
51
24
  //# sourceMappingURL=measure-resolutions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"measure-resolutions.d.ts","sourceRoot":"","sources":["../../lib/sdk/measure-resolutions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AAG1E,OAAO,EAAyC,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAC7F,OAAO,EAAgD,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAE1G,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB,EAAE,4BAA4B;IACnG;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,MAAM,WAAW,2BAA2B;IAC3C,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAA;IAC5B,YAAY,EAAE,oBAAoB,EAAE,CAAA;CACpC;AAID;;;;;GAKG;AACH,wBAAsB,4BAA4B,CACjD,OAAO,EAAE,yBAAyB,GAChC,OAAO,CAAC,2BAA2B,CAAC,CAwCtC;AAED,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"measure-resolutions.d.ts","sourceRoot":"","sources":["../../sdk/measure-resolutions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAA;AAGvG,OAAO,EAAyC,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAC7F,OAAO,EAAgD,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEpG,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB,EAAE,4BAA4B;IACnG;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CACzB;AAID;;;;GAIG;AACH,wBAAsB,4BAA4B,CACjD,OAAO,EAAE,yBAAyB,GAChC,OAAO,CAAC,2BAA2B,CAAC,oBAAoB,CAAC,CAAC,CAwC5D"}
@@ -3,33 +3,16 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The index resolution is a MEASUREMENT this layer takes, not a number argued to — and for this subject the
7
- * inherited size contract's own statistic is not the one that decides it.
8
- *
9
- * THE `partial` SHARE CARRIES NO SIGNAL HERE, AND THAT WAS MEASURED. Computed over all 85,330 Irish
10
- * features, the median zoning polygon is 4,497 m² against an average res-9 cell of 105,333 m²: 95.7% of
11
- * them are smaller than a res-9 cell, 75.1% smaller than a res-10 cell and 34.5% smaller than a res-11 one.
12
- * So the `partial` share sits near 100% at every candidate and cannot choose between them.
13
- *
14
- * TWO NUMBERS CAN. CANDIDATES PER CELL is what a probe pays — a cell naming eight polygons is eight
15
- * bounding-box tests and up to eight ray casts — and the POLYFILL-ONLY ZERO-CELL COUNT is how many features
16
- * the obvious index would have dropped, each of which would read downstream as an absence of zoning. Both
17
- * are reported per resolution and the `partial` share rides beside them.
18
- *
19
- * ONE STREAM, EVERY RESOLUTION. Re-reading the export per candidate costs a full pass each and buys
20
- * nothing — the classification is per feature, so every candidate index folds the same feature in turn. The
21
- * cost is memory: each resolution holds its own cell sets, and the finest candidate dominates. A caller that
22
- * runs out of headroom runs the candidates in separate invocations.
6
+ * The `partial` share cannot choose between candidate resolutions, so each is reported by candidates per cell and by the polyfill-only zero-cell count.
23
7
  */
24
8
  import { classifyFeatureCells } from "@mailwoman/spatial";
25
9
  import { polyfillFindsNothing, ZoningCellIndex } from "#sdk/cells";
26
- import { readZoningFeatures, readZoningSourceIdentity } from "#sdk/ingest/index";
10
+ import { readZoningFeatures, readZoningSourceIdentity } from "#sdk/ingest";
27
11
  const DEFAULT_PROGRESS_EVERY = 5000;
28
12
  /**
29
13
  * Measure every candidate resolution over the real source.
30
14
  *
31
- * @throws {Error} When the streamed feature count does not match the count the source declares. A short read produces a
32
- * well-formed table describing a smaller country, which is the partial result that must throw.
15
+ * @throws {Error} When the streamed feature count does not match the count the source declares.
33
16
  */
34
17
  export async function measureZoningCellResolutions(options) {
35
18
  const identity = await readZoningSourceIdentity(options);
@@ -49,8 +32,8 @@ export async function measureZoningCellResolutions(options) {
49
32
  options.onProgress?.(`${features.toLocaleString()} features classified`);
50
33
  }
51
34
  }
52
- // A RANGE or an authority selector narrows the population on purpose, so the declared total is only a check on a whole
53
- // pass. Narrowed runs report what they read and assert nothing about it.
35
+ // A range or authority selector narrows the population on purpose,
36
+ // so the declared total is only checked on a whole pass.
54
37
  const narrowed = options.limit !== undefined || options.authorityCode !== undefined || options.objectIDFrom !== undefined;
55
38
  if (!narrowed && features !== identity.featureCount) {
56
39
  throw new Error(`zoning measure: streamed ${features} features, the source declares ${identity.featureCount} — a short read reports a smaller country rather than failing`);
@@ -61,5 +44,4 @@ export async function measureZoningCellResolutions(options) {
61
44
  measurements: indexes.map((index) => index.finish()),
62
45
  };
63
46
  }
64
- export { formatResolutionRows } from "#sdk/cells";
65
47
  //# sourceMapp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AK,CACd,4BAA4B,QAAQ,kCAAkC,QAAQ,CAAC,YAAY,+DAA+D,CAC1J,CAAA;IACF,CAAC;IAED,OAAO;QACN,QAAQ;QACR,oBAAoB,EAAE,QAAQ,CAAC,YAAY;QAC3C,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;KACpD,CAAA;AACF,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `@mailwoman/zoning/test-kit` provides hand-built geometry for fixture tests.
7
+ * It includes zones in two plans over the same ground. It includes a zone with a service-encoded hole.
8
+ * It includes a zone smaller than a cell and a zone the authority states as unzoned.
9
+ *
10
+ * Under this service a clockwise ring is the exterior and a counter-clockwise one is a hole, the inverse of the GeoJSON convention and of every sibling fixture.
11
+ */
12
+ import { rectangleRing as counterClockwiseRing, reversedRing as clockwiseRing, type MultiPolygonRings } from "@mailwoman/spatial";
13
+ import type { ZoningFeatureSource, ZoningSourceFeature } from "#sdk/ingest";
14
+ /**
15
+ * The exterior ring builder under this service's convention.
16
+ */
17
+ export declare const exteriorRing: typeof clockwiseRing;
18
+ /**
19
+ * The hole ring builder under this service's convention.
20
+ */
21
+ export declare const holeRing: typeof counterClockwiseRing;
22
+ /**
23
+ * South-west corner of the fixture world, in the Irish Sea east of Dublin.
24
+ */
25
+ export declare const FIXTURE_ORIGIN: {
26
+ readonly lon: -5.99;
27
+ readonly lat: 53.3;
28
+ };
29
+ /**
30
+ * Side of a fixture zone in degrees.
31
+ */
32
+ export declare const FIXTURE_SIDE = 0.01;
33
+ /**
34
+ * The fixture authority's code and name.
35
+ */
36
+ export declare const FIXTURE_AUTHORITY: {
37
+ readonly code: "Fx";
38
+ readonly name: "Fixture County Council";
39
+ };
40
+ /**
41
+ * The two plans the fixture set uses, shaped like the real product's, with dates
42
+ * preserved as published in the source's own RFC 1123 form.
43
+ */
44
+ export declare const FIXTURE_PLANS: {
45
+ readonly development: {
46
+ readonly id: "FX-DP-2024";
47
+ readonly name: "Fixture County Development Plan 2024-2030";
48
+ readonly level: "DP";
49
+ readonly from: "Mon, 01 Jan 2024 00:00:00 GMT";
50
+ readonly to: "Sun, 31 Dec 2030 00:00:00 GMT";
51
+ };
52
+ readonly localArea: {
53
+ readonly id: "FX-LAP-2022";
54
+ readonly name: "Fixture Town Local Area Plan 2022-2028";
55
+ readonly level: "LAP";
56
+ readonly from: "Sat, 01 Jan 2022 00:00:00 GMT";
57
+ readonly to: "Sun, 31 Dec 2028 00:00:00 GMT";
58
+ };
59
+ };
60
+ /**
61
+ * One fixture feature, with its rings resolved the way the real ingest resolves them.
62
+ */
63
+ export declare function fixtureFeature(objectID: number, polygons: MultiPolygonRings, overrides?: Partial<Omit<ZoningSourceFeature, "rings">>): ZoningSourceFeature;
64
+ /**
65
+ * The fixture set has two adjacent zones and one with a service-encoded hole.
66
+ *
67
+ * It has a second plan over the same ground.
68
+ * It has a zone smaller than a cell and a zone the authority states as unzoned.
69
+ */
70
+ export declare function fixtureFeatures(): ZoningSourceFeature[];
71
+ /**
72
+ * A feature source over an explicit feature list.
73
+ */
74
+ export declare function fixtureSource(features: ZoningSourceFeature[]): ZoningFeatureSource;
75
+ //# sourceMappingURL=test-kit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-kit.d.ts","sourceRoot":"","sources":["../../sdk/test-kit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACN,aAAa,IAAI,oBAAoB,EACrC,YAAY,IAAI,aAAa,EAC7B,KAAK,iBAAiB,EACtB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAG3E;;GAEG;AACH,eAAO,MAAM,YAAY,sBAAgB,CAAA;AAEzC;;GAEG;AACH,eAAO,MAAM,QAAQ,6BAAuB,CAAA;AAE5C;;GAEG;AACH,eAAO,MAAM,cAAc;aAAK,GAAG,EAAE,CAAC,IAAI;aAAE,GAAG,EAAE,IAAI;CAAW,CAAA;AAEhE;;GAEG;AACH,eAAO,MAAM,YAAY,OAAO,CAAA;AAEhC;;GAEG;AACH,eAAO,MAAM,iBAAiB;aAAK,IAAI,EAAE,IAAI;aAAE,IAAI,EAAE,wBAAwB;CAAW,CAAA;AAExF;;;GAGG;AACH,eAAO,MAAM,aAAa;aACzB,WAAW;iBACV,EAAE,EAAE,YAAY;iBAChB,IAAI,EAAE,2CAA2C;iBACjD,KAAK,EAAE,IAAI;iBACX,IAAI,EAAE,+BAA+B;iBACrC,EAAE,EAAE,+BAA+B;;aAEpC,SAAS;iBACR,EAAE,EAAE,aAAa;iBACjB,IAAI,EAAE,wCAAwC;iBAC9C,KAAK,EAAE,KAAK;iBACZ,IAAI,EAAE,+BAA+B;iBACrC,EAAE,EAAE,+BAA+B;;CAE3B,CAAA;AAEV;;GAEG;AACH,wBAAgB,cAAc,CAC7B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,GAAE,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAM,GACzD,mBAAmB,CAuBrB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,mBAAmB,EAAE,CAmEvD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,mBAAmB,EAAE,GAAG,mBAAmB,CASlF"}
@@ -3,37 +3,21 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * `@mailwoman/zoning/test-kit` — hand-built geometry for the fixture rung: zones in two plans over the same
7
- * ground, one with a hole encoded the way this service encodes them, one smaller than a cell, and one the
8
- * authority states as UNZONED.
6
+ * `@mailwoman/zoning/test-kit` provides hand-built geometry for fixture tests.
7
+ * It includes zones in two plans over the same ground. It includes a zone with a service-encoded hole.
8
+ * It includes a zone smaller than a cell and a zone the authority states as unzoned.
9
9
  *
10
- * A PACKAGE SUBPATH RATHER THAN A `test/` FILE, for the same reason `packages/mailwoman/lib/test-kit` is one:
11
- * the observation route's suite lives in another workspace, and a relative import across two TypeScript
12
- * projects is refused outright (`TS2878`) because the compiled layout would not match the source layout.
13
- *
14
- * NO NETWORK AND NO GDAL. The builder takes a {@linkcode ZoningFeatureSource}, so a fixture is a list of
15
- * features — which is what lets this rung exercise the ring-role resolution, the vocabulary census, the cell
16
- * classification, the coverage rows, the manifest and the seal on every machine rather than only the ones
17
- * with ogr2ogr.
18
- *
19
- * THE EXTERIOR RING IS THE CLOCKWISE ONE, WHICH IS THE INVERSE OF THE GEOJSON CONVENTION AND OF EVERY
20
- * SIBLING FIXTURE. `@mailwoman/spatial`'s `rectangleRing` winds counter-clockwise and its `reversedRing`
21
- * clockwise, so this file aliases them the other way round from the flood and coastal test kits: under this
22
- * service a clockwise ring is the EXTERIOR and a counter-clockwise one is a HOLE. A fixture that used the
23
- * sibling naming would build geometry the ingest reads inside-out, and every assertion on it would pass.
24
- *
25
- * THE COORDINATES ARE IN THE IRISH SEA east of Dublin — inside the Department's declared extent, so a
26
- * fixture stays in the coordinate space the product occupies, and clear of every real zoning polygon.
10
+ * Under this service a clockwise ring is the exterior and a counter-clockwise one is a hole, the inverse of the GeoJSON convention and of every sibling fixture.
27
11
  */
28
12
  import { rectangleRing as counterClockwiseRing, reversedRing as clockwiseRing, } from "@mailwoman/spatial";
29
13
  import { resolveRingRoles } from "#rings";
30
14
  import { GZT_SOURCE_EPSG, GZT_UNZONED_LOCAL_CODE } from "#vocabulary";
31
15
  /**
32
- * The exterior ring builder, under THIS service's convention. Clockwise.
16
+ * The exterior ring builder under this service's convention.
33
17
  */
34
18
  export const exteriorRing = clockwiseRing;
35
19
  /**
36
- * The hole ring builder, under THIS service's convention. Counter-clockwise.
20
+ * The hole ring builder under this service's convention.
37
21
  */
38
22
  export const holeRing = counterClockwiseRing;
39
23
  /**
@@ -41,20 +25,16 @@ export const holeRing = counterClockwiseRing;
41
25
  */
42
26
  export const FIXTURE_ORIGIN = { lon: -5.99, lat: 53.3 };
43
27
  /**
44
- * Side of a fixture zone, in degrees. About 1.1 km at this latitude — several res-10 cells across, so a zone has a real
45
- * interior AND a real fringe.
28
+ * Side of a fixture zone in degrees.
46
29
  */
47
30
  export const FIXTURE_SIDE = 0.01;
48
31
  /**
49
- * The fixture authority and its two plans.
32
+ * The fixture authority's code and name.
50
33
  */
51
34
  export const FIXTURE_AUTHORITY = { code: "Fx", name: "Fixture County Council" };
52
35
  /**
53
- * The two plans the fixture set uses, shaped like the real product's: a Development Plan and a Local Area Plan, each
54
- * with its own stated window, both able to zone the same ground.
55
- *
56
- * The dates are in the source's own RFC 1123 form, because that is what the export publishes and this layer carries
57
- * them as published rather than re-formatting them.
36
+ * The two plans the fixture set uses, shaped like the real product's, with dates
37
+ * preserved as published in the source's own RFC 1123 form.
58
38
  */
59
39
  export const FIXTURE_PLANS = {
60
40
  development: {
@@ -94,32 +74,30 @@ export function fixtureFeature(objectID, polygons, overrides = {}) {
94
74
  crosswalkDescription: "Existing residential",
95
75
  crosswalkRollup: "RE",
96
76
  ...overrides,
97
- // RESOLVED THROUGH THE REAL RESOLVER, never hand-assembled: a fixture that nested its own holes would test the
98
- // assertion rather than the resolution, and the resolution is the part of this layer no sibling already has.
77
+ // Resolved through the real resolver rather than hand-assembled.
99
78
  rings: resolveRingRoles(polygons, String(objectID)),
100
79
  };
101
80
  }
102
81
  /**
103
- * The fixture set: two adjacent zones, one of them holed the way this service encodes holes; a second plan over the
104
- * SAME ground as the first; a zone smaller than a cell; and a zone the authority states as unzoned.
82
+ * The fixture set has two adjacent zones and one with a service-encoded hole.
105
83
  *
106
- * THE OVERLAP BETWEEN PLANS IS THE POINT. A point inside the first zone must answer with BOTH rows, each naming its own
107
- * plan — which is what proves a plan is part of the claim rather than a parameter of it.
84
+ * It has a second plan over the same ground.
85
+ * It has a zone smaller than a cell and a zone the authority states as unzoned.
108
86
  */
109
87
  export function fixtureFeatures() {
110
88
  const { lon, lat } = FIXTURE_ORIGIN;
111
89
  const zoneA = exteriorRing(lon, lat, lon + FIXTURE_SIDE, lat + FIXTURE_SIDE);
112
90
  const zoneB = exteriorRing(lon + FIXTURE_SIDE, lat, lon + 2 * FIXTURE_SIDE, lat + FIXTURE_SIDE);
113
- // THE HOLE IS A SEPARATE PART, not a nested ring — which is how the real service encodes it on the features that carry
114
- // one, and the encoding a nesting-aware reader turns into a second zoned area.
91
+ // The real service encodes the hole as a separate part.
92
+ // It does not nest the hole ring.
115
93
  const holed = [
116
94
  [exteriorRing(lon, lat + 2 * FIXTURE_SIDE, lon + FIXTURE_SIDE, lat + 3 * FIXTURE_SIDE)],
117
95
  [
118
96
  holeRing(lon + FIXTURE_SIDE * 0.35, lat + 2 * FIXTURE_SIDE + FIXTURE_SIDE * 0.35, lon + FIXTURE_SIDE * 0.65, lat + 2 * FIXTURE_SIDE + FIXTURE_SIDE * 0.65),
119
97
  ],
120
98
  ];
121
- // About 5.5 m across — smaller than a res-11 cell, let alone a res-9 one. `polygonToCells` returns nothing for a shape
122
- // this size, so it is the fixture that proves the index takes cell-touches-polygon rather than centre-in-polygon.
99
+ // Smaller than a res-11 cell, so `polygonToCells` returns no cell and the index must
100
+ // cover it by cell-touches-polygon rather than center-in-polygon.
123
101
  const sliver = exteriorRing(lon + 3 * FIXTURE_SIDE, lat, lon + 3 * FIXTURE_SIDE + 0.00005, lat + 0.00005);
124
102
  const unzoned = exteriorRing(lon + 4 * FIXTURE_SIDE, lat, lon + 5 * FIXTURE_SIDE, lat + FIXTURE_SIDE);
125
103
  const localAreaPlan = FIXTURE_PLANS.localArea;
@@ -143,7 +121,7 @@ export function fixtureFeatures() {
143
121
  crosswalkCode: "N1.1",
144
122
  crosswalkDescription: "Road",
145
123
  }),
146
- // The authority states unzoned land POSITIVELY, and uses a code its own domain never declares for it.
124
+ // The authority marks land as unzoned with a code its own domain does not declare.
147
125
  fixtureFeature(5, [[unzoned]], {
148
126
  localCode: GZT_UNZONED_LOCAL_CODE,
149
127
  localDescription: "Unzoned",
@@ -151,8 +129,7 @@ export function fixtureFeatures() {
151
129
  crosswalkDescription: null,
152
130
  crosswalkRollup: "N/A",
153
131
  }),
154
- // The SAME ground as zone A under a second plan, and the same local code mapped to a DIFFERENT generic type — which
155
- // is the shape that makes the crosswalk non-functional over an (authority, code) pair.
132
+ // The same ground as zone A under a second plan, with the same local code mapped to a different generic type.
156
133
  fixtureFeature(6, [[zoneA]], {
157
134
  planID: localAreaPlan.id,
158
135
  planName: localAreaPlan.name,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-kit.js","sourceRoot":"","sources":["../../sdk/test-kit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACN,aAAa,IAAI,oBAAoB,EACrC,YAAY,IAAI,aAAa,GAE7B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAEzC,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAErE;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAA;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,oBAAoB,CAAA;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAW,CAAA;AAEhE;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAA;AAEhC;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,wBAAwB,EAAW,CAAA;AAExF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,WAAW,EAAE;QACZ,EAAE,EAAE,YAAY;QAChB,IAA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