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