@mailwoman/tiger 5.9.0 → 5.10.1
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/block-group.ts +4 -4
- package/class-code.ts +168 -166
- package/constants.ts +35 -28
- package/county-subdivision.ts +4 -4
- package/county.ts +4 -4
- package/files.ts +41 -32
- package/functional-status.ts +16 -14
- package/geoid.ts +13 -11
- package/index.ts +12 -12
- package/legal-statistical-area.ts +140 -137
- package/out/block-group.d.ts +4 -4
- package/out/class-code.d.ts +167 -166
- package/out/class-code.d.ts.map +1 -1
- package/out/class-code.js +166 -167
- package/out/class-code.js.map +1 -1
- package/out/constants.d.ts +31 -28
- package/out/constants.d.ts.map +1 -1
- package/out/constants.js +23 -26
- package/out/constants.js.map +1 -1
- package/out/county-subdivision.d.ts +4 -4
- package/out/county.d.ts +4 -4
- package/out/files.d.ts +35 -33
- package/out/files.d.ts.map +1 -1
- package/out/files.js +19 -21
- package/out/files.js.map +1 -1
- package/out/functional-status.d.ts +15 -14
- package/out/functional-status.d.ts.map +1 -1
- package/out/functional-status.js +14 -15
- package/out/functional-status.js.map +1 -1
- package/out/geoid.d.ts +20 -19
- package/out/geoid.d.ts.map +1 -1
- package/out/geoid.js +10 -11
- package/out/geoid.js.map +1 -1
- package/out/index.d.ts +12 -12
- package/out/legal-statistical-area.d.ts +138 -137
- package/out/legal-statistical-area.d.ts.map +1 -1
- package/out/legal-statistical-area.js +137 -138
- package/out/legal-statistical-area.js.map +1 -1
- package/out/sdk/index.d.ts +4 -4
- package/out/sdk/state/TIGERTabulatedBlockEntity.d.ts +1 -2
- package/out/sdk/state/TIGERTabulatedBlockEntity.d.ts.map +1 -1
- package/out/sdk/state/index.d.ts +3 -3
- package/out/state.d.ts +302 -297
- package/out/state.d.ts.map +1 -1
- package/out/state.js +181 -186
- package/out/state.js.map +1 -1
- package/out/tabulation-block.d.ts +3 -3
- package/out/tabulation-block.d.ts.map +1 -1
- package/out/tools/index.d.ts +15 -0
- package/out/tools/index.d.ts.map +1 -0
- package/out/tools/index.js +15 -0
- package/out/tools/index.js.map +1 -0
- package/out/tools/race-dots-map.d.ts +29 -5
- package/out/tools/race-dots-map.d.ts.map +1 -1
- package/out/tools/race-dots-map.js +53 -64
- package/out/tools/race-dots-map.js.map +1 -1
- package/out/tools/race-dots.d.ts +27 -7
- package/out/tools/race-dots.d.ts.map +1 -1
- package/out/tools/race-dots.js +85 -89
- package/out/tools/race-dots.js.map +1 -1
- package/out/tools/serve-range.d.ts +23 -4
- package/out/tools/serve-range.d.ts.map +1 -1
- package/out/tools/serve-range.js +47 -36
- package/out/tools/serve-range.js.map +1 -1
- package/out/tract.d.ts +3 -3
- package/out/tract.d.ts.map +1 -1
- package/out/tsconfig.tsbuildinfo +1 -1
- package/package.json +31 -6
- package/sdk/fetch.ts +2 -2
- package/sdk/index.ts +4 -4
- package/sdk/redistricting.ts +2 -2
- package/sdk/state/index.ts +3 -3
- package/state.ts +193 -183
- package/tabulation-block.ts +20 -20
- package/tools/index.ts +15 -0
- package/tools/race-dots-map.ts +79 -70
- package/tools/race-dots.ts +127 -104
- package/tools/serve-range.ts +69 -38
- package/tract.ts +12 -12
- package/tsconfig.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA"}
|
|
@@ -8,12 +8,36 @@
|
|
|
8
8
|
* inlined here, à la `registry/map-html.ts`) under a circle layer of the dots, colored by race
|
|
9
9
|
* category. The dots PMTiles is read client-side via the `pmtiles` protocol.
|
|
10
10
|
*
|
|
11
|
-
* Each dot is one of
|
|
11
|
+
* Each dot is one of `per` people of a category, placed at random inside its Census block — a
|
|
12
12
|
* representation, not a record about any address. Serve over localhost (the house tile server
|
|
13
|
-
* CORS-restricts to localhost + the docs domains)
|
|
13
|
+
* CORS-restricts to localhost + the docs domains) — `mailwoman tiger race-dots-map --serve` wires
|
|
14
|
+
* {@linkcode serveWithRangeSupport} for exactly this.
|
|
14
15
|
*
|
|
15
|
-
* Run:
|
|
16
|
-
*
|
|
16
|
+
* Run: `mailwoman tiger race-dots-map --pmtiles-url
|
|
17
|
+
* http://localhost:8899/race-dots-oc.pmtiles --out /tmp/race-dots-oc.html`
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
/** Options for {@linkcode raceDotsMap}. */
|
|
20
|
+
export interface RaceDotsMapOptions {
|
|
21
|
+
/** Dots tileset URL the page reads client-side. Default `http://localhost:8899/race-dots-oc.pmtiles`. */
|
|
22
|
+
pmtilesURL?: string;
|
|
23
|
+
/** Output HTML path. Default `/tmp/race-dots-oc.html`. */
|
|
24
|
+
out?: string;
|
|
25
|
+
/** People represented by one dot (title/legend copy only). Default 5. */
|
|
26
|
+
per?: number;
|
|
27
|
+
/** Page title. Default derives from `per`. */
|
|
28
|
+
title?: string;
|
|
29
|
+
/** Initial map center longitude. Default -117.83 (Orange County, CA). */
|
|
30
|
+
lng?: number;
|
|
31
|
+
/** Initial map center latitude. Default 33.68. */
|
|
32
|
+
lat?: number;
|
|
33
|
+
/** Initial map zoom. Default 9.4. */
|
|
34
|
+
zoom?: number;
|
|
35
|
+
}
|
|
36
|
+
/** Result of {@linkcode raceDotsMap}. */
|
|
37
|
+
export interface RaceDotsMapResult {
|
|
38
|
+
outPath: string;
|
|
39
|
+
pmtilesURL: string;
|
|
40
|
+
}
|
|
41
|
+
/** Race-dots MapLibre page writer — see the module doc. */
|
|
42
|
+
export declare function raceDotsMap(options?: RaceDotsMapOptions, report?: (line: string) => void): Promise<RaceDotsMapResult>;
|
|
19
43
|
//# sourceMappingURL=race-dots-map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"race-dots-map.d.ts","sourceRoot":"","sources":["../../tools/race-dots-map.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"race-dots-map.d.ts","sourceRoot":"","sources":["../../tools/race-dots-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IAClC,yGAAyG;IACzG,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,yEAAyE;IACzE,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,yEAAyE;IACzE,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,kDAAkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAA;CACb;AAED,yCAAyC;AACzC,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;CAClB;AAkCD,2DAA2D;AAC3D,wBAAsB,WAAW,CAChC,OAAO,GAAE,kBAAuB,EAChC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,iBAAiB,CAAC,CA6F5B"}
|
|
@@ -8,40 +8,15 @@
|
|
|
8
8
|
* inlined here, à la `registry/map-html.ts`) under a circle layer of the dots, colored by race
|
|
9
9
|
* category. The dots PMTiles is read client-side via the `pmtiles` protocol.
|
|
10
10
|
*
|
|
11
|
-
* Each dot is one of
|
|
11
|
+
* Each dot is one of `per` people of a category, placed at random inside its Census block — a
|
|
12
12
|
* representation, not a record about any address. Serve over localhost (the house tile server
|
|
13
|
-
* CORS-restricts to localhost + the docs domains)
|
|
13
|
+
* CORS-restricts to localhost + the docs domains) — `mailwoman tiger race-dots-map --serve` wires
|
|
14
|
+
* {@linkcode serveWithRangeSupport} for exactly this.
|
|
14
15
|
*
|
|
15
|
-
* Run:
|
|
16
|
-
*
|
|
16
|
+
* Run: `mailwoman tiger race-dots-map --pmtiles-url
|
|
17
|
+
* http://localhost:8899/race-dots-oc.pmtiles --out /tmp/race-dots-oc.html`
|
|
17
18
|
*/
|
|
18
19
|
import { writeFileSync } from "node:fs";
|
|
19
|
-
import { parseArgs } from "node:util";
|
|
20
|
-
import { layers, namedFlavor } from "@protomaps/basemaps";
|
|
21
|
-
// Loose scan parity with the retired local argv helpers: unknown flags tolerated.
|
|
22
|
-
const { values: rawValues } = parseArgs({
|
|
23
|
-
options: {
|
|
24
|
-
lat: { type: "string" },
|
|
25
|
-
lng: { type: "string" },
|
|
26
|
-
out: { type: "string" },
|
|
27
|
-
per: { type: "string" },
|
|
28
|
-
"pmtiles-url": { type: "string" },
|
|
29
|
-
title: { type: "string" },
|
|
30
|
-
zoom: { type: "string" },
|
|
31
|
-
},
|
|
32
|
-
strict: false,
|
|
33
|
-
allowPositionals: true,
|
|
34
|
-
});
|
|
35
|
-
// Typed view: strict:false loosens TS inference, but declared options always parse to their schema type.
|
|
36
|
-
const values = rawValues;
|
|
37
|
-
const PMTILES_URL = values["pmtiles-url"] || "http://localhost:8899/race-dots-oc.pmtiles";
|
|
38
|
-
const OUT = values["out"] || "/tmp/race-dots-oc.html";
|
|
39
|
-
const PER = Number(values["per"] || "5");
|
|
40
|
-
const PER_PHRASE = PER === 1 ? "one dot is one person" : `one dot ≈ ${PER} people`;
|
|
41
|
-
const TITLE = values["title"] || `Race in Orange County, CA — ${PER_PHRASE} (2020 Census)`;
|
|
42
|
-
const CENTER_LNG = Number(values["lng"] || "-117.83");
|
|
43
|
-
const CENTER_LAT = Number(values["lat"] || "33.68");
|
|
44
|
-
const ZOOM = Number(values["zoom"] || "9.4");
|
|
45
20
|
const MAPLIBRE_VERSION = "5.24.0";
|
|
46
21
|
const MAPLIBRE_JS_SRI = "sha384-5+cfbwT0iiub6VsQAdn6yz16nr6sDiQoHx6tm4O8OVYXHYOxcffFmCJBL0dgdvGp";
|
|
47
22
|
const MAPLIBRE_CSS_SRI = "sha384-uTttxo/aOKbdE5RlD/SPzSDoDmNvGlUYPjONi2MN/b7c9HPSvW07OIuyP7uL6jxK";
|
|
@@ -71,39 +46,51 @@ const CATEGORY_LABEL = {
|
|
|
71
46
|
other: "Other (non-Hispanic)",
|
|
72
47
|
multi: "Two or more races",
|
|
73
48
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
},
|
|
49
|
+
/** Race-dots MapLibre page writer — see the module doc. */
|
|
50
|
+
export async function raceDotsMap(options = {}, report) {
|
|
51
|
+
const PMTILES_URL = options.pmtilesURL || "http://localhost:8899/race-dots-oc.pmtiles";
|
|
52
|
+
const OUT = options.out || "/tmp/race-dots-oc.html";
|
|
53
|
+
const PER = options.per ?? 5;
|
|
54
|
+
const PER_PHRASE = PER === 1 ? "one dot is one person" : `one dot ≈ ${PER} people`;
|
|
55
|
+
const TITLE = options.title || `Race in Orange County, CA — ${PER_PHRASE} (2020 Census)`;
|
|
56
|
+
const CENTER_LNG = options.lng ?? -117.83;
|
|
57
|
+
const CENTER_LAT = options.lat ?? 33.68;
|
|
58
|
+
const ZOOM = options.zoom ?? 9.4;
|
|
59
|
+
// Heavy dep (devDependency — operator tooling), lazy-imported so loading the tools barrel stays cheap.
|
|
60
|
+
const { layers, namedFlavor } = await import("@protomaps/basemaps");
|
|
61
|
+
const colorMatch = ["match", ["get", "cat"]];
|
|
62
|
+
for (const [cat, color] of Object.entries(CATEGORY_COLOR)) {
|
|
63
|
+
colorMatch.push(cat, color);
|
|
64
|
+
}
|
|
65
|
+
colorMatch.push("#9e9e9e");
|
|
66
|
+
const style = {
|
|
67
|
+
version: 8,
|
|
68
|
+
glyphs: GLYPHS_URL,
|
|
69
|
+
sprite: SPRITE_URL,
|
|
70
|
+
sources: {
|
|
71
|
+
[BASEMAP_SOURCE_ID]: { type: "vector", url: BASEMAP_TILEJSON_URL },
|
|
72
|
+
dots: { type: "vector", url: "pmtiles://" + PMTILES_URL },
|
|
99
73
|
},
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
74
|
+
layers: [
|
|
75
|
+
...layers(BASEMAP_SOURCE_ID, namedFlavor("light"), { lang: "en" }),
|
|
76
|
+
{
|
|
77
|
+
id: "race-dots",
|
|
78
|
+
type: "circle",
|
|
79
|
+
source: "dots",
|
|
80
|
+
"source-layer": "dots",
|
|
81
|
+
paint: {
|
|
82
|
+
"circle-radius": ["interpolate", ["linear"], ["zoom"], 4, 0.7, 9, 1.7, 12, 2.8, 16, 4.5],
|
|
83
|
+
"circle-color": colorMatch,
|
|
84
|
+
"circle-opacity": 0.85,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
};
|
|
89
|
+
const legendRows = Object.keys(CATEGORY_COLOR)
|
|
90
|
+
.map((c) => `<div><i style="background:${CATEGORY_COLOR[c]}"></i>${CATEGORY_LABEL[c]}</div>`)
|
|
91
|
+
.join("");
|
|
92
|
+
// The client script avoids template literals / `${` so it survives this outer template verbatim.
|
|
93
|
+
const html = `<!doctype html>
|
|
107
94
|
<html lang="en">
|
|
108
95
|
<head>
|
|
109
96
|
<meta charset="utf-8" />
|
|
@@ -142,6 +129,8 @@ const html = `<!doctype html>
|
|
|
142
129
|
</body>
|
|
143
130
|
</html>
|
|
144
131
|
`;
|
|
145
|
-
writeFileSync(OUT, html);
|
|
146
|
-
|
|
132
|
+
writeFileSync(OUT, html);
|
|
133
|
+
report?.(`[written] ${OUT} (pmtiles: ${PMTILES_URL})`);
|
|
134
|
+
return { outPath: OUT, pmtilesURL: PMTILES_URL };
|
|
135
|
+
}
|
|
147
136
|
//# sourceMappingURL=race-dots-map.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"race-dots-map.js","sourceRoot":"","sources":["../../tools/race-dots-map.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"race-dots-map.js","sourceRoot":"","sources":["../../tools/race-dots-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AA0BvC,MAAM,gBAAgB,GAAG,QAAQ,CAAA;AACjC,MAAM,eAAe,GAAG,yEAAyE,CAAA;AACjG,MAAM,gBAAgB,GAAG,yEAAyE,CAAA;AAClG,MAAM,eAAe,GAAG,OAAO,CAAA;AAE/B,MAAM,iBAAiB,GAAG,YAAY,CAAA;AACtC,MAAM,oBAAoB,GAAG,+CAA+C,CAAA;AAC5E,MAAM,UAAU,GAAG,2EAA2E,CAAA;AAC9F,MAAM,UAAU,GAAG,8DAA8D,CAAA;AAEjF,qEAAqE;AACrE,MAAM,cAAc,GAA2B;IAC9C,KAAK,EAAE,SAAS,EAAE,OAAO;IACzB,KAAK,EAAE,SAAS,EAAE,QAAQ;IAC1B,QAAQ,EAAE,SAAS,EAAE,SAAS;IAC9B,KAAK,EAAE,SAAS,EAAE,MAAM;IACxB,IAAI,EAAE,SAAS,EAAE,SAAS;IAC1B,IAAI,EAAE,SAAS,EAAE,OAAO;IACxB,KAAK,EAAE,SAAS,EAAE,QAAQ;IAC1B,KAAK,EAAE,SAAS,EAAE,OAAO;CACzB,CAAA;AACD,MAAM,cAAc,GAA2B;IAC9C,KAAK,EAAE,sBAAsB;IAC7B,KAAK,EAAE,sBAAsB;IAC7B,QAAQ,EAAE,oBAAoB;IAC9B,KAAK,EAAE,sBAAsB;IAC7B,IAAI,EAAE,iBAAiB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S,CAAC,KAAK,CAAC;aACnB,UAAU,KAAK,UAAU;UAC5B,IAAI;;;;;;;CAOb,CAAA;IAEA,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACxB,MAAM,EAAE,CAAC,aAAa,GAAG,eAAe,WAAW,GAAG,CAAC,CAAA;IAEvD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,CAAA;AACjD,CAAC"}
|
package/out/tools/race-dots.d.ts
CHANGED
|
@@ -7,19 +7,39 @@
|
|
|
7
7
|
* `mailwoman tiger` CLI produces.
|
|
8
8
|
*
|
|
9
9
|
* Reads `tabblock20 ⋈ pl_block` (block geometry + Census 2020 P.L. 94-171 table P2 counts) and
|
|
10
|
-
* scatters one dot per
|
|
10
|
+
* scatters one dot per `per` people uniformly at random inside each block, tagged with its
|
|
11
11
|
* race/ethnicity category. Output is NDJSON (one GeoJSON Point Feature per line, with a
|
|
12
12
|
* `tippecanoe` layer hint) ready for `tippecanoe -o race-dots.pmtiles`.
|
|
13
13
|
*
|
|
14
14
|
* Point-in-polygon uses `@turf/boolean-contains` (ships with `@mailwoman/tiger`). The dot is a
|
|
15
15
|
* _representation_, not a record: a random position inside the block it belongs to, standing in
|
|
16
|
-
* for
|
|
16
|
+
* for `per` real people of that category. It says nothing about any individual address.
|
|
17
17
|
*
|
|
18
|
-
* Build the input DB first: mailwoman tiger fetch --state 06 --county 059 --out tiger-oc.db
|
|
19
|
-
* mailwoman tiger redistricting --state 06 --county 059 --out tiger-oc.db
|
|
18
|
+
* Build the input DB first: `mailwoman tiger fetch --state 06 --county 059 --out tiger-oc.db` then
|
|
19
|
+
* `mailwoman tiger redistricting --state 06 --county 059 --out tiger-oc.db`.
|
|
20
20
|
*
|
|
21
|
-
* Run:
|
|
22
|
-
* --db tiger-oc.db --per 10 --out /tmp/race-dots.ndjson
|
|
21
|
+
* Run: `mailwoman tiger race-dots --db tiger-oc.db --per 10 --out /tmp/race-dots.ndjson`
|
|
23
22
|
*/
|
|
24
|
-
|
|
23
|
+
/** Options for {@linkcode raceDots}. */
|
|
24
|
+
export interface RaceDotsOptions {
|
|
25
|
+
/** TIGER SQLite DB (`tabblock20` ⋈ `pl_block`). Default `$MAILWOMAN_DATA_ROOT/tiger/tiger-oc.db`. */
|
|
26
|
+
db?: string;
|
|
27
|
+
/** Output NDJSON path. Default `/tmp/race-dots.ndjson`. */
|
|
28
|
+
out?: string;
|
|
29
|
+
/** People represented by one dot. Default 10. */
|
|
30
|
+
per?: number;
|
|
31
|
+
/** Tippecanoe layer name. Default `dots`. */
|
|
32
|
+
layer?: string;
|
|
33
|
+
}
|
|
34
|
+
/** Result of {@linkcode raceDots}. */
|
|
35
|
+
export interface RaceDotsResult {
|
|
36
|
+
outPath: string;
|
|
37
|
+
dots: number;
|
|
38
|
+
skipped: number;
|
|
39
|
+
blocks: number;
|
|
40
|
+
/** Dots emitted per P2 category. */
|
|
41
|
+
totals: Record<string, number>;
|
|
42
|
+
}
|
|
43
|
+
/** Race-by-dot-density NDJSON builder — see the module doc. */
|
|
44
|
+
export declare function raceDots(options?: RaceDotsOptions, report?: (line: string) => void): Promise<RaceDotsResult>;
|
|
25
45
|
//# sourceMappingURL=race-dots.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"race-dots.d.ts","sourceRoot":"","sources":["../../tools/race-dots.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"race-dots.d.ts","sourceRoot":"","sources":["../../tools/race-dots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC/B,qGAAqG;IACrG,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9B;AAmCD,+DAA+D;AAC/D,wBAAsB,QAAQ,CAC7B,OAAO,GAAE,eAAoB,EAC7B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,cAAc,CAAC,CA0GzB"}
|
package/out/tools/race-dots.js
CHANGED
|
@@ -7,37 +7,22 @@
|
|
|
7
7
|
* `mailwoman tiger` CLI produces.
|
|
8
8
|
*
|
|
9
9
|
* Reads `tabblock20 ⋈ pl_block` (block geometry + Census 2020 P.L. 94-171 table P2 counts) and
|
|
10
|
-
* scatters one dot per
|
|
10
|
+
* scatters one dot per `per` people uniformly at random inside each block, tagged with its
|
|
11
11
|
* race/ethnicity category. Output is NDJSON (one GeoJSON Point Feature per line, with a
|
|
12
12
|
* `tippecanoe` layer hint) ready for `tippecanoe -o race-dots.pmtiles`.
|
|
13
13
|
*
|
|
14
14
|
* Point-in-polygon uses `@turf/boolean-contains` (ships with `@mailwoman/tiger`). The dot is a
|
|
15
15
|
* _representation_, not a record: a random position inside the block it belongs to, standing in
|
|
16
|
-
* for
|
|
16
|
+
* for `per` real people of that category. It says nothing about any individual address.
|
|
17
17
|
*
|
|
18
|
-
* Build the input DB first: mailwoman tiger fetch --state 06 --county 059 --out tiger-oc.db
|
|
19
|
-
* mailwoman tiger redistricting --state 06 --county 059 --out tiger-oc.db
|
|
18
|
+
* Build the input DB first: `mailwoman tiger fetch --state 06 --county 059 --out tiger-oc.db` then
|
|
19
|
+
* `mailwoman tiger redistricting --state 06 --county 059 --out tiger-oc.db`.
|
|
20
20
|
*
|
|
21
|
-
* Run:
|
|
22
|
-
* --db tiger-oc.db --per 10 --out /tmp/race-dots.ndjson
|
|
21
|
+
* Run: `mailwoman tiger race-dots --db tiger-oc.db --per 10 --out /tmp/race-dots.ndjson`
|
|
23
22
|
*/
|
|
24
23
|
import { createWriteStream } from "node:fs";
|
|
25
24
|
import { DatabaseSync } from "node:sqlite";
|
|
26
|
-
import { parseArgs } from "node:util";
|
|
27
25
|
import { dataRootPath } from "@mailwoman/core/utils";
|
|
28
|
-
import booleanContains from "@turf/boolean-contains";
|
|
29
|
-
// Loose scan parity with the retired local argv helpers: unknown flags tolerated.
|
|
30
|
-
const { values: rawValues } = parseArgs({
|
|
31
|
-
options: { db: { type: "string" }, layer: { type: "string" }, out: { type: "string" }, per: { type: "string" } },
|
|
32
|
-
strict: false,
|
|
33
|
-
allowPositionals: true,
|
|
34
|
-
});
|
|
35
|
-
// Typed view: strict:false loosens TS inference, but declared options always parse to their schema type.
|
|
36
|
-
const values = rawValues;
|
|
37
|
-
const DB = values["db"] || dataRootPath("tiger", "tiger-oc.db");
|
|
38
|
-
const OUT = values["out"] || "/tmp/race-dots.ndjson";
|
|
39
|
-
const PER = Number(values["per"] || "10"); // people represented by one dot
|
|
40
|
-
const LAYER = values["layer"] || "dots";
|
|
41
26
|
// The eight P2 categories (columns in pl_block) that partition each block's population.
|
|
42
27
|
const CATEGORIES = ["hispanic", "white", "black", "asian", "aian", "nhpi", "other", "multi"];
|
|
43
28
|
function bbox(rings) {
|
|
@@ -58,80 +43,91 @@ function bbox(rings) {
|
|
|
58
43
|
}
|
|
59
44
|
return [minX, minY, maxX, maxY];
|
|
60
45
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const out = createWriteStream(OUT);
|
|
93
|
-
const totals = new Map();
|
|
94
|
-
let dots = 0, skipped = 0;
|
|
95
|
-
for (const row of rows) {
|
|
96
|
-
let geom;
|
|
97
|
-
try {
|
|
98
|
-
geom = JSON.parse(row.geometry);
|
|
99
|
-
}
|
|
100
|
-
catch {
|
|
101
|
-
continue;
|
|
46
|
+
/** Race-by-dot-density NDJSON builder — see the module doc. */
|
|
47
|
+
export async function raceDots(options = {}, report) {
|
|
48
|
+
const DB = options.db || dataRootPath("tiger", "tiger-oc.db");
|
|
49
|
+
const OUT = options.out || "/tmp/race-dots.ndjson";
|
|
50
|
+
const PER = options.per ?? 10; // people represented by one dot
|
|
51
|
+
const LAYER = options.layer || "dots";
|
|
52
|
+
// Heavy dep, lazy-imported so loading the tools barrel stays cheap.
|
|
53
|
+
const { default: booleanContains } = await import("@turf/boolean-contains");
|
|
54
|
+
// A block geometry is one or more polygons. Pick a sub-polygon weighted by bbox area, then
|
|
55
|
+
// rejection-sample inside it with a turf containment test (handles holes + winding correctly).
|
|
56
|
+
function randomPointIn(polys, areas, totalArea) {
|
|
57
|
+
let r = Math.random() * totalArea;
|
|
58
|
+
let pick = 0;
|
|
59
|
+
while (pick < polys.length - 1 && (r -= areas[pick]) > 0) {
|
|
60
|
+
pick++;
|
|
61
|
+
}
|
|
62
|
+
const poly = polys[pick];
|
|
63
|
+
const polyFeature = {
|
|
64
|
+
type: "Feature",
|
|
65
|
+
geometry: { type: "Polygon", coordinates: poly },
|
|
66
|
+
properties: {},
|
|
67
|
+
};
|
|
68
|
+
const [minX, minY, maxX, maxY] = bbox(poly);
|
|
69
|
+
for (let tries = 0; tries < 60; tries++) {
|
|
70
|
+
const x = minX + Math.random() * (maxX - minX);
|
|
71
|
+
const y = minY + Math.random() * (maxY - minY);
|
|
72
|
+
const pt = { type: "Feature", geometry: { type: "Point", coordinates: [x, y] }, properties: {} };
|
|
73
|
+
if (booleanContains(polyFeature, pt))
|
|
74
|
+
return [x, y];
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
102
77
|
}
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
78
|
+
const db = new DatabaseSync(DB, { readOnly: true });
|
|
79
|
+
const rows = db
|
|
80
|
+
.prepare(`SELECT b.geometry AS geometry, ${CATEGORIES.map((c) => `p.${c} AS ${c}`).join(", ")}
|
|
81
|
+
FROM tabblock20 b JOIN pl_block p ON b.GEOID = p.GEOID
|
|
82
|
+
WHERE p.pop_total > 0`)
|
|
83
|
+
.all();
|
|
84
|
+
db.close();
|
|
85
|
+
const out = createWriteStream(OUT);
|
|
86
|
+
const totals = new Map();
|
|
87
|
+
let dots = 0, skipped = 0;
|
|
88
|
+
for (const row of rows) {
|
|
89
|
+
let geom;
|
|
90
|
+
try {
|
|
91
|
+
geom = JSON.parse(row.geometry);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
112
94
|
continue;
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
95
|
+
}
|
|
96
|
+
const polys = geom.type === "Polygon" ? [geom.coordinates] : geom.coordinates;
|
|
97
|
+
const areas = polys.map((p) => {
|
|
98
|
+
const [a, b, c, d] = bbox(p);
|
|
99
|
+
return Math.max((c - a) * (d - b), 1e-12);
|
|
100
|
+
});
|
|
101
|
+
const totalArea = areas.reduce((s, a) => s + a, 0);
|
|
102
|
+
for (const cat of CATEGORIES) {
|
|
103
|
+
const people = row[cat];
|
|
104
|
+
if (people <= 0)
|
|
119
105
|
continue;
|
|
106
|
+
const exact = people / PER;
|
|
107
|
+
const n = Math.floor(exact) + (Math.random() < exact - Math.floor(exact) ? 1 : 0);
|
|
108
|
+
for (let k = 0; k < n; k++) {
|
|
109
|
+
const pt = randomPointIn(polys, areas, totalArea);
|
|
110
|
+
if (!pt) {
|
|
111
|
+
skipped++;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
out.write(JSON.stringify({
|
|
115
|
+
type: "Feature",
|
|
116
|
+
tippecanoe: { layer: LAYER },
|
|
117
|
+
properties: { cat },
|
|
118
|
+
geometry: { type: "Point", coordinates: [Math.round(pt[0] * 1e5) / 1e5, Math.round(pt[1] * 1e5) / 1e5] },
|
|
119
|
+
}) + "\n");
|
|
120
|
+
dots++;
|
|
121
|
+
totals.set(cat, (totals.get(cat) ?? 0) + 1);
|
|
120
122
|
}
|
|
121
|
-
out.write(JSON.stringify({
|
|
122
|
-
type: "Feature",
|
|
123
|
-
tippecanoe: { layer: LAYER },
|
|
124
|
-
properties: { cat },
|
|
125
|
-
geometry: { type: "Point", coordinates: [Math.round(pt[0] * 1e5) / 1e5, Math.round(pt[1] * 1e5) / 1e5] },
|
|
126
|
-
}) + "\n");
|
|
127
|
-
dots++;
|
|
128
|
-
totals.set(cat, (totals.get(cat) ?? 0) + 1);
|
|
129
123
|
}
|
|
130
124
|
}
|
|
131
|
-
|
|
132
|
-
out.
|
|
133
|
-
|
|
134
|
-
for (const [cat, n] of [...totals.entries()].sort((a, b) => b[1] - a[1])) {
|
|
135
|
-
|
|
125
|
+
out.end();
|
|
126
|
+
await new Promise((resolve) => out.on("finish", () => resolve()));
|
|
127
|
+
report?.(`[done] ${dots} dots from ${rows.length} blocks (1 dot ≈ ${PER} people); ${skipped} skipped`);
|
|
128
|
+
for (const [cat, n] of [...totals.entries()].sort((a, b) => b[1] - a[1])) {
|
|
129
|
+
report?.(` ${n.toString().padStart(7)} ${cat}`);
|
|
130
|
+
}
|
|
131
|
+
return { outPath: OUT, dots, skipped, blocks: rows.length, totals: Object.fromEntries(totals) };
|
|
136
132
|
}
|
|
137
133
|
//# sourceMappingURL=race-dots.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"race-dots.js","sourceRoot":"","sources":["../../tools/race-dots.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"race-dots.js","sourceRoot":"","sources":["../../tools/race-dots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAwBpD,wFAAwF;AACxF,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAU,CAAA;AAKrG,SAAS,IAAI,CAAC,KAAoB;IACjC,IAAI,IAAI,GAAG,QAAQ,EAClB,IAAI,GAAG,QAAQ,EACf,IAAI,GAAG,CAAC,QAAQ,EAChB,IAAI,GAAG,CAAC,QAAQ,CAAA;IAEjB,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAE,EAAE,CAAC;QAChC,IAAI,CAAE,GAAG,IAAI,EAAE,CAAC;YACf,IAAI,GAAG,CAAE,CAAA;QACV,CAAC;QAED,IAAI,CAAE,GAAG,IAAI,EAAE,CAAC;YACf,IAAI,GAAG,CAAE,CAAA;QACV,CAAC;QAED,IAAI,CAAE,GAAG,IAAI,EAAE,CAAC;YACf,IAAI,GAAG,CAAE,CAAA;QACV,CAAC;QAED,IAAI,CAAE,GAAG,IAAI,EAAE,CAAC;YACf,IAAI,GAAG,CAAE,CAAA;QACV,CAAC;IACF,CAAC;IAED,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AACh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CAAC;QAC1E,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAA;AAChG,CAAC"}
|
|
@@ -5,10 +5,29 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Minimal static file server that honours HTTP Range requests (206) — Python's `http.server` does
|
|
7
7
|
* not, and PMTiles reads via Range, so it can't be served by it. Used to preview/render a local
|
|
8
|
-
* `.pmtiles` tileset (e.g. the race-dot map
|
|
9
|
-
* the tile worker.
|
|
8
|
+
* `.pmtiles` tileset (e.g. the race-dot map, via `mailwoman tiger race-dots-map --serve`). Not for
|
|
9
|
+
* production; the deployed tiles go through the tile worker.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Internal helper module — no standalone command.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
import { type Server } from "node:http";
|
|
14
|
+
/** Options for {@linkcode serveWithRangeSupport}. */
|
|
15
|
+
export interface ServeRangeOptions {
|
|
16
|
+
/** Directory to serve. Default `/tmp`. */
|
|
17
|
+
dir?: string;
|
|
18
|
+
/** Port to listen on. Default 8899. */
|
|
19
|
+
port?: number;
|
|
20
|
+
}
|
|
21
|
+
/** A running range-capable static server, resolved once listening. */
|
|
22
|
+
export interface RangeServer {
|
|
23
|
+
dir: string;
|
|
24
|
+
port: number;
|
|
25
|
+
server: Server;
|
|
26
|
+
close: () => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Serve `dir` over localhost with HTTP Range support. Resolves once the server is listening; the caller owns the
|
|
30
|
+
* lifetime (`close()` to stop — commands typically hold the process open instead).
|
|
31
|
+
*/
|
|
32
|
+
export declare function serveWithRangeSupport(options?: ServeRangeOptions, report?: (line: string) => void): Promise<RangeServer>;
|
|
14
33
|
//# sourceMappingURL=serve-range.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve-range.d.ts","sourceRoot":"","sources":["../../tools/serve-range.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|
|
1
|
+
{"version":3,"file":"serve-range.d.ts","sourceRoot":"","sources":["../../tools/serve-range.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAsC,KAAK,MAAM,EAAuB,MAAM,WAAW,CAAA;AAGhG,qDAAqD;AACrD,MAAM,WAAW,iBAAiB;IACjC,0CAA0C;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAA;CACb;AAED,sEAAsE;AACtE,MAAM,WAAW,WAAW;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,IAAI,CAAA;CACjB;AAUD;;;GAGG;AACH,wBAAgB,qBAAqB,CACpC,OAAO,GAAE,iBAAsB,EAC/B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,WAAW,CAAC,CA2CtB"}
|