/** * @copyright Sister Software * @license AGPL-3.0 * @author Teffen Ellis, et al. * * `lv-varis`: Latvia's State Address Register (`Valsts adrešu reģistrs`), read from the open data * Valsts zemes dienests publishes as the data.gov.lv dataset `varis-atvertie-dati`. * * Input is the directory `fetchVaris` writes: six of the dataset's CSV tables, each under the file * name the portal serves it as, `aw_eka.csv` and the five tables its parent codes point into. Every table is * UTF-8 with a byte-order mark, comma-separated, and quotes every field, doubling a quote inside a * value. The column metadata the publisher posts beside each table declares `ISO-8859-1`; the bytes * are UTF-8, and the reader decodes them as UTF-8. Over the 2026-09-30 edition no value in * `aw_eka.csv` holds a line break, 0 of 610,876 records. * * ## One row per building or land-unit address * * `aw_eka.csv` holds the addresses of buildings and of land units intended for building, one record * per address. Of its 610,876 records, `STATUSS` is `EKS` (existing) on 550,652, `DEL` (removed) on * 32,448 and `ERR` (erroneous) on 27,776. Only `EKS` records become rows. The two other states are * counted under {@linkcode VarisRefusal}. * * Each record names its immediate parent by `VKUR_CD` and `VKUR_TIPS`, and the parent names its own * the same way, up to the country. The type codes are the register's: `104` city (`pilsēta`), `105` * parish (`pagasts`), `106` village (`ciems`), `107` street (`iela`), `113` municipality (`novads`) * and `101` Latvia, whose code `100000000` no table holds as a row. Over the 550,652 active records the * chains take seven shapes, written from the parent upward. The rows column counts what the adapter * emits after the refusals below: * * | Chain | Records | Rows | {@linkcode VarisAddressType} | * | ----------------------------- | ------: | ------: | ----------------------------- | * | parish, municipality | 116,225 | 116,225 | `parish-named-house` | * | street, city, municipality | 113,906 | 113,905 | `town-street` | * | street, city | 111,218 | 111,217 | `state-city-street` | * | village, parish, municipality | 108,164 | 108,164 | `village-named-house` | * | street, village, parish, mun. | 98,192 | 98,179 | `village-street` | * | city, municipality | 2,814 | 2,814 | `city-named-house` | * | city | 133 | 133 | `city-named-house` | * * No active record has an unresolved or inactive ancestor, 0 of 550,652. * * ## The written form is the publisher's * * `STD` holds the register's own full address string: `Krišjāņa Barona iela 1, Rīga, LV-1050` or * `"Riņņi", Vecates pag., Valmieras nov., LV-4211`. Each * part is the `NOSAUKUMS` of one object in the chain, in chain order, joined by a comma and a space, * with the postcode `ATRIB` last. A building on a street writes the street name and the house number * as one part, and a named building writes its name inside ASCII double quotes. The adapter composes * that string from the chain and compares it with `STD`. Over the 550,637 active records the adapter * does not refuse first, the two are equal on 550,637. A record where they differ is refused, so every * row's `raw` is `STD` unchanged and every component's position in it is known. The row's surface is * `attested`. Aligning the 550,637 rows with `alignRow` at edit distance 0 quarantines none and places * every component in the order above. * * The comparison reads values as stored. 25 building names end in a space, and `STD` keeps it inside the * quotes, `"Vilidža "`, so the reader turns off the CSV reader's trimming, composes from the stored * values and trims only the labels. * * The codex renderer cannot produce this order. libaddressinput's Latvian layout prints the region * line before the locality, `Siguldas nov., Sigulda, LV-2150`, where the register writes `Sigulda, * Siguldas nov., LV-2150`, so `formatAddressRow` is not called. * * ## Which tag each part takes * * - The street's `NOSAUKUMS` is `street`, type word included: `Brīvības iela`, `Vidusceļš`. No Latvian * street-type split exists in this repository, and the register stores the name whole. * - The house number is `house_number`, its building-block suffix included: `195 k-1` is house 195, * block (`korpuss`) 1, one address in the register. Over the 323,316 street addresses, 249,783 are * bare digits and 56,374 digits and a letter. 15 hold no digit, such as `Bauskas iela Ozoli`, where * a house name stands in the number's place. Those are refused, because the name is not a number * and labeling it a venue would place a venue after a street, which no other Latvian row does. * - A building's name is `venue`. SCHEMA.mdx defines `venue` as a named place and keeps * `building_name` for Japan, and the Estonian register adapter labels a farm name `venue` for the same * reason. The quotes are punctuation and lie outside the span. 236 names hold a quote of their own, * such as `Stacija "Biksti"`, which the register writes `"Stacija "Biksti""`. * - A city and a parish are `locality`. Both are direct parts of a municipality, so they are the same * tier, and a rural address without a village still writes the parish it lies in. The * parish is written with the register's abbreviation, `Vecates pag.`, and the span includes it, as a * `subregion` of `Multnomah County` includes `County`. * - A village is `dependent_locality`. It lies inside a parish, and the Estonian adapter labels a * village inside a rural municipality the same way. * - A municipality is `region`, abbreviation included: `Valmieras nov.`. The register holds no tier * above it: the parent of all 35 active municipalities is Latvia. The 7 active cities whose parent is * Latvia, the state cities such as Rīga and Daugavpils, write no municipality, so their rows carry no * region. * - `ATRIB` is `postcode`, prefix included: `LV-4211`. * * ## Premises and apartments * * The register's premises table, `aw_dziv.csv`, holds 868,669 active apartment and premises addresses * in 57,285 buildings, more than the 550,652 building addresses. A tenth of those buildings hold 50.1% * of the apartments, and one building holds 681. Rows for every apartment would make a few large blocks * the commonest Latvian address, so the adapter reads no premises. * * ## Personal data, identity and license * * The register records places and names no owner or occupant, so no row carries a natural person's * name. A building name is the name of the property, as on a map. * * The row id is the register's own object code, `lv-varis-`. Five `STD` strings are each written * by two codes, so two rows can share a `raw` while their ids differ. * * data.gov.lv publishes the dataset under `CC-BY-4.0`, the `license_id` its CKAN record names for the * publisher Valsts zemes dienests, and the column metadata posted beside `aw_dziv.csv` names * `https://creativecommons.org/licenses/by/4.0/` as `dc:license`. CC BY 4.0 requires credit, a link to the license and * a statement that changes were made, so every row records the license and * {@linkcode LV_VARIS_ATTRIBUTION} is the credit the model card carries. * * The adapter honors `opts.limit` and `opts.signal`. `opts.country` is optional and accepts only `LV`. */ import type { PathBuilderLike } from "path-ts"; import { type CanonicalRow, type CorpusAdapter } from "#types"; /** * Registry id for this adapter, stamped into every row it emits. */ export declare const LV_VARIS_ADAPTER_ID = "lv-varis"; /** * The one jurisdiction this adapter emits. */ export declare const LV_VARIS_COUNTRIES: readonly string[]; /** * The license data.gov.lv names for the dataset. */ export declare const LV_VARIS_LICENSE = "CC-BY-4.0"; /** * The credit CC BY 4.0 obliges. */ export declare const LV_VARIS_ATTRIBUTION = "Valsts zemes dienests, Valsts adre\u0161u re\u0123istra atv\u0113rtie dati, via data.gov.lv"; /** * The register tables the adapter reads, by the file name the portal serves each under. */ export declare const VARIS_TABLES: { readonly Building: "aw_eka.csv"; readonly Street: "aw_iela.csv"; readonly Village: "aw_ciems.csv"; readonly Parish: "aw_pagasts.csv"; readonly Municipality: "aw_novads.csv"; readonly City: "aw_pilseta.csv"; }; export type VarisTable = (typeof VARIS_TABLES)[keyof typeof VARIS_TABLES]; /** * The register's addressing-object type codes, `TIPS_CD` and `VKUR_TIPS`. */ export declare const VarisObjectType: { readonly Country: "101"; readonly City: "104"; readonly Parish: "105"; readonly Village: "106"; readonly Street: "107"; readonly Building: "108"; readonly Municipality: "113"; }; export type VarisObjectType = (typeof VarisObjectType)[keyof typeof VarisObjectType]; /** * Why a building record did not become a row. */ export declare const VarisRefusal: { /** * `STATUSS` is `DEL`: the address was removed. */ readonly Removed: "row:status-removed"; /** * `STATUSS` is `ERR`: the register marks the address erroneous. */ readonly Erroneous: "row:status-erroneous"; /** * `STATUSS` holds a value the register's documentation does not list. */ readonly UnknownStatus: "row:status-unknown"; /** * A code in the parent chain names no object in the tables read. */ readonly ParentUnresolved: "row:parent-unresolved"; /** * An object in the parent chain is not active. */ readonly AncestorInactive: "row:ancestor-inactive"; /** * The chain holds an object type in a place no address shape allows. */ readonly UnexpectedHierarchy: "row:unexpected-hierarchy"; /** * The record carries no `LV-` postcode. */ readonly PostcodeAbsent: "row:postcode-absent"; /** * A building on a street carries a name with no digit where its number belongs. */ readonly NamedHouseOnStreet: "row:named-house-on-street"; /** * The string composed from the chain differs from the register's `STD`. */ readonly StandardFormMismatch: "row:standard-form-mismatch"; }; export type VarisRefusal = (typeof VarisRefusal)[keyof typeof VarisRefusal]; /** * The shape of an address, read from its parent chain. */ export declare const VarisAddressType: { /** * A street address in one of the state cities, which lie under no municipality. */ readonly StateCityStreet: "state-city-street"; /** * A street address in a town of a municipality. */ readonly TownStreet: "town-street"; /** * A street address in a village. */ readonly VillageStreet: "village-street"; /** * A named house in a city, on no street. */ readonly CityNamedHouse: "city-named-house"; /** * A named house in a village. */ readonly VillageNamedHouse: "village-named-house"; /** * A named house in a parish, in no village. */ readonly ParishNamedHouse: "parish-named-house"; }; export type VarisAddressType = (typeof VarisAddressType)[keyof typeof VarisAddressType]; /** * The columns read from every table. */ export interface VarisRecord { KODS: string; TIPS_CD: string; STATUSS: string; VKUR_CD: string; VKUR_TIPS: string; NOSAUKUMS: string; ATRIB: string; STD: string; } /** * One object a building's parent chain passes through. */ export interface VarisPlace { type: string; name: string; parentCode: string; active: boolean; } /** * The places of the five parent tables, keyed by object code. */ export type VarisPlaces = ReadonlyMap; export type VarisReading = { readonly admitted: CanonicalRow; readonly addressType: VarisAddressType; } | { readonly refused: VarisRefusal; }; /** * The object code the register gives Latvia, the parent of every municipality and state city. * No table read holds it as a row. */ export declare const VARIS_COUNTRY_CODE = "100000000"; /** * Reads one building record into a row or the reason it is refused. */ export declare function readVarisBuilding(record: VarisRecord, places: VarisPlaces): VarisReading; /** * Streams one table's records, each value as stored. * * Trimming is off because `STD` keeps a stored trailing space inside a building * name's quotes, and the composition check compares the two. */ export declare function readVarisTable(path: PathBuilderLike): AsyncIterable; /** * Reads the five parent tables into one map keyed by object code. */ export declare function readVarisPlaces(directory: PathBuilderLike): Promise>; export declare function createVarisAdapter(): CorpusAdapter; /** * The configured adapter instance registered with the corpus builder. */ export declare const varisAdapter: CorpusAdapter; //# sourceMappingURL=adapter.d.ts.map