@mailwoman/tiger 1.0.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 +3 -0
- package/block-group.ts +151 -0
- package/class-code.ts +1026 -0
- package/constants.ts +252 -0
- package/county-subdivision.ts +154 -0
- package/county.ts +135 -0
- package/files.ts +251 -0
- package/functional-status.ts +64 -0
- package/geoid.ts +678 -0
- package/index.ts +18 -0
- package/legal-statistical-area.ts +222 -0
- package/out/block-group.d.ts +135 -0
- package/out/block-group.d.ts.map +1 -0
- package/out/block-group.js +7 -0
- package/out/block-group.js.map +1 -0
- package/out/class-code.d.ts +863 -0
- package/out/class-code.d.ts.map +1 -0
- package/out/class-code.js +864 -0
- package/out/class-code.js.map +1 -0
- package/out/constants.d.ts +220 -0
- package/out/constants.d.ts.map +1 -0
- package/out/constants.js +98 -0
- package/out/constants.js.map +1 -0
- package/out/county-subdivision.d.ts +139 -0
- package/out/county-subdivision.d.ts.map +1 -0
- package/out/county-subdivision.js +7 -0
- package/out/county-subdivision.js.map +1 -0
- package/out/county.d.ts +120 -0
- package/out/county.d.ts.map +1 -0
- package/out/county.js +9 -0
- package/out/county.js.map +1 -0
- package/out/files.d.ts +118 -0
- package/out/files.d.ts.map +1 -0
- package/out/files.js +142 -0
- package/out/files.js.map +1 -0
- package/out/functional-status.d.ts +64 -0
- package/out/functional-status.d.ts.map +1 -0
- package/out/functional-status.js +65 -0
- package/out/functional-status.js.map +1 -0
- package/out/geoid.d.ts +438 -0
- package/out/geoid.d.ts.map +1 -0
- package/out/geoid.js +255 -0
- package/out/geoid.js.map +1 -0
- package/out/index.d.ts +18 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +18 -0
- package/out/index.js.map +1 -0
- package/out/legal-statistical-area.d.ts +222 -0
- package/out/legal-statistical-area.d.ts.map +1 -0
- package/out/legal-statistical-area.js +223 -0
- package/out/legal-statistical-area.js.map +1 -0
- package/out/sdk/fetch.d.ts.map +1 -0
- package/out/sdk/fetch.js.map +1 -0
- package/out/sdk/index.d.ts +7 -0
- package/out/sdk/index.d.ts.map +1 -0
- package/out/sdk/index.js +7 -0
- package/out/sdk/index.js.map +1 -0
- package/out/sdk/redistricting.d.ts.map +1 -0
- package/out/sdk/redistricting.js.map +1 -0
- package/out/sdk/schema.d.ts.map +1 -0
- package/out/sdk/schema.js.map +1 -0
- package/out/sdk/state/TIGERTabulatedBlockEntity.d.ts +13 -0
- package/out/sdk/state/TIGERTabulatedBlockEntity.d.ts.map +1 -0
- package/out/sdk/state/TIGERTabulatedBlockEntity.js +22 -0
- package/out/sdk/state/TIGERTabulatedBlockEntity.js.map +1 -0
- package/out/sdk/state/TIGERTractEntity.d.ts +31 -0
- package/out/sdk/state/TIGERTractEntity.d.ts.map +1 -0
- package/out/sdk/state/TIGERTractEntity.js +7 -0
- package/out/sdk/state/TIGERTractEntity.js.map +1 -0
- package/out/sdk/state/block-operations.d.ts +36 -0
- package/out/sdk/state/block-operations.d.ts.map +1 -0
- package/out/sdk/state/block-operations.js +37 -0
- package/out/sdk/state/block-operations.js.map +1 -0
- package/out/sdk/state/index.d.ts +9 -0
- package/out/sdk/state/index.d.ts.map +1 -0
- package/out/sdk/state/index.js +9 -0
- package/out/sdk/state/index.js.map +1 -0
- package/out/state.d.ts +595 -0
- package/out/state.d.ts.map +1 -0
- package/out/state.js +384 -0
- package/out/state.js.map +1 -0
- package/out/tabulation-block.d.ts +43 -0
- package/out/tabulation-block.d.ts.map +1 -0
- package/out/tabulation-block.js +9 -0
- package/out/tabulation-block.js.map +1 -0
- package/out/tract.d.ts +36 -0
- package/out/tract.d.ts.map +1 -0
- package/out/tract.js +8 -0
- package/out/tract.js.map +1 -0
- package/out/tsconfig.tsbuildinfo +1 -0
- package/package.json +41 -0
- package/sdk/data/nation/index.json +14642 -0
- package/sdk/index.ts +7 -0
- package/sdk/initialize.sql +161 -0
- package/sdk/state/TIGERTabulatedBlockEntity.ts +25 -0
- package/sdk/state/TIGERTractEntity.ts +34 -0
- package/sdk/state/block-operations.ts +69 -0
- package/sdk/state/index.ts +9 -0
- package/state.ts +553 -0
- package/tabulation-block.ts +68 -0
- package/tract.ts +52 -0
- package/tsconfig.json +16 -0
- package/typedoc.json +5 -0
package/state.ts
ADDED
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { GeoFeature, MultiPolygonLiteral } from "@mailwoman/spatial"
|
|
8
|
+
import { GeoIDPart } from "./geoid.js"
|
|
9
|
+
import type { TIGERTabulatedBlockProperties } from "./tabulation-block.js"
|
|
10
|
+
|
|
11
|
+
//#region FIPS Codes
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* FIPS codes for US States.
|
|
15
|
+
*
|
|
16
|
+
* @category FIPS
|
|
17
|
+
* @category States
|
|
18
|
+
* @category Census
|
|
19
|
+
* @see {@linkcode FIPSTerritoryCode} for territories.
|
|
20
|
+
* @see {@linkcode AdminLevel1Code} for a combined set of states and territories.
|
|
21
|
+
*/
|
|
22
|
+
export enum FIPSStateCode {
|
|
23
|
+
/** @title Alabama */
|
|
24
|
+
AL = "01",
|
|
25
|
+
|
|
26
|
+
/** @title Alaska */
|
|
27
|
+
AK = "02",
|
|
28
|
+
|
|
29
|
+
/** @title Arizona */
|
|
30
|
+
AZ = "04",
|
|
31
|
+
|
|
32
|
+
/** @title Arkansas */
|
|
33
|
+
AR = "05",
|
|
34
|
+
|
|
35
|
+
/** @title California */
|
|
36
|
+
CA = "06",
|
|
37
|
+
|
|
38
|
+
/** @title Colorado */
|
|
39
|
+
CO = "08",
|
|
40
|
+
|
|
41
|
+
/** @title Connecticut */
|
|
42
|
+
CT = "09",
|
|
43
|
+
|
|
44
|
+
/** @title Delaware */
|
|
45
|
+
DE = "10",
|
|
46
|
+
|
|
47
|
+
/** @title District Of Columbia */
|
|
48
|
+
DC = "11",
|
|
49
|
+
|
|
50
|
+
/** @title Florida */
|
|
51
|
+
FL = "12",
|
|
52
|
+
|
|
53
|
+
/** @title Georgia */
|
|
54
|
+
GA = "13",
|
|
55
|
+
|
|
56
|
+
/** @title Hawaii */
|
|
57
|
+
HI = "15",
|
|
58
|
+
|
|
59
|
+
/** @title Idaho */
|
|
60
|
+
ID = "16",
|
|
61
|
+
|
|
62
|
+
/** @title Illinois */
|
|
63
|
+
IL = "17",
|
|
64
|
+
|
|
65
|
+
/** @title Indiana */
|
|
66
|
+
IN = "18",
|
|
67
|
+
|
|
68
|
+
/** @title Iowa */
|
|
69
|
+
IA = "19",
|
|
70
|
+
|
|
71
|
+
/** @title Kansas */
|
|
72
|
+
KS = "20",
|
|
73
|
+
|
|
74
|
+
/** @title Kentucky */
|
|
75
|
+
KY = "21",
|
|
76
|
+
|
|
77
|
+
/** @title Louisiana */
|
|
78
|
+
LA = "22",
|
|
79
|
+
|
|
80
|
+
/** @title Maine */
|
|
81
|
+
ME = "23",
|
|
82
|
+
|
|
83
|
+
/** @title Maryland */
|
|
84
|
+
MD = "24",
|
|
85
|
+
|
|
86
|
+
/** @title Massachusetts */
|
|
87
|
+
MA = "25",
|
|
88
|
+
|
|
89
|
+
/** @title Michigan */
|
|
90
|
+
MI = "26",
|
|
91
|
+
|
|
92
|
+
/** @title Minnesota */
|
|
93
|
+
MN = "27",
|
|
94
|
+
|
|
95
|
+
/** @title Mississippi */
|
|
96
|
+
MS = "28",
|
|
97
|
+
|
|
98
|
+
/** @title Missouri */
|
|
99
|
+
MO = "29",
|
|
100
|
+
|
|
101
|
+
/** @title Montana */
|
|
102
|
+
MT = "30",
|
|
103
|
+
|
|
104
|
+
/** @title Nebraska */
|
|
105
|
+
NE = "31",
|
|
106
|
+
|
|
107
|
+
/** @title Nevada */
|
|
108
|
+
NV = "32",
|
|
109
|
+
|
|
110
|
+
/** @title New Hampshire */
|
|
111
|
+
NH = "33",
|
|
112
|
+
|
|
113
|
+
/** @title New Jersey */
|
|
114
|
+
NJ = "34",
|
|
115
|
+
|
|
116
|
+
/** @title New Mexico */
|
|
117
|
+
NM = "35",
|
|
118
|
+
|
|
119
|
+
/** @title New York */
|
|
120
|
+
NY = "36",
|
|
121
|
+
|
|
122
|
+
/** @title North Carolina */
|
|
123
|
+
NC = "37",
|
|
124
|
+
|
|
125
|
+
/** @title North Dakota */
|
|
126
|
+
ND = "38",
|
|
127
|
+
|
|
128
|
+
/** @title Ohio */
|
|
129
|
+
OH = "39",
|
|
130
|
+
|
|
131
|
+
/** @title Oklahoma */
|
|
132
|
+
OK = "40",
|
|
133
|
+
|
|
134
|
+
/** @title Oregon */
|
|
135
|
+
OR = "41",
|
|
136
|
+
|
|
137
|
+
/** @title Pennsylvania */
|
|
138
|
+
PA = "42",
|
|
139
|
+
|
|
140
|
+
/** @title Rhode Island */
|
|
141
|
+
RI = "44",
|
|
142
|
+
|
|
143
|
+
/** @title South Carolina */
|
|
144
|
+
SC = "45",
|
|
145
|
+
|
|
146
|
+
/** @title South Dakota */
|
|
147
|
+
SD = "46",
|
|
148
|
+
|
|
149
|
+
/** @title Tennessee */
|
|
150
|
+
TN = "47",
|
|
151
|
+
|
|
152
|
+
/** @title Texas */
|
|
153
|
+
TX = "48",
|
|
154
|
+
|
|
155
|
+
/** @title Utah */
|
|
156
|
+
UT = "49",
|
|
157
|
+
|
|
158
|
+
/** @title Vermont */
|
|
159
|
+
VT = "50",
|
|
160
|
+
|
|
161
|
+
/** @title Virginia */
|
|
162
|
+
VA = "51",
|
|
163
|
+
|
|
164
|
+
/** @title Washington */
|
|
165
|
+
WA = "53",
|
|
166
|
+
|
|
167
|
+
/** @title West Virginia */
|
|
168
|
+
WV = "54",
|
|
169
|
+
|
|
170
|
+
/** @title Wisconsin */
|
|
171
|
+
WI = "55",
|
|
172
|
+
|
|
173
|
+
/** @title Wyoming */
|
|
174
|
+
WY = "56",
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* FIPS codes for US Territories.
|
|
179
|
+
*
|
|
180
|
+
* @category FIPS
|
|
181
|
+
* @category Territories
|
|
182
|
+
* @category Census
|
|
183
|
+
* @see {@linkcode FIPSStateCode} for states.
|
|
184
|
+
* @see {@linkcode AdminLevel1Code} for a combined set of states and territories.
|
|
185
|
+
* @minLength 2
|
|
186
|
+
* @maxLength 2
|
|
187
|
+
*/
|
|
188
|
+
export enum FIPSTerritoryCode {
|
|
189
|
+
/**
|
|
190
|
+
* @title Johnston Atoll
|
|
191
|
+
*/
|
|
192
|
+
JA = "74",
|
|
193
|
+
|
|
194
|
+
/** @title American Samoa */
|
|
195
|
+
AS = "60",
|
|
196
|
+
|
|
197
|
+
/** @title Guam */
|
|
198
|
+
GU = "66",
|
|
199
|
+
|
|
200
|
+
/** @title Northern Mariana Islands */
|
|
201
|
+
MP = "69",
|
|
202
|
+
|
|
203
|
+
/** @title Puerto Rico */
|
|
204
|
+
PR = "72",
|
|
205
|
+
|
|
206
|
+
/** @title Virgin Islands */
|
|
207
|
+
VI = "78",
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* A combined set of FIPS codes for US States and Territories.
|
|
212
|
+
*
|
|
213
|
+
* @category FIPS
|
|
214
|
+
* @category States
|
|
215
|
+
* @category Territories
|
|
216
|
+
* @category Census
|
|
217
|
+
* @see {@linkcode FIPSStateCode} for states.
|
|
218
|
+
* @see {@linkcode FIPSTerritoryCode} for territories.
|
|
219
|
+
* @minLength 2
|
|
220
|
+
* @maxLength 2
|
|
221
|
+
* @public
|
|
222
|
+
*/
|
|
223
|
+
export const AdminLevel1Code = {
|
|
224
|
+
...FIPSStateCode,
|
|
225
|
+
...FIPSTerritoryCode,
|
|
226
|
+
} as const
|
|
227
|
+
|
|
228
|
+
export type AdminLevel1Code = FIPSStateCode | FIPSTerritoryCode
|
|
229
|
+
|
|
230
|
+
const FIPSStateCodeToAbbreviation = Object.fromEntries(
|
|
231
|
+
Object.entries(FIPSStateCode).map(([name, code]) => [code, name])
|
|
232
|
+
) as Record<FIPSStateCode, StateAbbreviation>
|
|
233
|
+
|
|
234
|
+
const FIPSTerritoryCodeToAbbreviation = Object.fromEntries(
|
|
235
|
+
Object.entries(FIPSTerritoryCode).map(([name, code]) => [code, name])
|
|
236
|
+
) as Record<FIPSTerritoryCode, TerritoryAbbreviation>
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* A combined set of FIPS codes for US States and Territories.
|
|
240
|
+
*
|
|
241
|
+
* Maps FIPS codes to their respective two-letter abbreviations.
|
|
242
|
+
*/
|
|
243
|
+
export const AdminLevel1CodeToAbbreviation = {
|
|
244
|
+
...FIPSStateCodeToAbbreviation,
|
|
245
|
+
...FIPSTerritoryCodeToAbbreviation,
|
|
246
|
+
} as Record<AdminLevel1Code, AdminLevel1Abbreviation>
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Type-predicate to determine if a given string is a valid state FIPS code.
|
|
250
|
+
*/
|
|
251
|
+
export function isStateFIPSCode(code: string | null | undefined): code is FIPSStateCode {
|
|
252
|
+
if (!code || typeof code !== "string") return false
|
|
253
|
+
|
|
254
|
+
return Object.hasOwn(FIPSStateCodeToAbbreviation, code)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Type-predicate to determine if a given string is a valid territory FIPS code.
|
|
259
|
+
*/
|
|
260
|
+
export function isTerritoryFIPSCode(code: string | null | undefined): code is FIPSTerritoryCode {
|
|
261
|
+
if (!code || typeof code !== "string") return false
|
|
262
|
+
|
|
263
|
+
return Object.hasOwn(FIPSTerritoryCodeToAbbreviation, code)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Type-predicate to determine if a given string is a valid state-level FIPS code.
|
|
268
|
+
*
|
|
269
|
+
* This includes both states and territories.
|
|
270
|
+
*/
|
|
271
|
+
export function isAdminLevel1FIPSCode(code: string | null | undefined): code is AdminLevel1Code {
|
|
272
|
+
return isStateFIPSCode(code) || isTerritoryFIPSCode(code)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
//#endregion
|
|
276
|
+
|
|
277
|
+
//#region State Abbreviation
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Two-letter abbreviations of a US states.
|
|
281
|
+
*
|
|
282
|
+
* @minLength 2
|
|
283
|
+
* @maxLength 2
|
|
284
|
+
* @public
|
|
285
|
+
*/
|
|
286
|
+
export enum StateAbbreviation {
|
|
287
|
+
"Alaska" = "AK",
|
|
288
|
+
"Alabama" = "AL",
|
|
289
|
+
"Arkansas" = "AR",
|
|
290
|
+
"Arizona" = "AZ",
|
|
291
|
+
"California" = "CA",
|
|
292
|
+
"Colorado" = "CO",
|
|
293
|
+
"Connecticut" = "CT",
|
|
294
|
+
"District of Columbia" = "DC",
|
|
295
|
+
"Delaware" = "DE",
|
|
296
|
+
"Florida" = "FL",
|
|
297
|
+
"Georgia" = "GA",
|
|
298
|
+
"Hawaii" = "HI",
|
|
299
|
+
"Iowa" = "IA",
|
|
300
|
+
"Idaho" = "ID",
|
|
301
|
+
"Illinois" = "IL",
|
|
302
|
+
"Indiana" = "IN",
|
|
303
|
+
"Kansas" = "KS",
|
|
304
|
+
"Kentucky" = "KY",
|
|
305
|
+
"Louisiana" = "LA",
|
|
306
|
+
"Massachusetts" = "MA",
|
|
307
|
+
"Maryland" = "MD",
|
|
308
|
+
"Maine" = "ME",
|
|
309
|
+
"Michigan" = "MI",
|
|
310
|
+
"Minnesota" = "MN",
|
|
311
|
+
"Missouri" = "MO",
|
|
312
|
+
"Mississippi" = "MS",
|
|
313
|
+
"Montana" = "MT",
|
|
314
|
+
"North Carolina" = "NC",
|
|
315
|
+
"North Dakota" = "ND",
|
|
316
|
+
"Nebraska" = "NE",
|
|
317
|
+
"New Hampshire" = "NH",
|
|
318
|
+
"New Jersey" = "NJ",
|
|
319
|
+
"New Mexico" = "NM",
|
|
320
|
+
"Nevada" = "NV",
|
|
321
|
+
"New York" = "NY",
|
|
322
|
+
"Ohio" = "OH",
|
|
323
|
+
"Oklahoma" = "OK",
|
|
324
|
+
"Oregon" = "OR",
|
|
325
|
+
"Pennsylvania" = "PA",
|
|
326
|
+
"Rhode Island" = "RI",
|
|
327
|
+
"South Carolina" = "SC",
|
|
328
|
+
"South Dakota" = "SD",
|
|
329
|
+
"Tennessee" = "TN",
|
|
330
|
+
"Texas" = "TX",
|
|
331
|
+
"Utah" = "UT",
|
|
332
|
+
"Virginia" = "VA",
|
|
333
|
+
"Vermont" = "VT",
|
|
334
|
+
"Washington" = "WA",
|
|
335
|
+
"Wisconsin" = "WI",
|
|
336
|
+
"West Virginia" = "WV",
|
|
337
|
+
"Wyoming" = "WY",
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export enum TerritoryAbbreviation {
|
|
341
|
+
"American Samoa" = "AS",
|
|
342
|
+
"Johnston Atoll" = "JA",
|
|
343
|
+
"Guam" = "GU",
|
|
344
|
+
"Virgin Islands" = "VI",
|
|
345
|
+
"Northern Mariana Islands" = "MP",
|
|
346
|
+
"Puerto Rico" = "PR",
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Two-letter abbreviations of a US states and territories.
|
|
351
|
+
*
|
|
352
|
+
* @minLength 2
|
|
353
|
+
* @maxLength 2
|
|
354
|
+
* @public
|
|
355
|
+
*/
|
|
356
|
+
export type AdminLevel1Abbreviation = StateAbbreviation | TerritoryAbbreviation
|
|
357
|
+
|
|
358
|
+
export const AdminLevel1Abbreviation = {
|
|
359
|
+
...StateAbbreviation,
|
|
360
|
+
...TerritoryAbbreviation,
|
|
361
|
+
} as const
|
|
362
|
+
|
|
363
|
+
//#endregion
|
|
364
|
+
|
|
365
|
+
//#region State Name
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* US State abbreviations to their full names.
|
|
369
|
+
*
|
|
370
|
+
* @public
|
|
371
|
+
*/
|
|
372
|
+
export enum StateName {
|
|
373
|
+
AS = "American Samoa",
|
|
374
|
+
AK = "Alaska",
|
|
375
|
+
AL = "Alabama",
|
|
376
|
+
AR = "Arkansas",
|
|
377
|
+
AZ = "Arizona",
|
|
378
|
+
CA = "California",
|
|
379
|
+
CO = "Colorado",
|
|
380
|
+
CT = "Connecticut",
|
|
381
|
+
DC = "District of Columbia",
|
|
382
|
+
DE = "Delaware",
|
|
383
|
+
FL = "Florida",
|
|
384
|
+
GA = "Georgia",
|
|
385
|
+
HI = "Hawaii",
|
|
386
|
+
IA = "Iowa",
|
|
387
|
+
ID = "Idaho",
|
|
388
|
+
IL = "Illinois",
|
|
389
|
+
IN = "Indiana",
|
|
390
|
+
JA = "Johnston Atoll",
|
|
391
|
+
KS = "Kansas",
|
|
392
|
+
KY = "Kentucky",
|
|
393
|
+
LA = "Louisiana",
|
|
394
|
+
MA = "Massachusetts",
|
|
395
|
+
MD = "Maryland",
|
|
396
|
+
ME = "Maine",
|
|
397
|
+
MI = "Michigan",
|
|
398
|
+
MN = "Minnesota",
|
|
399
|
+
MO = "Missouri",
|
|
400
|
+
MS = "Mississippi",
|
|
401
|
+
MT = "Montana",
|
|
402
|
+
NC = "North Carolina",
|
|
403
|
+
ND = "North Dakota",
|
|
404
|
+
NE = "Nebraska",
|
|
405
|
+
NH = "New Hampshire",
|
|
406
|
+
NJ = "New Jersey",
|
|
407
|
+
NM = "New Mexico",
|
|
408
|
+
NV = "Nevada",
|
|
409
|
+
NY = "New York",
|
|
410
|
+
OH = "Ohio",
|
|
411
|
+
OK = "Oklahoma",
|
|
412
|
+
OR = "Oregon",
|
|
413
|
+
PA = "Pennsylvania",
|
|
414
|
+
PR = "Puerto Rico",
|
|
415
|
+
RI = "Rhode Island",
|
|
416
|
+
SC = "South Carolina",
|
|
417
|
+
SD = "South Dakota",
|
|
418
|
+
TN = "Tennessee",
|
|
419
|
+
TX = "Texas",
|
|
420
|
+
UT = "Utah",
|
|
421
|
+
VA = "Virginia",
|
|
422
|
+
VT = "Vermont",
|
|
423
|
+
WA = "Washington",
|
|
424
|
+
WI = "Wisconsin",
|
|
425
|
+
WV = "West Virginia",
|
|
426
|
+
WY = "Wyoming",
|
|
427
|
+
VI = "Virgin Islands",
|
|
428
|
+
MP = "Northern Mariana Islands",
|
|
429
|
+
GU = "Guam",
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
//#endregion
|
|
433
|
+
|
|
434
|
+
//#region State Utilities
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Predicate for checking if a string is a proper abbreviation for a US State or territory, rather
|
|
438
|
+
* than a random 2-letter string.
|
|
439
|
+
*
|
|
440
|
+
* @see {@link isStateAbbreviation} for a specific check for US States.
|
|
441
|
+
* @see {@link isStateTerritoryAbbreviation} for a specific check for US Territories.
|
|
442
|
+
*/
|
|
443
|
+
export function isStateLevelAbbreviation(input: unknown): input is AdminLevel1Abbreviation {
|
|
444
|
+
if (typeof input !== "string") return false
|
|
445
|
+
|
|
446
|
+
return Object.hasOwn(FIPSStateCode, input) || Object.hasOwn(FIPSTerritoryCode, input)
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Predicate for checking if a string is a proper abbreviation for a US State, rather than a random
|
|
451
|
+
* 2-letter string.
|
|
452
|
+
*
|
|
453
|
+
* @see {@link isStateLevelAbbreviation} for a general check for US States and Territories.
|
|
454
|
+
* @see {@link isStateTerritoryAbbreviation} for a specific check for US Territories.
|
|
455
|
+
*/
|
|
456
|
+
export function isStateAbbreviation(input: unknown): input is StateAbbreviation {
|
|
457
|
+
if (typeof input !== "string") return false
|
|
458
|
+
|
|
459
|
+
return Object.hasOwn(FIPSStateCode, input)
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Predicate for checking if a string is a proper abbreviation for a US Territory, rather than a
|
|
464
|
+
* random 2-letter string.
|
|
465
|
+
*
|
|
466
|
+
* @see {@link isStateLevelAbbreviation} for a general check for US States and Territories.
|
|
467
|
+
* @see {@link isStateAbbreviation} for a specific check for US States.
|
|
468
|
+
*/
|
|
469
|
+
export function isStateTerritoryAbbreviation(input: unknown): input is AdminLevel1Abbreviation {
|
|
470
|
+
if (typeof input !== "string") return false
|
|
471
|
+
|
|
472
|
+
return Object.hasOwn(FIPSTerritoryCode, input)
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Common case variations of a US State or Territory name.
|
|
477
|
+
*
|
|
478
|
+
* @internal
|
|
479
|
+
*/
|
|
480
|
+
export type StateNameVariation = StateName | Lowercase<StateName> | Uppercase<StateName>
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Details about a US State or Territory.
|
|
484
|
+
*
|
|
485
|
+
* @title US State Details
|
|
486
|
+
*/
|
|
487
|
+
export interface StateDetails {
|
|
488
|
+
/**
|
|
489
|
+
* Two-letter abbreviation of the state or territory.
|
|
490
|
+
*
|
|
491
|
+
* @title Abbreviation
|
|
492
|
+
*/
|
|
493
|
+
abbreviation: AdminLevel1Abbreviation
|
|
494
|
+
/**
|
|
495
|
+
* Full name of the state or territory.
|
|
496
|
+
*
|
|
497
|
+
* @title Name
|
|
498
|
+
*/
|
|
499
|
+
displayName: StateName
|
|
500
|
+
/**
|
|
501
|
+
* The FIPS code for the state or territory.
|
|
502
|
+
*
|
|
503
|
+
* @title FIPS Code
|
|
504
|
+
*/
|
|
505
|
+
FIPSCode: string
|
|
506
|
+
/**
|
|
507
|
+
* The ANSI code for the state or territory.
|
|
508
|
+
*
|
|
509
|
+
* @title ANSI Code
|
|
510
|
+
*/
|
|
511
|
+
ANSICode: string
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* A US state as defined by the Census Bureau's TIGER system.
|
|
516
|
+
*
|
|
517
|
+
* @title Census TIGER State
|
|
518
|
+
* @public
|
|
519
|
+
*/
|
|
520
|
+
export interface TIGERState {
|
|
521
|
+
/**
|
|
522
|
+
* The two-letter abbreviation of a US state.
|
|
523
|
+
*
|
|
524
|
+
* @title State Abbreviation
|
|
525
|
+
*/
|
|
526
|
+
abbreviation: AdminLevel1Abbreviation
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* The state's name.
|
|
530
|
+
*
|
|
531
|
+
* @title State Name
|
|
532
|
+
*/
|
|
533
|
+
displayName: StateName
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* The state's FIPS code.
|
|
537
|
+
*
|
|
538
|
+
* @title State FIPS Code
|
|
539
|
+
*/
|
|
540
|
+
[GeoIDPart.State]: AdminLevel1Code
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* The geometry of the tabulated block, typically a polygon, but may be a multi-polygon for blocks
|
|
544
|
+
* with holes, or islands.
|
|
545
|
+
*
|
|
546
|
+
* @title Geometry
|
|
547
|
+
*/
|
|
548
|
+
GEOM: MultiPolygonLiteral
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
export type TIGERStateFeature = GeoFeature<MultiPolygonLiteral, TIGERTabulatedBlockProperties>
|
|
552
|
+
|
|
553
|
+
//#endregion
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { type MultiPolygonLiteral } from "@mailwoman/spatial"
|
|
8
|
+
import { TIGERProperty, type TIGERPropertyRecord } from "./constants.js"
|
|
9
|
+
import { GeoIDPart, type FIPSBlockGeoID, type ParsedGeoIDBlockLevel } from "./geoid.js"
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The properties of a tabulated block from the TIGER/Line dataset.
|
|
13
|
+
*/
|
|
14
|
+
export type TIGERTabulatedBlockProperties = Pick<
|
|
15
|
+
TIGERPropertyRecord<FIPSBlockGeoID>,
|
|
16
|
+
| TIGERProperty.GeoID
|
|
17
|
+
| GeoIDPart.CountySubDivision
|
|
18
|
+
| GeoIDPart.Tract
|
|
19
|
+
| GeoIDPart.Place
|
|
20
|
+
| GeoIDPart.BlockGroup
|
|
21
|
+
| GeoIDPart.Block
|
|
22
|
+
| GeoIDPart.Place
|
|
23
|
+
| GeoIDPart.CongressionalDistrict
|
|
24
|
+
| TIGERProperty.ClassCode
|
|
25
|
+
| TIGERProperty.UrbanRuralCode
|
|
26
|
+
| TIGERProperty.UrbanizedAreaCode
|
|
27
|
+
| TIGERProperty.FunctionalStatus
|
|
28
|
+
| TIGERProperty.LandAreaSqm
|
|
29
|
+
| TIGERProperty.WaterAreaSqm
|
|
30
|
+
| TIGERProperty.CentroidLatitude
|
|
31
|
+
| TIGERProperty.CentroidLongitude
|
|
32
|
+
| TIGERProperty.HousingUnitCount
|
|
33
|
+
| TIGERProperty.Population
|
|
34
|
+
>
|
|
35
|
+
|
|
36
|
+
export interface TIGERBlockFeature {
|
|
37
|
+
type: "Feature"
|
|
38
|
+
id: FIPSBlockGeoID
|
|
39
|
+
geometry: MultiPolygonLiteral
|
|
40
|
+
properties: TIGERTabulatedBlockProperties
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface TIGERBlockFeatureCollection {
|
|
44
|
+
type: "FeatureCollection"
|
|
45
|
+
features: TIGERBlockFeature[]
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A tabulated block from the TIGER/Line dataset.
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
export interface TIGERTabulatedBlock extends ParsedGeoIDBlockLevel, TIGERTabulatedBlockProperties {
|
|
54
|
+
/**
|
|
55
|
+
* The GeoID of the tabulated block.
|
|
56
|
+
*
|
|
57
|
+
* @title GeoID
|
|
58
|
+
*/
|
|
59
|
+
GEOID: FIPSBlockGeoID
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The geometry of the tabulated block, typically a polygon, but may be a multi-polygon for blocks
|
|
63
|
+
* with holes, or islands.
|
|
64
|
+
*
|
|
65
|
+
* @title Geometry
|
|
66
|
+
*/
|
|
67
|
+
GEOMETRY: MultiPolygonLiteral
|
|
68
|
+
}
|
package/tract.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { type GeoFeature, type MultiPolygonLiteral } from "@mailwoman/spatial"
|
|
8
|
+
import { TIGERProperty, type TIGERPropertyRecord } from "./constants.js"
|
|
9
|
+
import type { FIPSTractGeoID, GeoIDPart, ParsedGeoIDTractLevel } from "./geoid.js"
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @title TIGER Tract
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface TIGERTract extends ParsedGeoIDTractLevel {
|
|
16
|
+
/**
|
|
17
|
+
* The GeoID of the tabulated block.
|
|
18
|
+
*
|
|
19
|
+
* @title Geo ID
|
|
20
|
+
*/
|
|
21
|
+
GEOID: FIPSTractGeoID
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The geometry of the tabulated block, typically a polygon, but may be a multi-polygon for blocks
|
|
25
|
+
* with holes, or islands.
|
|
26
|
+
*
|
|
27
|
+
* @title Geometry
|
|
28
|
+
*/
|
|
29
|
+
GEOMETRY: MultiPolygonLiteral
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Properties of a Census Tract.
|
|
34
|
+
*/
|
|
35
|
+
export type TIGERTractProperties = Pick<
|
|
36
|
+
TIGERPropertyRecord<FIPSTractGeoID>,
|
|
37
|
+
| TIGERProperty.GeoID
|
|
38
|
+
| GeoIDPart.State
|
|
39
|
+
| GeoIDPart.County
|
|
40
|
+
| GeoIDPart.Tract
|
|
41
|
+
| TIGERProperty.ClassCode
|
|
42
|
+
| TIGERProperty.FunctionalStatus
|
|
43
|
+
| TIGERProperty.LandAreaSqm
|
|
44
|
+
| TIGERProperty.WaterAreaSqm
|
|
45
|
+
| TIGERProperty.CentroidLongitude
|
|
46
|
+
| TIGERProperty.CentroidLatitude
|
|
47
|
+
>
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A geographci feature representing a Census Tract.
|
|
51
|
+
*/
|
|
52
|
+
export type TIGERTractFeature = GeoFeature<MultiPolygonLiteral, TIGERTractProperties>
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@sister.software/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"allowSyntheticDefaultImports": true,
|
|
5
|
+
"emitDecoratorMetadata": true,
|
|
6
|
+
"emitDeclarationOnly": false,
|
|
7
|
+
"allowImportingTsExtensions": false,
|
|
8
|
+
"experimentalDecorators": true
|
|
9
|
+
},
|
|
10
|
+
"exclude": ["./out/**/*"],
|
|
11
|
+
"references": [
|
|
12
|
+
// ---
|
|
13
|
+
{ "path": "../core" },
|
|
14
|
+
{ "path": "../spatial" }
|
|
15
|
+
]
|
|
16
|
+
}
|