/** * A WOF GeoJSON feature, as published by the per-record bundles. */ export interface WOFFeature { type?: string; id?: number | string; properties?: Record | null; } /** * Lightweight in-memory shape both adapters keep per record. * * Geometry is intentionally dropped because the adapters never consult it. */ export interface WOFRecord { id: number; parent_id: number | null; name: string; placetype: string; /** * ISO 3166-1 alpha-2 from `wof:country`, upper-cased on read. * * The standard's codes are upper case. * The publisher's spelling can differ. * * A consumer such as the `--country NL` filter compares the two strings directly. */ country: string; /** * Localized name variants from `name:*` properties. * * Keys are the raw `name:eng_x_preferred` form. * A key whose array holds one distinct value maps to that string, and a key with several * maps to all of them in source order: New York City's `name:eng_x_colloquial` lists * Big Apple, Gotham and NYC. {@linkcode nameValues} reads either shape. * * The single-value case stays a string because an admin run holds over 13 million records resident. * This representation avoids allocating an array when a key has one value. * * The canonical `wof:name` isn't included — adapters add a synthetic `"default"` slot for it. */ nameVariants: Map; /** * Ancestor ids from `wof:hierarchy`, nearest level first, keeping only the levels on * which every hierarchy the record lists agrees. * * New York City lists five hierarchies, one per county, so its county is left out * and its region and country stay. * Empty when the record lists no hierarchy, in which case the parent chain answers. */ ancestors: readonly number[]; /** * The countries that lead the record's own ISO 3166 and HASC codes ({@linkcode SUBDIVISION_OF_SOURCES}), * where one differs from `country`: `GP` for France's region Guadeloupe (`iso:id` `GP`). */ codeCountries: readonly string[]; } /** * The WOF concordances whose leading two letters are the code of the country a region is a * subdivision of: the ISO code and the HASC code (`GF` for French Guiana, `BQ.BO` for Bonaire). */ export declare const SUBDIVISION_OF_SOURCES: readonly ["iso:id", "iso:code", "hasc:id"]; /** * The country code that leads an ISO 3166 or HASC code, `GF` for `GF` and `BQ` for `BQ.BO` * or `BQ-BO`, or `null` for a code that leads with none. */ export declare function codeCountry(code: string): string | null; /** * `mz:is_current` ∈ {`1`, `-1`} → keep, `0` → drop. * * Real WOF postalcode distros tag every row `-1` ("unknown but treated as active") and the * Pelias importer accepts `-1` alongside `1`; tightening the predicate to `= 1` makes the * postalcode distros contribute zero rows to the corpus, silently, with no error to notice it by. */ export declare function isCurrentFeature(props: Record): boolean; /** * Pull `name:*` localized variants off a WOF feature's properties, keeping every distinct non-blank * value of the array WOF stores them in (`["Saint Petersburg"]`), with attestations removed. */ export declare function extractNameVariants(props: Record): Map; /** * Every value one `name:*` key holds, in source order. */ export declare function nameValues(value: string | readonly string[] | undefined): readonly string[]; /** * The first `name:_x_preferred` value of a record, or `null` when the record has none. * * `language` is the ISO 639-3 code WOF keys its names by (`jpn`, `kor`). */ export declare function preferredName(record: WOFRecord, language: string): string | null; /** * Removes historical attestations from a Who's On First name and trims the result. */ export declare function stripAttestation(name: string): string; /** * Turn a `name:*` property key into a hyphen-safe suffix fragment for `source_id` * (`"name:eng_x_colloquial"` → `"name-eng-x-colloquial"`); both `:` and `_` become `-` * because both collide with the separator vocabulary downstream consumers split on. */ export declare function normalizeNameKey(rawKey: string): string; /** * The kind and language of a WOF name-slot key, the TypeScript twin of {@linkcode wofNameSlotSQL}. * * `default` reads as kind and language `default`; `name-rus-x-preferred-2` as `preferred` * and `rus`; a `name-` key without `-x-` as kind `unmarked`. */ export declare function parseWOFSlotKey(key: string): { kind: string; language: string; }; /** * DuckDB expressions that read a WOF row's name slot back out of its `source_id`. * * A WOF `source_id` is `---`. * The slot key is `default` or a {@linkcode normalizeNameKey} form such as * `name-rus-x-preferred` or `name-und-x-variant-2`. * * `kind` is `default` or the part after `-x-` (`preferred`, `variant`, `colloquial`…), * and `unmarked` for a `name-` key without one. * `language` is `default` or the key's ISO 639 code. */ export declare function wofNameSlotSQL(sourceID?: string): { kind: string; language: string; }; /** * Parse a single GeoJSON feature; `null` means skip this row for any reason. */ export declare function recordFromFeature(feature: WOFFeature, refutedParents: ReadonlySet): WOFRecord | null; /** * The committed list of WOF records whose point lies over 1 km outside their parent's * polygon and inside another polygon of the parent's placetype. */ export declare const REFUTED_PARENTS_PATH: string; /** * The ids in {@linkcode REFUTED_PARENTS_PATH}, read once per process. */ export declare function readRefutedParentIDs(): Promise>; /** * Whether a WOF record's representative point is exactly latitude 0, longitude 0, * the value WOF writes for a record that has no geometry. * * The parent of such a record was not found by location. * WOF assigns 347 Spanish postcodes from every province, including Soria's `42002`, * to the village of Melgar de Yuso. */ export declare function isAtOrigin(props: Record): boolean; /** * The record one GeoJSON file holds, or `null` when the file is unreadable, malformed or skipped. * * The single-record explorer reads its record and ancestors through this. */ export declare function readFeatureRecord(filePath: string): Promise; /** * The component tags a variant builder looks an ancestor up by. * * `variantsFor` reads the nearest `locality`, `subregion` (county), `region` * and `country` ancestor, with its localized and colloquial names. * `postcodeVariantsFor` reads the nearest `locality`, `region` and `country`. */ export declare const ANCESTOR_NAME_TAGS: readonly ["locality", "subregion", "region", "country"]; /** * The nearest ancestor's `wof:name` per tag in {@linkcode ANCESTOR_NAME_TAGS}. * * A tag with no ancestor has no key. * `ancestry.find(…) === undefined` expresses that state. */ export type AncestorNames = Partial>; /** * The nearest ancestor record per tag in {@linkcode ANCESTOR_NAME_TAGS}. * * The admin adapter reads an ancestor's localized names from it. * Each value is a record the index already holds, so it copies no name. */ export type AncestorRecords = Partial>; /** * Each ancestor record's `wof:name`, per tag. * * `wof-postalcode` renders a postcode's hierarchy from these names and reads no other ancestor field. */ export declare function ancestorNamesOf(records: AncestorRecords): AncestorNames; /** * The nearest ancestor record per tag in {@linkcode ANCESTOR_NAME_TAGS} for one record. * * `lookup` returns a record the reader kept, or `undefined`. * `tagOf` maps a WOF placetype to a component tag, or returns a value outside * {@linkcode ANCESTOR_NAME_TAGS} for a placetype no builder looks up. * * It is a parameter because `placetypeToTag` lives with the adapters and this module doesn't import them. * * The `wof:hierarchy` levels are read first, then the parent chain. * The chain stops at the first id `lookup` cannot return, and at any re-visit. * Only a corrupt fixture holds a cycle. * * A record whose ancestors are absent resolves the tags it can reach rather than failing. * * An ancestor in another country claims no tag, unless its own ISO or HASC code leads with * the record's country, as France's region Guadeloupe (`GP`) does for a record in `GP`. * A row takes its country from the record, so any other such ancestor would write another country's * region under it: WOF files Monaco's quarters under Alpes-Maritimes and Macau's under Guangdong. */ export declare function ancestorRecordsOf(rec: WOFRecord, lookup: (id: number) => WOFRecord | undefined, tagOf: (placetype: string) => string | null | undefined): AncestorRecords; //# sourceMappingURL=wof-json.d.ts.map