/** * @copyright Sister Software * @license AGPL-3.0 * @author Teffen Ellis, et al. * * `dk-inspire`: Klimadatastyrelsen's INSPIRE Addresses GeoPackage adapter, street-level over Denmark. * * Input is a local `ad_inspire.gpkg`, the one member of the `DK_INSPIRE_Addresses.zip` that * Denmark's ATOM download service serves. The download belongs to * `#dk/tools/fetch/inspire`; this module reads a file that is already on disk, as the CSV adapters do. * * Denmark serves the Addresses (AD) theme as a GeoPackage rather than as GML, so there is no XML to * parse. A GeoPackage is a SQLite database, and this adapter reads it through * `@mailwoman/sqlite`'s Kysely client. The file is a published artifact and is opened read-only. * * The INSPIRE address model is normalized, so one address is a join rather than a row. The `address` * table carries the locator designators and a reference per component. The street name and the * postcode live in `thoroughfarename` and `postaldescriptor` and are reached through * `component_thoroughfarename` and `component_postaldescriptor`. Both resolve for every row of the * measured file, and a reference that does not resolve raises * {@linkcode UnresolvedAddressComponentError} rather than yielding an address missing its street. * * The adapter reads `locator_designator_1_designator` as `house_number`, which already carries any * letter (`2A`, `68A`); `thoroughfarename.name_name` as `street`; `postaldescriptor.postcode` and * `postname` as `postcode` and `locality`. Denmark writes a floor and a door after the house number, * and the publisher splits them across `locator_designator_2_designator` and * `locator_designator_3_designator`; the adapter joins the two into one `unit`, because the Danish * address layout places `unit` and leaves `level` unplaced. * * The file carries no region column that belongs in an address. `component_adminunitname_2` and * `_3` name a region and a municipality, neither of which a Danish address line states, so region * is left to the wof-postalcode and wof-admin cross-reference at corpus build time, as BAN's is. * * The address-source register records this source as `dk-property-building-1` and its license as * `unchecked-access-free-dk-klimadatastyrelsen`, whose `spdx` field reads `CC-BY-4.0` in an * `elected` state with `train` permitted. The adapter records that license on every row, and the * model card must attribute Klimadatastyrelsen. * * The adapter streams through Kysely's `.stream()`, so the `address` table never sits in memory, and * orders by `objectid` so two runs over one file emit the same rows in the same order. It honors * `opts.limit` and `opts.signal`. `opts.country` is optional and accepts only `DK`: the file covers * Denmark proper, and Greenland and the Faroe Islands are their own jurisdictions and are absent * from it. * * The measured file holds 599,999 `address` rows, which is one short of a round 600,000 against a * national register several times that size. Treat it as a possible export cap rather than as * Denmark's address count. The register's `coverage` field records the same reading. */ import { type CorpusAdapter } from "#types"; /** * Registry id for this adapter. * * Stamped into every row it emits, so a corpus record can be traced back to the dataset it came from. */ export declare const DK_INSPIRE_ADAPTER_ID = "dk-inspire"; /** * The license the address-source register elects for this source. * * Read from the `spdx` field of the register's `unchecked-access-free-dk-klimadatastyrelsen` * license, which the register's `dk-property-building-1` source names. * The feed's own `` says the same, but the register is what governs. */ export declare const DK_INSPIRE_DEFAULT_LICENSE = "CC-BY-4.0"; /** * Every jurisdiction this adapter emits, checked against a caller's `--country`. * * Klimadatastyrelsen's INSPIRE obligation covers Denmark proper. * Greenland and the Faroe Islands are separate ISO 3166-1 jurisdictions outside the EU, * and the file's administrative units name `Danmark` and its five regions only. */ export declare const DK_INSPIRE_COUNTRIES: readonly string[]; /** * The tables the adapter reads, which it requires `gpkg_contents` to declare. * * The GeoPackage declares five. * `addressareaname` is a supplementary locality that resolves for 206,416 of the 599,999 rows * and that a Danish address line does not state, and `adminunitname` holds the region * and municipality the adapter leaves to cross-reference, so neither is read. */ export declare const DK_INSPIRE_REQUIRED_TABLES: readonly string[]; /** * Raised when the input is not a GeoPackage this adapter can read. * * The message lists the tables that were declared, so a caller reads which file it opened * rather than receiving zero rows from a database with a different schema. */ export declare class AddressGeoPackageSchemaError extends Error { constructor(inputPath: string, declared: readonly string[], missing: readonly string[]); } /** * Raised when an address row's component reference resolves to no row of the referenced table. * * Every reference resolves in the measured file. * One that does not means the database is incomplete, which is reported * rather than converted into an address missing its street. */ export declare class UnresolvedAddressComponentError extends Error { constructor(inspireID: string, column: string, reference: string | null); } /** * The GeoPackage tables and columns the adapter reads. * * The explicit shape catches a column rename upstream. * Every text column is nullable in the publisher's own DDL except the ones marked * `NOT NULL` there, and an absent value is SQL `NULL` rather than an empty string: * the measured file holds no empty string in any column read here. */ export interface AddressGeoPackageDatabase { gpkg_contents: { table_name: string; data_type: string; }; address: { objectid: number; inspireid: string; locator_designator_1_designator: string | null; locator_designator_2_designator: string | null; locator_designator_3_designator: string | null; component_postaldescriptor: string | null; component_thoroughfarename: string | null; }; thoroughfarename: { inspireid: string | null; name_name: string; }; postaldescriptor: { inspireid: string | null; postcode: string | null; postname: string | null; }; } /** * Joins Denmark's floor and door designators into the one `unit` value an address line states. * * Klimadatastyrelsen writes the floor in `locator_designator_2_designator` * (`st` for `stuen`, the ground floor, or a storey number) and the door in * `locator_designator_3_designator` (`tv` for `til venstre`, or a number). * Danish writes the floor first, so the two join in that order. * * {@linkcode composeHouseNumber} answers the empty string when its first argument is absent, * which is right for the house-number columns it was written for and wrong here: * 967 of the measured file's rows carry a door and no floor, and passing the pair * straight through would drop every one of those doors. * The door alone is therefore the value when the floor is absent. * * @returns The joined designator, or the empty string when the publisher states neither. */ export declare function composeUnitDesignator(floor: string | null, door: string | null): string; export declare function createDKInspireAdapter(): CorpusAdapter; /** * The configured adapter instance registered with the corpus builder. */ export declare const dkInspireAdapter: CorpusAdapter; //# sourceMappingURL=adapter.d.ts.map