@mailwoman/soil 10.0.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -116
- package/lib/index.ts +66 -98
- package/lib/paths.ts +24 -0
- package/lib/schema.ts +188 -120
- package/lib/vocabulary.ts +40 -107
- package/out/index.d.ts +52 -70
- package/out/index.d.ts.map +1 -1
- package/out/index.js +24 -72
- package/out/index.js.map +1 -1
- package/out/paths.d.ts +19 -0
- package/out/paths.d.ts.map +1 -0
- package/out/paths.js +21 -0
- package/out/paths.js.map +1 -0
- package/out/schema.d.ts +187 -119
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js +31 -31
- package/out/schema.js.map +1 -1
- package/out/sdk/acquire.d.ts +15 -24
- package/out/sdk/acquire.d.ts.map +1 -1
- package/out/sdk/acquire.js +6 -21
- package/out/sdk/acquire.js.map +1 -1
- package/out/sdk/build-soil.d.ts +67 -70
- package/out/sdk/build-soil.d.ts.map +1 -1
- package/out/sdk/build-soil.js +64 -94
- package/out/sdk/build-soil.js.map +1 -1
- package/out/sdk/cell-tiers.d.ts +7 -19
- package/out/sdk/cell-tiers.d.ts.map +1 -1
- package/out/sdk/cell-tiers.js +19 -38
- package/out/sdk/cell-tiers.js.map +1 -1
- package/out/sdk/cells.d.ts +15 -41
- package/out/sdk/cells.d.ts.map +1 -1
- package/out/sdk/cells.js +11 -38
- package/out/sdk/cells.js.map +1 -1
- package/out/sdk/client.d.ts +23 -48
- package/out/sdk/client.d.ts.map +1 -1
- package/out/sdk/client.js +19 -63
- package/out/sdk/client.js.map +1 -1
- package/out/sdk/download.d.ts +24 -47
- package/out/sdk/download.d.ts.map +1 -1
- package/out/sdk/download.js +14 -54
- package/out/sdk/download.js.map +1 -1
- package/out/sdk/ingest/chunk.d.ts +29 -25
- package/out/sdk/ingest/chunk.d.ts.map +1 -1
- package/out/sdk/ingest/chunk.js +18 -16
- package/out/sdk/ingest/chunk.js.map +1 -1
- package/out/sdk/ingest/worker.d.ts +9 -0
- package/out/sdk/ingest/worker.d.ts.map +1 -0
- package/out/{scripts/ingest-chunk.js → sdk/ingest/worker.js} +11 -10
- package/out/sdk/ingest/worker.js.map +1 -0
- package/out/sdk/ingest.d.ts +120 -0
- package/out/sdk/ingest.d.ts.map +1 -0
- package/out/sdk/ingest.js +127 -0
- package/out/sdk/ingest.js.map +1 -0
- package/out/sdk/measure-resolutions.d.ts +6 -17
- package/out/sdk/measure-resolutions.d.ts.map +1 -1
- package/out/sdk/measure-resolutions.js +4 -16
- package/out/sdk/measure-resolutions.js.map +1 -1
- package/out/sdk/reduce.d.ts +33 -59
- package/out/sdk/reduce.d.ts.map +1 -1
- package/out/sdk/reduce.js +47 -78
- package/out/sdk/reduce.js.map +1 -1
- package/out/sdk/survey-area.d.ts +16 -48
- package/out/sdk/survey-area.d.ts.map +1 -1
- package/out/sdk/survey-area.js +33 -77
- package/out/sdk/survey-area.js.map +1 -1
- package/out/sdk/tabular.d.ts +32 -31
- package/out/sdk/tabular.d.ts.map +1 -1
- package/out/sdk/tabular.js +57 -49
- package/out/sdk/tabular.js.map +1 -1
- package/out/sdk/test-kit.d.ts +57 -0
- package/out/sdk/test-kit.d.ts.map +1 -0
- package/out/{test-kit.js → sdk/test-kit.js} +18 -39
- package/out/sdk/test-kit.js.map +1 -0
- package/out/sdk/verify.d.ts +15 -51
- package/out/sdk/verify.d.ts.map +1 -1
- package/out/sdk/verify.js +19 -77
- package/out/sdk/verify.js.map +1 -1
- package/out/vocabulary.d.ts +37 -103
- package/out/vocabulary.d.ts.map +1 -1
- package/out/vocabulary.js +34 -107
- package/out/vocabulary.js.map +1 -1
- package/package.json +36 -190
- package/{lib/sdk → sdk}/acquire.ts +18 -28
- package/{lib/sdk → sdk}/build-soil.ts +113 -127
- package/{lib/sdk → sdk}/cell-tiers.ts +20 -39
- package/{lib/sdk → sdk}/cells.ts +17 -43
- package/sdk/client.ts +147 -0
- package/sdk/download.ts +131 -0
- package/{lib/sdk → sdk}/ingest/chunk.ts +35 -27
- package/{lib/scripts/ingest-chunk.ts → sdk/ingest/worker.ts} +10 -9
- package/sdk/ingest.ts +253 -0
- package/{lib/sdk → sdk}/measure-resolutions.ts +6 -17
- package/sdk/reduce.ts +344 -0
- package/{lib/sdk → sdk}/survey-area.ts +39 -83
- package/{lib/sdk → sdk}/tabular.ts +61 -52
- package/{lib → sdk}/test-kit.ts +19 -41
- package/{lib/sdk → sdk}/verify.ts +29 -85
- package/lib/sdk/client.ts +0 -184
- package/lib/sdk/download.ts +0 -161
- package/lib/sdk/index.ts +0 -20
- package/lib/sdk/ingest/index.ts +0 -278
- package/lib/sdk/reduce.ts +0 -375
- package/out/scripts/ingest-chunk.d.ts +0 -11
- package/out/scripts/ingest-chunk.d.ts.map +0 -1
- package/out/scripts/ingest-chunk.js.map +0 -1
- package/out/sdk/index.d.ts +0 -20
- package/out/sdk/index.d.ts.map +0 -1
- package/out/sdk/index.js +0 -20
- package/out/sdk/index.js.map +0 -1
- package/out/sdk/ingest/index.d.ts +0 -132
- package/out/sdk/ingest/index.d.ts.map +0 -1
- package/out/sdk/ingest/index.js +0 -170
- package/out/sdk/ingest/index.js.map +0 -1
- package/out/test-kit.d.ts +0 -79
- package/out/test-kit.d.ts.map +0 -1
- package/out/test-kit.js.map +0 -1
package/lib/schema.ts
CHANGED
|
@@ -3,36 +3,26 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* Typed schema for `soil.db
|
|
7
|
-
*
|
|
6
|
+
* Typed schema for `soil.db`. It defines the polygon truth table, its containment index and the shared reduction
|
|
7
|
+
* that both consumers read. It also defines the layer-interface tables from `@mailwoman/core/layers`.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* weights change silently.
|
|
9
|
+
* {@link SoilMapUnitAreaTable} stores the authority's unsimplified geometry.
|
|
10
|
+
* {@link SoilMapUnitCellTable} records which cells each delineation reaches and whether it fills them.
|
|
11
|
+
* {@link SoilCapabilityCellTable} is that index reduced once, at build time, into a per-cell
|
|
12
|
+
* distribution. A `partial` cell's contribution is weighted by the area it covers. The truth table keeps
|
|
13
|
+
* unsimplified rings so simplification cannot change those weights silently.
|
|
15
14
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* `muaggatt.niccdcd` — its own dominant-condition capability class — beside `niccdcdpct`, the share that
|
|
21
|
-
* class actually covers, with an observed minimum of 2%. This table reproduces that pattern at cell grain
|
|
22
|
-
* rather than inventing one.
|
|
15
|
+
* The reduction stores a distribution instead of one winning class. Four separate shares record reasons for
|
|
16
|
+
* absence. Class 8 is a determination, so it contributes a class share. A fold that places a `notcom` polygon, a water body
|
|
17
|
+
* and an unrated series into "not arable" would produce a well-formed but wrong answer. The four shares preserve
|
|
18
|
+
* those distinctions.
|
|
23
19
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* polygon, a water body and an unrated series into "not arable" would produce a well-formed wrong answer,
|
|
28
|
-
* which is what the four shares exist to make impossible.
|
|
29
|
-
*
|
|
30
|
-
* `WITHOUT ROWID` ON THE CELL TABLES AND NEVER ON THE GEOMETRY TABLE. Small fixed-width rows probed by
|
|
31
|
-
* their exact primary key belong in the B-tree; a row carrying a geometry blob does not — clustering it
|
|
32
|
-
* into the B-tree makes every index page a geometry page.
|
|
20
|
+
* Cell tables use `without rowid`; the geometry table uses ordinary rowids. Small fixed-width rows are probed by
|
|
21
|
+
* their exact primary key, so they fit the B-tree. A geometry blob would make every index page a geometry page if
|
|
22
|
+
* stored in that B-tree.
|
|
33
23
|
*/
|
|
34
24
|
|
|
35
|
-
import type {
|
|
25
|
+
import type { layerschemadatabase } from "@mailwoman/core/layers"
|
|
36
26
|
import { addBoundingBoxColumns, addCellIndexColumns, addRingGeometryColumns } from "@mailwoman/sqlite/schema-columns"
|
|
37
27
|
import { sql, type Kysely } from "kysely"
|
|
38
28
|
|
|
@@ -41,11 +31,16 @@ import { sql, type Kysely } from "kysely"
|
|
|
41
31
|
*/
|
|
42
32
|
export const SoilCellContainment = {
|
|
43
33
|
/**
|
|
44
|
-
* Every point in the cell is inside the delineation.
|
|
34
|
+
* Every point in the cell is inside the delineation.
|
|
35
|
+
*
|
|
36
|
+
* Answered from the index without reading geometry.
|
|
45
37
|
*/
|
|
46
38
|
Whole: "whole",
|
|
47
39
|
/**
|
|
48
|
-
* The delineation's boundary crosses the cell.
|
|
40
|
+
* The delineation's boundary crosses the cell.
|
|
41
|
+
*
|
|
42
|
+
* The index has narrowed the candidates.
|
|
43
|
+
* The point test decides.
|
|
49
44
|
*/
|
|
50
45
|
Partial: "partial",
|
|
51
46
|
} as const
|
|
@@ -53,19 +48,29 @@ export const SoilCellContainment = {
|
|
|
53
48
|
export type SoilCellContainment = (typeof SoilCellContainment)[keyof typeof SoilCellContainment]
|
|
54
49
|
|
|
55
50
|
/**
|
|
56
|
-
* One map-unit delineation, verbatim.
|
|
57
|
-
*
|
|
51
|
+
* One map-unit delineation, verbatim.
|
|
52
|
+
*
|
|
53
|
+
* A plain rowid table.
|
|
54
|
+
* It holds a geometry blob.
|
|
55
|
+
* `without rowid` stores this shape inefficiently.
|
|
58
56
|
*/
|
|
59
57
|
export interface SoilMapUnitAreaTable {
|
|
60
58
|
/**
|
|
61
|
-
* `<areasymbol>:<ordinal>`
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
59
|
+
* `<areasymbol>:<ordinal>` identifies the survey area and this delineation's
|
|
60
|
+
* position in the authority's own shapefile order.
|
|
61
|
+
*
|
|
62
|
+
* SSURGO publishes no per-delineation key.
|
|
63
|
+
* `mukey` identifies the map unit.
|
|
64
|
+
*
|
|
65
|
+
* Each map unit has many delineations.
|
|
66
|
+
* The ordinal distinguishes each delineation row.
|
|
67
|
+
*
|
|
68
|
+
* Text allows the source to publish a non-numeric ID without a schema change.
|
|
65
69
|
*/
|
|
66
70
|
area_id: string
|
|
67
71
|
/**
|
|
68
|
-
* The map unit this delineation
|
|
72
|
+
* The map unit that contains this delineation.
|
|
73
|
+
* NRCS uses this key to join every attribute.
|
|
69
74
|
*/
|
|
70
75
|
mukey: string
|
|
71
76
|
areasymbol: string
|
|
@@ -74,26 +79,31 @@ export interface SoilMapUnitAreaTable {
|
|
|
74
79
|
max_lat: number
|
|
75
80
|
max_lon: number
|
|
76
81
|
/**
|
|
77
|
-
* The authority's ring coordinates, unsimplified
|
|
82
|
+
* The authority's ring coordinates, unsimplified.
|
|
83
|
+
* See `@mailwoman/spatial`'s ring blob for the layout.
|
|
78
84
|
*/
|
|
79
85
|
rings: Uint8Array
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
/**
|
|
83
|
-
*
|
|
89
|
+
* Records whether a delineation covers a whole cell or only part of it.
|
|
84
90
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
91
|
+
* Rows use the delineation as the key because the reduction weights by covered area.
|
|
92
|
+
* Two delineations from one map unit can reach the same cell while covering different ground.
|
|
87
93
|
*/
|
|
88
94
|
export interface SoilMapUnitCellTable {
|
|
89
95
|
/**
|
|
90
|
-
* 48-bit short H3 cell.
|
|
91
|
-
*
|
|
96
|
+
* 48-bit short H3 cell.
|
|
97
|
+
*
|
|
98
|
+
* Uses mixed resolutions.
|
|
99
|
+
* `whole` rows are compacted parent-ward; `partial` rows stay at the index resolution.
|
|
92
100
|
*/
|
|
93
101
|
h3_cell: number
|
|
94
102
|
/**
|
|
95
|
-
* The resolution this row's cell was captured at.
|
|
96
|
-
*
|
|
103
|
+
* The resolution this row's cell was captured at.
|
|
104
|
+
*
|
|
105
|
+
* A short cell has no resolution of its own.
|
|
106
|
+
* A table that mixes resolutions requires this column for probes.
|
|
97
107
|
*/
|
|
98
108
|
resolution: number
|
|
99
109
|
area_id: string
|
|
@@ -104,47 +114,61 @@ export interface SoilMapUnitCellTable {
|
|
|
104
114
|
}
|
|
105
115
|
|
|
106
116
|
/**
|
|
107
|
-
* One
|
|
117
|
+
* One ssurgo map unit, the attribute row every delineation joins to.
|
|
108
118
|
*/
|
|
109
119
|
export interface SoilMapUnitTable {
|
|
110
120
|
mukey: string
|
|
111
121
|
areasymbol: string
|
|
112
122
|
/**
|
|
113
|
-
* The map unit symbol.
|
|
114
|
-
*
|
|
123
|
+
* The map unit symbol.
|
|
124
|
+
*
|
|
125
|
+
* `notcom` and `notpub` are meaningful values here rather than codes to skip.
|
|
126
|
+
* They mark a polygon the authority drew with no soil mapping behind it.
|
|
115
127
|
*/
|
|
116
128
|
musym: string
|
|
117
129
|
muname: string
|
|
118
130
|
/**
|
|
119
|
-
* `Consociation` | `Complex` | `Association` | `Undifferentiated group`,
|
|
120
|
-
*
|
|
121
|
-
*
|
|
131
|
+
* `Consociation` | `Complex` | `Association` | `Undifferentiated group`,
|
|
132
|
+
* from the authority's declared domain.
|
|
133
|
+
*
|
|
134
|
+
* A complex is nrcs's statement that two or more soils are intermingled
|
|
135
|
+
* and cannot be separated at the mapping scale.
|
|
136
|
+
* The mixture is the survey's finding rather than this layer's loss.
|
|
122
137
|
*/
|
|
123
138
|
mukind: string | null
|
|
124
139
|
mustatus: string | null
|
|
125
140
|
/**
|
|
126
|
-
* The full conditional string, verbatim.
|
|
127
|
-
*
|
|
141
|
+
* The full conditional string, verbatim.
|
|
142
|
+
*
|
|
143
|
+
* `Not prime farmland` is itself a declared value, while NULL means the map
|
|
144
|
+
* unit has no farmland classification.
|
|
128
145
|
*/
|
|
129
146
|
farmlndcl: string | null
|
|
130
147
|
/**
|
|
131
|
-
* Which of {@link FarmlandScope} `farmlndcl` falls under
|
|
132
|
-
*
|
|
133
|
-
*
|
|
148
|
+
* Which of {@link FarmlandScope} `farmlndcl` falls under.
|
|
149
|
+
*
|
|
150
|
+
* Federal criteria travel between states, while delegated ones do not.
|
|
151
|
+
*
|
|
152
|
+
* Derived once at build time so a consumer never has to re-read 7 CFR 657.5 to know
|
|
153
|
+
* whether two rows are comparable.
|
|
134
154
|
*/
|
|
135
155
|
farmland_scope: string
|
|
136
156
|
/**
|
|
137
|
-
*
|
|
157
|
+
* Nrcs's own dominant-condition capability class for the map unit, stored rather than recomputed.
|
|
138
158
|
*/
|
|
139
159
|
niccdcd: string | null
|
|
140
160
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
161
|
+
* The share that class actually covers.
|
|
162
|
+
*
|
|
163
|
+
* The pair is the pattern this layer's cell reduction reproduces at cell grain,
|
|
164
|
+
* so carrying both makes the two comparable.
|
|
143
165
|
*/
|
|
144
166
|
niccdcdpct: number | null
|
|
145
167
|
/**
|
|
146
|
-
* Whether this map unit is a polygon with
|
|
147
|
-
*
|
|
168
|
+
* Whether this map unit is a polygon with no soil mapping behind it, such as `notcom`,
|
|
169
|
+
* `notpub`, access denied, or a map unit carrying no components at all.
|
|
170
|
+
*
|
|
171
|
+
* Such a map unit contributes to `nodata_share` and never to a class share.
|
|
148
172
|
*/
|
|
149
173
|
no_mapping: number
|
|
150
174
|
}
|
|
@@ -156,17 +180,20 @@ export interface SoilComponentTable {
|
|
|
156
180
|
cokey: string
|
|
157
181
|
mukey: string
|
|
158
182
|
/**
|
|
159
|
-
* The component's representative percentage of its map unit
|
|
183
|
+
* The component's representative percentage of its map unit, the weight the reduction aggregates by.
|
|
160
184
|
*/
|
|
161
185
|
comppct_r: number
|
|
162
186
|
compname: string | null
|
|
163
187
|
/**
|
|
164
|
-
* `Miscellaneous area` is what separates
|
|
165
|
-
*
|
|
188
|
+
* `Miscellaneous area` is what separates not-rateable from unrated: a rock outcrop
|
|
189
|
+
* or a water body is a component the capability rating does not apply to,
|
|
190
|
+
* while an unrated series is one the survey did not rate.
|
|
166
191
|
*/
|
|
167
192
|
compkind: string | null
|
|
168
193
|
/**
|
|
169
|
-
* Nonirrigated Land Capability Class, `"1"`–`"8"`.
|
|
194
|
+
* Nonirrigated Land Capability Class, `"1"`–`"8"`.
|
|
195
|
+
*
|
|
196
|
+
* NULL means not rated, never class 8.
|
|
170
197
|
*/
|
|
171
198
|
nirrcapcl: string | null
|
|
172
199
|
/**
|
|
@@ -174,38 +201,48 @@ export interface SoilComponentTable {
|
|
|
174
201
|
*/
|
|
175
202
|
nirrcapscl: string | null
|
|
176
203
|
/**
|
|
177
|
-
* The irrigated rating.
|
|
178
|
-
*
|
|
179
|
-
* is
|
|
204
|
+
* The irrigated rating.
|
|
205
|
+
*
|
|
206
|
+
* Populated only where irrigation is a considered use, so its absence states that
|
|
207
|
+
* the rating does not apply rather than anything about the land.
|
|
208
|
+
* The build stores it without reducing it.
|
|
180
209
|
*/
|
|
181
210
|
irrcapcl: string | null
|
|
182
211
|
irrcapscl: string | null
|
|
183
212
|
/**
|
|
184
|
-
* The
|
|
213
|
+
* The nccpi v3.0 overall index in [0, 1], under its own rule name.
|
|
214
|
+
*
|
|
215
|
+
* Never blended with the capability class.
|
|
185
216
|
*/
|
|
186
217
|
nccpi_v3: number | null
|
|
187
218
|
}
|
|
188
219
|
|
|
189
220
|
/**
|
|
190
|
-
*
|
|
221
|
+
* The shared artifact both consumers read, one row per cell with the index reduced once.
|
|
191
222
|
*
|
|
192
|
-
* The result-level observation takes {@link SoilCapabilityCellTable.top_class} with the share it rests
|
|
193
|
-
* affordance vector takes `class_shares` plus the four absence shares as its axis.
|
|
194
|
-
*
|
|
223
|
+
* The result-level observation takes {@link SoilCapabilityCellTable.top_class} with the share it rests
|
|
224
|
+
* on, while the affordance vector takes `class_shares` plus the four absence shares as its axis.
|
|
225
|
+
* One artifact, one aggregation and one set of provenance rows, so the two
|
|
226
|
+
* consumers cannot disagree about what the ground is.
|
|
195
227
|
*/
|
|
196
228
|
export interface SoilCapabilityCellTable {
|
|
197
229
|
/**
|
|
198
|
-
* 48-bit short H3 cell at the declared index resolution.
|
|
199
|
-
*
|
|
230
|
+
* 48-bit short H3 cell at the declared index resolution.
|
|
231
|
+
*
|
|
232
|
+
* Single-resolution, unlike {@link SoilMapUnitCellTable}, because a consumer joins
|
|
233
|
+
* on this table and a mixed-resolution join key cannot serve that.
|
|
200
234
|
*/
|
|
201
235
|
h3_cell: number
|
|
202
236
|
/**
|
|
203
|
-
* JSON: the authority's class codes mapped to their area-weighted share, sorted by descending share.
|
|
204
|
-
*
|
|
237
|
+
* JSON: the authority's class codes mapped to their area-weighted share, sorted by descending share.
|
|
238
|
+
*
|
|
239
|
+
* Shares above the declared truncation floor only.
|
|
240
|
+
* The remainder is in `other_share`.
|
|
205
241
|
*/
|
|
206
242
|
class_shares: string
|
|
207
243
|
/**
|
|
208
|
-
* Mapped soil components carrying a NULL rating
|
|
244
|
+
* Mapped soil components carrying a NULL rating.
|
|
245
|
+
* The survey did not rate them.
|
|
209
246
|
*/
|
|
210
247
|
unrated_share: number
|
|
211
248
|
/**
|
|
@@ -213,82 +250,105 @@ export interface SoilCapabilityCellTable {
|
|
|
213
250
|
*/
|
|
214
251
|
notrateable_share: number
|
|
215
252
|
/**
|
|
216
|
-
* `
|
|
253
|
+
* `notcom`, `notpub` and access-denied map units: a polygon the authority drew,
|
|
254
|
+
* with no soil mapping behind it.
|
|
217
255
|
*/
|
|
218
256
|
nodata_share: number
|
|
219
257
|
/**
|
|
220
|
-
* The truncated minority tail.
|
|
221
|
-
*
|
|
258
|
+
* The truncated minority tail.
|
|
259
|
+
*
|
|
260
|
+
* Stored explicitly so the five shares always sum to 1 and a reader can see how
|
|
261
|
+
* much was folded away rather than inferring it from a gap.
|
|
222
262
|
*/
|
|
223
263
|
other_share: number
|
|
224
264
|
/**
|
|
225
|
-
* The fraction of the
|
|
265
|
+
* The fraction of the cell covered by any map-unit delineation at all.
|
|
266
|
+
*
|
|
267
|
+
* The five shares above are normalized over this value and sum to 1 exactly.
|
|
268
|
+
* A cell at a survey-area edge can fall partly outside every delineation.
|
|
226
269
|
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
* cell wholly inside the mapped area reads 1.
|
|
270
|
+
* This column prevents the unmapped remainder from deflating every class share.
|
|
271
|
+
*
|
|
272
|
+
* This schema prevents an absence from appearing as a small number.
|
|
273
|
+
* A cell wholly inside the mapped area reads 1.
|
|
231
274
|
*/
|
|
232
275
|
mapped_share: number
|
|
233
276
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
277
|
+
* Stores the largest class share and its proportion.
|
|
278
|
+
*
|
|
279
|
+
* This gives consumers an at-cell result and follows NRCS's `niccdcd`/`niccdcdpct` pattern.
|
|
280
|
+
*
|
|
281
|
+
* NULL when the cell has no class.
|
|
282
|
+
* This is a valid result.
|
|
283
|
+
*
|
|
284
|
+
* A cell that is 100% `unrated_share` is complete and has no capability reading.
|
|
237
285
|
*/
|
|
238
286
|
top_class: string | null
|
|
239
287
|
top_class_share: number | null
|
|
240
288
|
/**
|
|
241
|
-
* Which weighting produced the shares
|
|
242
|
-
*
|
|
289
|
+
* Which weighting produced the shares, one of {@link SOIL_SHARE_WEIGHTING}.
|
|
290
|
+
*
|
|
291
|
+
* Stored per row as well as in the manifest.
|
|
292
|
+
* A later build with different weighting must have a distinct record.
|
|
243
293
|
*/
|
|
244
294
|
weighting: string
|
|
245
295
|
/**
|
|
246
|
-
* How many delineations reached this cell.
|
|
247
|
-
*
|
|
296
|
+
* How many delineations reached this cell.
|
|
297
|
+
*
|
|
298
|
+
* Supplies the denominator behind each share above.
|
|
299
|
+
* It also distinguishes a single-delineation cell from a crowded cell.
|
|
248
300
|
*/
|
|
249
301
|
delineations: number
|
|
250
302
|
}
|
|
251
303
|
|
|
252
304
|
/**
|
|
253
|
-
* The authority's mapped footprint, one row per published survey area
|
|
254
|
-
* area's own metadata
|
|
305
|
+
* The authority's mapped footprint, one row per published survey area, derived from the
|
|
306
|
+
* survey-area outline and each area's own metadata rather than from the rated polygons.
|
|
255
307
|
*
|
|
256
|
-
*
|
|
257
|
-
* are
|
|
258
|
-
*
|
|
308
|
+
* The survey's §3.2 identifies rated polygons as an invalid source for this footprint.
|
|
309
|
+
* `notcom` and access-denied map units are inside the footprint and have no rating,
|
|
310
|
+
* so a footprint taken from the rated set would report them as unmapped even
|
|
311
|
+
* though the authority has declared exactly what they are.
|
|
259
312
|
*/
|
|
260
313
|
export interface SoilSurveyAreaTable {
|
|
261
314
|
areasymbol: string
|
|
262
315
|
areaname: string
|
|
263
316
|
/**
|
|
264
|
-
* The version-established date from `sacatalog.saverest
|
|
317
|
+
* The version-established date from `sacatalog.saverest`, the refresh and the manifest's vintage.
|
|
265
318
|
*/
|
|
266
319
|
saverest: string
|
|
267
320
|
saversion: number | null
|
|
268
321
|
/**
|
|
269
|
-
* The
|
|
322
|
+
* The oldest source citation date in the area's own fgdc lineage, the field
|
|
323
|
+
* survey the republished polygons rest on.
|
|
270
324
|
*
|
|
271
|
-
* This
|
|
272
|
-
* over a field survey published in 1960
|
|
273
|
-
*
|
|
325
|
+
* This date differs from `saverest`.
|
|
326
|
+
* `IA153` records a 2025-09-09 refresh over a field survey published in 1960.
|
|
327
|
+
*
|
|
328
|
+
* The dataset's time-period-of-content ends at the refresh, so it does not state
|
|
329
|
+
* when the field survey occurred.
|
|
274
330
|
*/
|
|
275
331
|
survey_source_date: string | null
|
|
276
332
|
/**
|
|
277
|
-
* The title of the source `survey_source_date
|
|
333
|
+
* The title of the source for `survey_source_date`.
|
|
334
|
+
* It lets readers check the date against its source.
|
|
278
335
|
*/
|
|
279
336
|
survey_source_title: string | null
|
|
280
337
|
/**
|
|
281
|
-
* The scale of that original source
|
|
338
|
+
* The scale of that original source, 15840 for `IA153`'s 1960 survey.
|
|
282
339
|
*/
|
|
283
340
|
source_scale: number | null
|
|
284
341
|
/**
|
|
285
|
-
* The scale the map units were
|
|
286
|
-
*
|
|
342
|
+
* The scale the map units were digitized at, from `legend.projectscale`, 12000 for `IA153`.
|
|
343
|
+
*
|
|
344
|
+
* This differs from `source_scale`.
|
|
345
|
+
* `source_scale` describes survey detail; `mapping_scale` describes drawing detail.
|
|
287
346
|
*/
|
|
288
347
|
mapping_scale: number | null
|
|
289
348
|
/**
|
|
290
|
-
* The area the authority publishes for the survey area, in acres.
|
|
291
|
-
*
|
|
349
|
+
* The area the authority publishes for the survey area, in acres.
|
|
350
|
+
*
|
|
351
|
+
* The independent witness the ring-area check compares against.
|
|
292
352
|
*/
|
|
293
353
|
area_acres: number | null
|
|
294
354
|
min_lat: number
|
|
@@ -296,7 +356,7 @@ export interface SoilSurveyAreaTable {
|
|
|
296
356
|
max_lat: number
|
|
297
357
|
max_lon: number
|
|
298
358
|
/**
|
|
299
|
-
*
|
|
359
|
+
* The number of `layer_coverage` rows this survey area produced and their resolution.
|
|
300
360
|
*/
|
|
301
361
|
coverage_cells: number
|
|
302
362
|
coverage_resolution: number
|
|
@@ -305,13 +365,14 @@ export interface SoilSurveyAreaTable {
|
|
|
305
365
|
/**
|
|
306
366
|
* The authority's declared domain for one `Choice` column, read out of the `msdomdet.txt` the archive ships.
|
|
307
367
|
*
|
|
308
|
-
* Stored so a reader can refuse a code the layer
|
|
309
|
-
*
|
|
368
|
+
* Stored so a reader can refuse a code the layer cannot hold.
|
|
369
|
+
* The artifact also includes the authority's prose definition of "capability class 3"
|
|
370
|
+
* instead of requiring a separate handbook.
|
|
310
371
|
*/
|
|
311
372
|
export interface SoilVocabularyTable {
|
|
312
373
|
/**
|
|
313
|
-
* The domain name as
|
|
314
|
-
* `
|
|
374
|
+
* The domain name as nrcs spells it, such as `capability_class`, `capability_subclass`,
|
|
375
|
+
* `farmland_classification`, `component_kind` or `mapunit_kind`.
|
|
315
376
|
*/
|
|
316
377
|
domain: string
|
|
317
378
|
/**
|
|
@@ -323,7 +384,7 @@ export interface SoilVocabularyTable {
|
|
|
323
384
|
*/
|
|
324
385
|
definition: string
|
|
325
386
|
/**
|
|
326
|
-
*
|
|
387
|
+
* Each value's sequence records its order within the authority's domain.
|
|
327
388
|
*/
|
|
328
389
|
sequence: number
|
|
329
390
|
}
|
|
@@ -331,7 +392,7 @@ export interface SoilVocabularyTable {
|
|
|
331
392
|
/**
|
|
332
393
|
* Pass to `new DatabaseClient<SoilDatabase>(...)`.
|
|
333
394
|
*/
|
|
334
|
-
export interface SoilDatabase extends
|
|
395
|
+
export interface SoilDatabase extends layerschemadatabase {
|
|
335
396
|
soil_map_unit_area: SoilMapUnitAreaTable
|
|
336
397
|
soil_map_unit_cell: SoilMapUnitCellTable
|
|
337
398
|
soil_map_unit: SoilMapUnitTable
|
|
@@ -342,14 +403,18 @@ export interface SoilDatabase extends LayerContractDatabase {
|
|
|
342
403
|
}
|
|
343
404
|
|
|
344
405
|
/**
|
|
345
|
-
* The
|
|
346
|
-
*
|
|
406
|
+
* The subset of a Kysely handle the DDL touches.
|
|
407
|
+
*
|
|
408
|
+
* Kysely is invariant in its schema parameter, so naming only the members these
|
|
409
|
+
* functions call lets a caller pass its own wider handle.
|
|
347
410
|
*/
|
|
348
411
|
export type SoilSchemaHandle = Pick<Kysely<SoilDatabase>, "schema">
|
|
349
412
|
|
|
350
413
|
/**
|
|
351
|
-
* Create `soil_map_unit_area`.
|
|
352
|
-
*
|
|
414
|
+
* Create `soil_map_unit_area`.
|
|
415
|
+
*
|
|
416
|
+
* A plain rowid table on purpose.
|
|
417
|
+
* The `rings` blob is exactly the payload `without rowid` penalizes.
|
|
353
418
|
*/
|
|
354
419
|
export async function createSoilMapUnitAreaTable(db: SoilSchemaHandle): Promise<void> {
|
|
355
420
|
const table = db.schema
|
|
@@ -362,14 +427,16 @@ export async function createSoilMapUnitAreaTable(db: SoilSchemaHandle): Promise<
|
|
|
362
427
|
}
|
|
363
428
|
|
|
364
429
|
/**
|
|
365
|
-
* Create `soil_map_unit_cell
|
|
430
|
+
* Create `soil_map_unit_cell`, the containment index.
|
|
431
|
+
*
|
|
432
|
+
* Small fixed-width rows probed by their exact primary key.
|
|
366
433
|
*/
|
|
367
434
|
export async function createSoilMapUnitCellTable(db: SoilSchemaHandle): Promise<void> {
|
|
368
435
|
const table = db.schema.createTable("soil_map_unit_cell")
|
|
369
436
|
|
|
370
437
|
await addCellIndexColumns(table, "area_id")
|
|
371
438
|
.addPrimaryKeyConstraint("soil_map_unit_cell_pk", ["h3_cell", "area_id"])
|
|
372
|
-
// `
|
|
439
|
+
// `without rowid` has no first-class builder. The raw modifier is the idiomatic fallback.
|
|
373
440
|
.modifyEnd(sql`without rowid`)
|
|
374
441
|
.execute()
|
|
375
442
|
}
|
|
@@ -414,7 +481,8 @@ export async function createSoilComponentTable(db: SoilSchemaHandle): Promise<vo
|
|
|
414
481
|
}
|
|
415
482
|
|
|
416
483
|
/**
|
|
417
|
-
* Create `soil_capability_cell
|
|
484
|
+
* Create `soil_capability_cell`.
|
|
485
|
+
* The reduction both consumers read.
|
|
418
486
|
*/
|
|
419
487
|
export async function createSoilCapabilityCellTable(db: SoilSchemaHandle): Promise<void> {
|
|
420
488
|
await db.schema
|