import { type AreaAgreementReading } from "@mailwoman/core/layers"; import { type ParsedGeometry } from "@mailwoman/spatial"; import type { PathBuilderLike } from "path-ts"; import type { SoilFeatureSource } from "#sdk/ingest"; import type { SoilChunkResult } from "#sdk/ingest/chunk"; import type { SurveyAreaAttributes } from "#sdk/survey-area"; /** * The schema version of the domain tables. * * It changes when a column changes meaning. * An added column that readers can ignore doesn't change it. */ export declare const SOIL_SCHEMA_VERSION = 1; /** * The number of delineation ids per chunk process. * * A single process over a large polygon layer fails after several hundred thousand * features because the h3 wasm heap fragments. * This size stays well below that limit. */ export declare const DEFAULT_CHUNK_SIZE = 100000; /** * One survey area ready to build, with its geometry and tabular attributes. */ export interface SurveyAreaInput { attributes: SurveyAreaAttributes; /** * The path of the map-unit polygon shapefile. */ shapefilePath?: string; /** * The survey area's outline. */ outline: ParsedGeometry; /** * An in-process feature source, used by fixtures. * * The batched path builds one of these per chunk, so both paths share one implementation. */ source?: SoilFeatureSource; /** * The delineation count that the shapefile declares, when the caller has already read it. */ declaredFeatureCount?: number; } /** * Options for {@link buildSoilDatabase}. */ export interface BuildSoilOptions { /** * The survey areas to build, in ingest order. */ areas: ReadonlyArray; /** * The region code in the layer name, such as `ia`. */ region: string; /** * The path of the sealed artifact. * * The build writes a temporary file beside it and then swaps it in. */ out: PathBuilderLike; /** * The survey refresh date, written to `layer_manifest.version` and `source_vintage`. */ sourceVintage: string; buildCmd: string; buildSHA: string; /** * The ISO-8601 creation time, supplied by the caller so that two builds of the same inputs are identical. */ createdAt: string; /** * The H3 resolution of the cell index and the reduction. */ indexResolution: number; /** * The H3 resolution of the `layer_coverage` rows. * It must be coarser than the index resolution. */ coverageResolution: number; /** * The number of delineation ids per chunk process. * See {@link DEFAULT_CHUNK_SIZE}. */ chunkSize?: number; /** * Whether to run the ingest in this process instead of in chunk processes. * * Only fixtures use it, because they have no shapefile for a child process to open. */ inProcess?: boolean; onProgress?: (message: string) => void; } /** * The counts and measurements that {@link buildSoilDatabase} reports. */ export interface BuildSoilResult { out: string; region: string; surveyAreas: number; delineations: number; mapUnits: number; components: number; indexResolution: number; coverageResolution: number; wholeCellRows: number; partialCellRows: number; /** * The value of `partialCellRows / (wholeCellRows + partialCellRows)` over the stored index rows. * * Whole cells are compacted, so this differs from the partial share used to choose the resolution. */ storedPartialShare: number; capabilityCells: number; /** * The number of cells reduced with the sampling lattice instead of the whole-cell fast path. */ sampledCells: number; /** * The number of cells whose top class covers less than half the cell. */ topClassUnderHalfCells: number; topClassUnderHalfShare: number; /** * The number of cells that the survey mapped but didn't rate. */ classlessCells: number; /** * The number of indexed cells that no lattice point landed in. * * These cells are dropped. * A large count means the lattice is too coarse for the geometry. */ unsampledCells: number; meanDelineationsPerCell: number; coarsenedFeatures: number; storedResolutions: number[]; coverageCells: number; /** * The number of coverage cells inside a survey-area outline that no mapped delineation reached. * * SSURGO covers every part of a published area, so a large count means the outline * and the delineations disagree. */ coverageCellsWithoutMapping: number; /** * The ring-area totals in square kilometers, compared with the published acreage. * * Its `known` count is the number of survey areas that publish an acreage. */ area: AreaAgreementReading; sizeBytes: number; } /** * Builds the soil layer. * * @throws {Error} When the classifier rejects a delineation, when a streamed count * differs from the shapefile's declared count, when the area total differs from the * published acreage, or when the outlines contain no interior coverage cell. */ export declare function buildSoilDatabase(options: BuildSoilOptions): Promise; /** * The combined result of every ingest chunk. */ interface StreamResult { delineations: number; coarsened: number; byArea: Map; observedByCoverageCell: Map; mappedByCoverageCell: Map; nestedM2: number; allExteriorM2: number; } /** * Sums the results of the ingest chunks. * * It is exported for a unit test because fixture builds do not exercise the batched path. */ export declare function aggregateChunks(chunks: ReadonlyArray): StreamResult; export {}; //# sourceMappingURL=build-soil.d.ts.map