/** * @copyright Sister Software * @license AGPL-3.0 * @author Teffen Ellis, et al. * * Fetch GeoNames per-country gazetteer dumps. These are the 19-column `.txt` files under * `https://download.geonames.org/export/dump/`, the export directory rather than the postal export * at `export/zip/` that `geonames-postal.ts` handles. The dumps contain feature classes and codes * (column 8: `pplc` national capital, `ppla` first-order administrative seat), which is what the * capitals reference build consumes. * * `countryInfo.txt` supplies the country catalog. It lists each country GeoNames publishes with one * row per ISO alpha-2 code. Each row also lists the capital. The capitals build checks it against * its `pplc` extraction. The tool fetches this file first and derives the country set from it. A dump * absent from disk then counts as a gap in the source's own catalog. * The dump directory may contain files this tool never fetched. The tool keeps present files unchanged. * It checks each present `.txt` for the 19-column gazetteer format. GeoNames postal exports share * the basename, so a postal export receives `wrong_format_present` and does not count as coverage. */ import type { BaseFetchOptions, FetchSummary } from "#tools/fetch/download"; export interface FetchGeonamesDumpOptions extends BaseFetchOptions { /** * ISO alpha-2 codes, any casing. * * Absent → every country `countryInfo.txt` enumerates. */ countries?: readonly string[]; /** * Dump directory to read from. * * Defaults to GeoNames' own. * Exists so the 404 and coverage behavior can be exercised against a local server. */ baseURL?: string; /** * Refetch a dump whose `.txt` already exists. * * Default false — the tool fills gaps. */ force?: boolean; } interface GeonamesDumpFileEntry { country: string; filename: string; source_url: string; sha256: string; bytes: number; } export interface GeonamesDumpManifest { source: string; base_url: string; license: string; attribution: string; downloaded_at: string; files: GeonamesDumpFileEntry[]; /** * `.txt` files already on disk and leaves unchanged — the hand-fetched population this tool extends. */ skipped_present: string[]; /** * Countries in the source catalog that the source's dump directory nonetheless 404s. * * A fact about the source, recorded so a later reader does not spend the fetch to rediscover it. */ unavailable: string[]; /** * Present `.txt` files that are not 19-column gazetteer dumps. * GeoNames' postal exports share the same basename. * * Left in place (this tool never overwrites data it did not fetch). * The fix is to move the file to its own home and rerun. */ wrong_format_present: string[]; } /** * True when the first non-empty line contains the gazetteer dump's 19 tab-separated columns. * * Accepts a partial head read. * The first line is the whole question, so callers need not hand it a resident 350 MB dump. * * Walk the string directly instead of constructing a spliterator. * The capitals builder already holds each country dump as a string. * * A byte-oriented spliterator would UTF-8 encode that input and allocate up to * another 350 MB just to inspect the first non-empty line. */ export declare function looksLikeGazetteerDump(text: string): boolean; /** * Parse the ISO codes (column 1) and capital names (column 6) out of `countryInfo.txt`. * `#`-prefixed lines are the file's own commentary. */ export declare function parseCountryInfo(text: string): Array<{ country: string; capital: string; }>; /** * Download `countryInfo.txt` and each missing `.zip`. * * Extract each dump to `/.txt` beside the hand-fetched files. * The `manifest.json` lists fetched countries. * * It also lists countries skipped because their files were already present * and countries unavailable from the source. */ export declare function fetchGeonamesDumps(options: FetchGeonamesDumpOptions, report?: (line: string) => void): Promise; export {}; //# sourceMappingURL=dump.d.ts.map