@mailwoman/resolver-wof-sqlite 9.0.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -9
- package/address-point-interpolation.ts +18 -8
- package/address-point-schema.ts +18 -6
- package/address-point.ts +111 -18
- package/ancestry.ts +9 -6
- package/build-candidate.ts +287 -157
- package/build-slim.ts +3 -3
- package/candidate/alias-bags.ts +54 -0
- package/candidate/ancestors-sidecar.ts +206 -0
- package/candidate/country-display-names.ts +79 -0
- package/candidate/name-roles.ts +237 -0
- package/candidate/own-name.ts +146 -0
- package/candidate/place-attrs.ts +44 -0
- package/candidate/shard-fold.ts +137 -0
- package/candidate-ancestors-schema.ts +195 -0
- package/candidate-fts.ts +4 -2
- package/candidate-importance.ts +228 -0
- package/candidate-lookup.ts +564 -174
- package/candidate-schema.ts +60 -3
- package/candidate-scoring.ts +268 -0
- package/capital-schema.ts +90 -0
- package/capitals.ts +148 -0
- package/coincident-roles.ts +69 -10
- package/convention-schema.ts +72 -0
- package/convention.ts +2 -2
- package/coverage-manifest-schema.ts +7 -7
- package/currency-backfill.ts +249 -0
- package/exact-match.ts +104 -0
- package/fst-autocomplete.ts +105 -122
- package/fst-builder.ts +39 -47
- package/fst-deserialize-web.ts +43 -7
- package/fst-freshness.ts +2 -2
- package/fst-serialize.ts +68 -12
- package/fst-types.ts +35 -1
- package/fts-query.ts +1 -1
- package/fts.ts +16 -4
- package/geonames-postal.ts +2 -2
- package/index.ts +26 -14
- package/interpolation.ts +113 -19
- package/lookup.ts +118 -560
- package/name-score.ts +6 -4
- package/out/address-point-interpolation.d.ts.map +1 -1
- package/out/address-point-interpolation.js +13 -7
- package/out/address-point-interpolation.js.map +1 -1
- package/out/address-point-schema.d.ts +16 -6
- package/out/address-point-schema.d.ts.map +1 -1
- package/out/address-point-schema.js.map +1 -1
- package/out/address-point.d.ts.map +1 -1
- package/out/address-point.js +70 -14
- package/out/address-point.js.map +1 -1
- package/out/ancestry.d.ts +2 -2
- package/out/ancestry.d.ts.map +1 -1
- package/out/ancestry.js +5 -6
- package/out/ancestry.js.map +1 -1
- package/out/build-candidate.d.ts +108 -0
- package/out/build-candidate.d.ts.map +1 -1
- package/out/build-candidate.js +151 -120
- package/out/build-candidate.js.map +1 -1
- package/out/build-slim.d.ts +1 -1
- package/out/build-slim.js +3 -3
- package/out/build-slim.js.map +1 -1
- package/out/candidate/alias-bags.d.ts +17 -0
- package/out/candidate/alias-bags.d.ts.map +1 -0
- package/out/candidate/alias-bags.js +39 -0
- package/out/candidate/alias-bags.js.map +1 -0
- package/out/candidate/ancestors-sidecar.d.ts +33 -0
- package/out/candidate/ancestors-sidecar.d.ts.map +1 -0
- package/out/candidate/ancestors-sidecar.js +140 -0
- package/out/candidate/ancestors-sidecar.js.map +1 -0
- package/out/candidate/country-display-names.d.ts +35 -0
- package/out/candidate/country-display-names.d.ts.map +1 -0
- package/out/candidate/country-display-names.js +59 -0
- package/out/candidate/country-display-names.js.map +1 -0
- package/out/candidate/name-roles.d.ts +55 -0
- package/out/candidate/name-roles.d.ts.map +1 -0
- package/out/candidate/name-roles.js +165 -0
- package/out/candidate/name-roles.js.map +1 -0
- package/out/candidate/own-name.d.ts +50 -0
- package/out/candidate/own-name.d.ts.map +1 -0
- package/out/candidate/own-name.js +132 -0
- package/out/candidate/own-name.js.map +1 -0
- package/out/candidate/place-attrs.d.ts +43 -0
- package/out/candidate/place-attrs.d.ts.map +1 -0
- package/out/candidate/place-attrs.js +15 -0
- package/out/candidate/place-attrs.js.map +1 -0
- package/out/candidate/shard-fold.d.ts +31 -0
- package/out/candidate/shard-fold.d.ts.map +1 -0
- package/out/candidate/shard-fold.js +104 -0
- package/out/candidate/shard-fold.js.map +1 -0
- package/out/candidate-ancestors-schema.d.ts +150 -0
- package/out/candidate-ancestors-schema.d.ts.map +1 -0
- package/out/candidate-ancestors-schema.js +123 -0
- package/out/candidate-ancestors-schema.js.map +1 -0
- package/out/candidate-fts.d.ts +4 -2
- package/out/candidate-fts.d.ts.map +1 -1
- package/out/candidate-fts.js +4 -2
- package/out/candidate-fts.js.map +1 -1
- package/out/candidate-importance.d.ts +132 -0
- package/out/candidate-importance.d.ts.map +1 -0
- package/out/candidate-importance.js +174 -0
- package/out/candidate-importance.js.map +1 -0
- package/out/candidate-lookup.d.ts +22 -37
- package/out/candidate-lookup.d.ts.map +1 -1
- package/out/candidate-lookup.js +446 -132
- package/out/candidate-lookup.js.map +1 -1
- package/out/candidate-schema.d.ts +52 -4
- package/out/candidate-schema.d.ts.map +1 -1
- package/out/candidate-schema.js +8 -0
- package/out/candidate-schema.js.map +1 -1
- package/out/candidate-scoring.d.ts +34 -0
- package/out/candidate-scoring.d.ts.map +1 -0
- package/out/candidate-scoring.js +200 -0
- package/out/candidate-scoring.js.map +1 -0
- package/out/capital-schema.d.ts +51 -0
- package/out/capital-schema.d.ts.map +1 -0
- package/out/capital-schema.js +63 -0
- package/out/capital-schema.js.map +1 -0
- package/out/capitals.d.ts +69 -0
- package/out/capitals.d.ts.map +1 -0
- package/out/capitals.js +98 -0
- package/out/capitals.js.map +1 -0
- package/out/coincident-roles.d.ts +7 -0
- package/out/coincident-roles.d.ts.map +1 -1
- package/out/coincident-roles.js +42 -8
- package/out/coincident-roles.js.map +1 -1
- package/out/convention-schema.d.ts +51 -0
- package/out/convention-schema.d.ts.map +1 -0
- package/out/convention-schema.js +34 -0
- package/out/convention-schema.js.map +1 -0
- package/out/convention.d.ts +1 -1
- package/out/convention.js +2 -2
- package/out/coverage-manifest-schema.js +3 -7
- package/out/coverage-manifest-schema.js.map +1 -1
- package/out/currency-backfill.d.ts +46 -0
- package/out/currency-backfill.d.ts.map +1 -0
- package/out/currency-backfill.js +180 -0
- package/out/currency-backfill.js.map +1 -0
- package/out/exact-match.d.ts +25 -0
- package/out/exact-match.d.ts.map +1 -0
- package/out/exact-match.js +89 -0
- package/out/exact-match.js.map +1 -0
- package/out/fst-autocomplete.d.ts +24 -14
- package/out/fst-autocomplete.d.ts.map +1 -1
- package/out/fst-autocomplete.js +84 -100
- package/out/fst-autocomplete.js.map +1 -1
- package/out/fst-builder.d.ts.map +1 -1
- package/out/fst-builder.js +32 -40
- package/out/fst-builder.js.map +1 -1
- package/out/fst-deserialize-web.d.ts.map +1 -1
- package/out/fst-deserialize-web.js +36 -7
- package/out/fst-deserialize-web.js.map +1 -1
- package/out/fst-freshness.d.ts +2 -2
- package/out/fst-freshness.js +2 -2
- package/out/fst-serialize.d.ts +14 -4
- package/out/fst-serialize.d.ts.map +1 -1
- package/out/fst-serialize.js +60 -12
- package/out/fst-serialize.js.map +1 -1
- package/out/fst-types.d.ts +35 -1
- package/out/fst-types.d.ts.map +1 -1
- package/out/fts-query.js +1 -1
- package/out/fts-query.js.map +1 -1
- package/out/fts.d.ts +15 -4
- package/out/fts.d.ts.map +1 -1
- package/out/fts.js +15 -4
- package/out/fts.js.map +1 -1
- package/out/geonames-postal.d.ts +2 -2
- package/out/geonames-postal.js +2 -2
- package/out/index.d.ts +4 -2
- package/out/index.d.ts.map +1 -1
- package/out/index.js +3 -2
- package/out/index.js.map +1 -1
- package/out/interpolation.d.ts +8 -0
- package/out/interpolation.d.ts.map +1 -1
- package/out/interpolation.js +91 -19
- package/out/interpolation.js.map +1 -1
- package/out/lookup.d.ts +4 -5
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +102 -444
- package/out/lookup.js.map +1 -1
- package/out/name-score.d.ts +0 -10
- package/out/name-score.d.ts.map +1 -1
- package/out/name-score.js +6 -4
- package/out/name-score.js.map +1 -1
- package/out/place-importance-schema.d.ts +226 -0
- package/out/place-importance-schema.d.ts.map +1 -0
- package/out/place-importance-schema.js +288 -0
- package/out/place-importance-schema.js.map +1 -0
- package/out/poi-lookup.d.ts +1 -1
- package/out/poi-lookup.d.ts.map +1 -1
- package/out/poi-lookup.js +12 -13
- package/out/poi-lookup.js.map +1 -1
- package/out/poi-schema.d.ts +7 -3
- package/out/poi-schema.d.ts.map +1 -1
- package/out/poi-schema.js.map +1 -1
- package/out/polygon-schema.d.ts +37 -0
- package/out/polygon-schema.d.ts.map +1 -0
- package/out/polygon-schema.js +23 -0
- package/out/polygon-schema.js.map +1 -0
- package/out/postal-city-alias-lookup.d.ts +1 -1
- package/out/postal-city-alias-lookup.js +1 -1
- package/out/postal-city-candidate-schema.d.ts +2 -1
- package/out/postal-city-candidate-schema.d.ts.map +1 -1
- package/out/postal-city-candidate-schema.js.map +1 -1
- package/out/postcode-point-lookup.d.ts +1 -1
- package/out/postcode-point-lookup.js +1 -1
- package/out/primary-preference.d.ts +125 -0
- package/out/primary-preference.d.ts.map +1 -0
- package/out/primary-preference.js +138 -0
- package/out/primary-preference.js.map +1 -0
- package/out/proximity-rerank.d.ts +77 -0
- package/out/proximity-rerank.d.ts.map +1 -0
- package/out/proximity-rerank.js +86 -0
- package/out/proximity-rerank.js.map +1 -0
- package/out/region-keys.d.ts +47 -0
- package/out/region-keys.d.ts.map +1 -0
- package/out/region-keys.js +121 -0
- package/out/region-keys.js.map +1 -0
- package/out/reverse.d.ts.map +1 -1
- package/out/reverse.js +6 -9
- package/out/reverse.js.map +1 -1
- package/out/schema.d.ts +1 -1
- package/out/search-fetch.d.ts +57 -0
- package/out/search-fetch.d.ts.map +1 -0
- package/out/search-fetch.js +183 -0
- package/out/search-fetch.js.map +1 -0
- package/out/sharding.d.ts +3 -3
- package/out/sharding.js +1 -1
- package/out/sqlite-convention-source.d.ts +1 -1
- package/out/sqlite-convention-source.js +1 -1
- package/out/sqlite-utils.d.ts +31 -1
- package/out/sqlite-utils.d.ts.map +1 -1
- package/out/sqlite-utils.js +38 -0
- package/out/sqlite-utils.js.map +1 -1
- package/out/street-centroid-schema.d.ts +7 -2
- package/out/street-centroid-schema.d.ts.map +1 -1
- package/out/street-centroid-schema.js.map +1 -1
- package/out/street-centroid.d.ts.map +1 -1
- package/out/street-centroid.js +7 -7
- package/out/street-centroid.js.map +1 -1
- package/out/street-morphology-fst-builder.d.ts.map +1 -1
- package/out/street-morphology-fst-builder.js +5 -4
- package/out/street-morphology-fst-builder.js.map +1 -1
- package/out/street-normalize.d.ts +83 -9
- package/out/street-normalize.d.ts.map +1 -1
- package/out/street-normalize.js +177 -10
- package/out/street-normalize.js.map +1 -1
- package/out/street-segment-schema.d.ts +6 -2
- package/out/street-segment-schema.d.ts.map +1 -1
- package/out/street-segment-schema.js.map +1 -1
- package/out/types.d.ts +74 -1
- package/out/types.d.ts.map +1 -1
- package/out/unified-schema.d.ts +1 -1
- package/out/unified-schema.js +1 -1
- package/out/uprn-lookup.d.ts +85 -0
- package/out/uprn-lookup.d.ts.map +1 -0
- package/out/uprn-lookup.js +152 -0
- package/out/uprn-lookup.js.map +1 -0
- package/out/uprn-schema.d.ts +93 -0
- package/out/uprn-schema.d.ts.map +1 -0
- package/out/uprn-schema.js +78 -0
- package/out/uprn-schema.js.map +1 -0
- package/out/weights-overlay-linker.d.ts +141 -0
- package/out/weights-overlay-linker.d.ts.map +1 -0
- package/out/weights-overlay-linker.js +259 -0
- package/out/weights-overlay-linker.js.map +1 -0
- package/package.json +296 -16
- package/place-importance-schema.ts +402 -0
- package/poi-lookup.ts +12 -13
- package/poi-schema.ts +8 -3
- package/polygon-schema.ts +47 -0
- package/postal-city-alias-lookup.ts +1 -1
- package/postal-city-candidate-schema.ts +3 -1
- package/postcode-point-lookup.ts +1 -1
- package/primary-preference.ts +207 -0
- package/proximity-rerank.ts +120 -0
- package/region-keys.ts +144 -0
- package/reverse.ts +17 -16
- package/schema.ts +1 -1
- package/search-fetch.ts +256 -0
- package/sharding.ts +3 -3
- package/sqlite-convention-source.ts +1 -1
- package/sqlite-utils.ts +63 -1
- package/street-centroid-schema.ts +8 -2
- package/street-centroid.ts +13 -8
- package/street-morphology-fst-builder.ts +5 -4
- package/street-normalize.ts +254 -24
- package/street-segment-schema.ts +7 -2
- package/types.ts +74 -1
- package/unified-schema.ts +1 -1
- package/uprn-lookup.ts +210 -0
- package/uprn-schema.ts +124 -0
- package/weights-overlay-linker.ts +377 -0
- package/geo.ts +0 -121
- package/out/geo.d.ts +0 -74
- package/out/geo.d.ts.map +0 -1
- package/out/geo.js +0 -71
- package/out/geo.js.map +0 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The CAPITAL-STATUS reference index (#1880) — answers, for one resolved candidate, "is this
|
|
7
|
+
* place the national capital or an admin-1 seat of its country?". The consumer is the resolver's
|
|
8
|
+
* bounded capital promotion (`@mailwoman/resolver`'s `promoteCapitals`, applied after the fame
|
|
9
|
+
* key on the bare-toponym class); this module only matches, it never ranks. PURE and
|
|
10
|
+
* platform-free (the #861 parity discipline).
|
|
11
|
+
*
|
|
12
|
+
* Matching is an IDENTITY test with three conjuncts: same country, within
|
|
13
|
+
* {@link CAPITAL_MATCH_RADIUS_KM} of the reference point, and the candidate's own folded name a
|
|
14
|
+
* member of the reference entry's folded name set (name + romanization + the source's alternate
|
|
15
|
+
* names, so exonym rows — "Vienna" for Wien — still match). All three are load-bearing. The
|
|
16
|
+
* iteration-1 board run matched on country + coordinate alone, and the 25 km radius promoted
|
|
17
|
+
* capital-ADJACENT namesakes instead of capitals: North Salt Lake beside the Utah seat, a Gujarat
|
|
18
|
+
* Indiranagar beside Gandhinagar, Via delle Parti beside Perugia. The name set is what makes the
|
|
19
|
+
* radius a centroid-drift allowance rather than a catchment.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Capital status of one candidate: national capital, admin-1 seat, or neither. Numeric so the resolver's promotion can
|
|
23
|
+
* compare levels.
|
|
24
|
+
*/
|
|
25
|
+
export declare const CAPITAL_LEVEL: {
|
|
26
|
+
readonly none: 0;
|
|
27
|
+
readonly admin1: 1;
|
|
28
|
+
readonly national: 2;
|
|
29
|
+
};
|
|
30
|
+
export type CapitalLevel = (typeof CAPITAL_LEVEL)[keyof typeof CAPITAL_LEVEL];
|
|
31
|
+
/**
|
|
32
|
+
* How far a candidate row may sit from the reference point and still read as the same place — a centroid-convention
|
|
33
|
+
* allowance (GeoNames point vs WOF centroid on a metro-scale city), not a catchment: the name-membership conjunct is
|
|
34
|
+
* what excludes neighbours inside the radius.
|
|
35
|
+
*/
|
|
36
|
+
export declare const CAPITAL_MATCH_RADIUS_KM = 25;
|
|
37
|
+
/**
|
|
38
|
+
* One reference entry, as `data/gazetteer/capitals-v1.json` carries it (`entries[]`).
|
|
39
|
+
*/
|
|
40
|
+
export interface CapitalPoint {
|
|
41
|
+
/**
|
|
42
|
+
* ISO alpha-2, uppercase.
|
|
43
|
+
*/
|
|
44
|
+
country: string;
|
|
45
|
+
latitude: number;
|
|
46
|
+
longitude: number;
|
|
47
|
+
level: "national" | "admin1";
|
|
48
|
+
/**
|
|
49
|
+
* Folded name keys (name + romanization + alternate names, `normalizeLocalityForKey` fold) — the membership set for
|
|
50
|
+
* the name conjunct.
|
|
51
|
+
*/
|
|
52
|
+
k: string[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Country-bucketed capital points with the three-conjunct identity probe. Construct from the parsed reference file's
|
|
56
|
+
* `entries` — the loader that reads the file off disk lives with the path owners (`mailwoman`'s resolver backend),
|
|
57
|
+
* keeping this module platform-free.
|
|
58
|
+
*/
|
|
59
|
+
export declare class CapitalIndex {
|
|
60
|
+
#private;
|
|
61
|
+
constructor(entries: Iterable<CapitalPoint>);
|
|
62
|
+
/**
|
|
63
|
+
* The highest capital level whose entry passes all three conjuncts for this place. `none` — never a throw — for a
|
|
64
|
+
* missing name, country, or coordinate, an unknown country, or no matching entry.
|
|
65
|
+
*/
|
|
66
|
+
levelOfPlace(name: string | null | undefined, country: string | null | undefined, latitude: number | null | undefined, longitude: number | null | undefined): CapitalLevel;
|
|
67
|
+
get size(): number;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=capitals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capitals.d.ts","sourceRoot":"","sources":["../capitals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;CAIhB,CAAA;AAEV,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAA;AAE7E;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAA;AAEzC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,UAAU,GAAG,QAAQ,CAAA;IAC5B;;;OAGG;IACH,CAAC,EAAE,MAAM,EAAE,CAAA;CACX;AAcD;;;;GAIG;AACH,qBAAa,YAAY;;gBAGZ,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC;IAqB3C;;;OAGG;IACH,YAAY,CACX,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAClC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAClC,YAAY;IA0Bf,IAAI,IAAI,IAAI,MAAM,CAQjB;CACD"}
|
package/out/capitals.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The CAPITAL-STATUS reference index (#1880) — answers, for one resolved candidate, "is this
|
|
7
|
+
* place the national capital or an admin-1 seat of its country?". The consumer is the resolver's
|
|
8
|
+
* bounded capital promotion (`@mailwoman/resolver`'s `promoteCapitals`, applied after the fame
|
|
9
|
+
* key on the bare-toponym class); this module only matches, it never ranks. PURE and
|
|
10
|
+
* platform-free (the #861 parity discipline).
|
|
11
|
+
*
|
|
12
|
+
* Matching is an IDENTITY test with three conjuncts: same country, within
|
|
13
|
+
* {@link CAPITAL_MATCH_RADIUS_KM} of the reference point, and the candidate's own folded name a
|
|
14
|
+
* member of the reference entry's folded name set (name + romanization + the source's alternate
|
|
15
|
+
* names, so exonym rows — "Vienna" for Wien — still match). All three are load-bearing. The
|
|
16
|
+
* iteration-1 board run matched on country + coordinate alone, and the 25 km radius promoted
|
|
17
|
+
* capital-ADJACENT namesakes instead of capitals: North Salt Lake beside the Utah seat, a Gujarat
|
|
18
|
+
* Indiranagar beside Gandhinagar, Via delle Parti beside Perugia. The name set is what makes the
|
|
19
|
+
* radius a centroid-drift allowance rather than a catchment.
|
|
20
|
+
*/
|
|
21
|
+
import { haversineKm } from "@mailwoman/spatial";
|
|
22
|
+
import { normalizeLocalityForKey } from "./street-normalize.js";
|
|
23
|
+
/**
|
|
24
|
+
* Capital status of one candidate: national capital, admin-1 seat, or neither. Numeric so the resolver's promotion can
|
|
25
|
+
* compare levels.
|
|
26
|
+
*/
|
|
27
|
+
export const CAPITAL_LEVEL = {
|
|
28
|
+
none: 0,
|
|
29
|
+
admin1: 1,
|
|
30
|
+
national: 2,
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* How far a candidate row may sit from the reference point and still read as the same place — a centroid-convention
|
|
34
|
+
* allowance (GeoNames point vs WOF centroid on a metro-scale city), not a catchment: the name-membership conjunct is
|
|
35
|
+
* what excludes neighbours inside the radius.
|
|
36
|
+
*/
|
|
37
|
+
export const CAPITAL_MATCH_RADIUS_KM = 25;
|
|
38
|
+
const LEVEL_OF = {
|
|
39
|
+
national: CAPITAL_LEVEL.national,
|
|
40
|
+
admin1: CAPITAL_LEVEL.admin1,
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Country-bucketed capital points with the three-conjunct identity probe. Construct from the parsed reference file's
|
|
44
|
+
* `entries` — the loader that reads the file off disk lives with the path owners (`mailwoman`'s resolver backend),
|
|
45
|
+
* keeping this module platform-free.
|
|
46
|
+
*/
|
|
47
|
+
export class CapitalIndex {
|
|
48
|
+
#byCountry = new Map();
|
|
49
|
+
constructor(entries) {
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
const country = entry.country.toUpperCase();
|
|
52
|
+
const point = {
|
|
53
|
+
latitude: entry.latitude,
|
|
54
|
+
longitude: entry.longitude,
|
|
55
|
+
level: LEVEL_OF[entry.level],
|
|
56
|
+
keys: new Set(entry.k),
|
|
57
|
+
};
|
|
58
|
+
const bucket = this.#byCountry.get(country);
|
|
59
|
+
if (bucket) {
|
|
60
|
+
bucket.push(point);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
this.#byCountry.set(country, [point]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The highest capital level whose entry passes all three conjuncts for this place. `none` — never a throw — for a
|
|
69
|
+
* missing name, country, or coordinate, an unknown country, or no matching entry.
|
|
70
|
+
*/
|
|
71
|
+
levelOfPlace(name, country, latitude, longitude) {
|
|
72
|
+
if (!name || !country || typeof latitude !== "number" || typeof longitude !== "number")
|
|
73
|
+
return CAPITAL_LEVEL.none;
|
|
74
|
+
const bucket = this.#byCountry.get(country.toUpperCase());
|
|
75
|
+
if (!bucket)
|
|
76
|
+
return CAPITAL_LEVEL.none;
|
|
77
|
+
const key = String(normalizeLocalityForKey(name));
|
|
78
|
+
if (!key)
|
|
79
|
+
return CAPITAL_LEVEL.none;
|
|
80
|
+
let best = CAPITAL_LEVEL.none;
|
|
81
|
+
for (const point of bucket) {
|
|
82
|
+
if (point.level > best &&
|
|
83
|
+
point.keys.has(key) &&
|
|
84
|
+
haversineKm(latitude, longitude, point.latitude, point.longitude) <= CAPITAL_MATCH_RADIUS_KM) {
|
|
85
|
+
best = point.level;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return best;
|
|
89
|
+
}
|
|
90
|
+
get size() {
|
|
91
|
+
let n = 0;
|
|
92
|
+
for (const bucket of this.#byCountry.values()) {
|
|
93
|
+
n += bucket.length;
|
|
94
|
+
}
|
|
95
|
+
return n;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=capitals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capitals.js","sourceRoot":"","sources":["../capitals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;CACF,CAAA;AAIV;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAA;AAoBzC,MAAM,QAAQ,GAAgD;IAC7D,QAAQ,EAAE,aAAa,CAAC,QAAQ;IAChC,MAAM,EAAE,aAAa,CAAC,MAAM;CAC5B,CAAA;AASD;;;;GAIG;AACH,MAAM,OAAO,YAAY;IACf,UAAU,GAAG,IAAI,GAAG,EAA0B,CAAA;IAEvD,YAAY,OAA+B;QAC1C,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAA;YAE3C,MAAM,KAAK,GAAiB;gBAC3B,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;gBAC5B,IAAI,EAAE,IAAI,GAAG,CAAC,KAAK,CAA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OAAO,IAAI,CAAA;IACZ,CAAC;IAED,IAAI,IAAI;QACP,IAAI,CAAC,GAAG,CAAC,CAAA;QAET,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;YAC/C,CAAC,IAAI,MAAM,CAAC,MAAM,CAAA;QACnB,CAAC;QAED,OAAO,CAAC,CAAA;IACT,CAAC;CACD"}
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
* be wired as a post-step of the main `scripts/build-unified-wof.ts`.
|
|
39
39
|
*/
|
|
40
40
|
import type { DatabaseSync } from "node:sqlite";
|
|
41
|
+
import type { CoincidentLocality } from "@mailwoman/resolver";
|
|
41
42
|
/**
|
|
42
43
|
* Table of places that hold more than one admin role — a locality that is also its county seat. Written by the
|
|
43
44
|
* gazetteer build, read by the resolver when a coincident locality has to be chosen.
|
|
@@ -93,4 +94,10 @@ export declare function coincidentRolesExists(db: DatabaseSync): boolean;
|
|
|
93
94
|
* map when the table is absent.
|
|
94
95
|
*/
|
|
95
96
|
export declare function loadCoincidentRoles(db: DatabaseSync): Map<number, CoincidentRole[]>;
|
|
97
|
+
/**
|
|
98
|
+
* The relation joined with `spr`, as an in-memory map keyed by `admin_id` — the resolver-facing view of
|
|
99
|
+
* {@link loadCoincidentRoles}, carrying the canonical name and coordinates each coincident locality resolves to.
|
|
100
|
+
* Returns an empty map when the relation table is absent.
|
|
101
|
+
*/
|
|
102
|
+
export declare function loadCoincidentLocalities(db: DatabaseSync): Map<number, CoincidentLocality[]>;
|
|
96
103
|
//# sourceMappingURL=coincident-roles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coincident-roles.d.ts","sourceRoot":"","sources":["../coincident-roles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"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,mBAAmB,CAAC,EAAE,EAAE,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAsCnF;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAiD5F"}
|
package/out/coincident-roles.js
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
* be wired as a post-step of the main `scripts/build-unified-wof.ts`.
|
|
39
39
|
*/
|
|
40
40
|
import { haversineKm } from "@mailwoman/spatial";
|
|
41
|
+
import { allRows } from "./sqlite-utils.js";
|
|
41
42
|
/**
|
|
42
43
|
* Table of places that hold more than one admin role — a locality that is also its county seat. Written by the
|
|
43
44
|
* gazetteer build, read by the resolver when a coincident locality has to be chosen.
|
|
@@ -81,8 +82,7 @@ export function buildCoincidentRoles(db, opts = {}) {
|
|
|
81
82
|
// Admin (region/county tier) ⋈ same-name DESCENDANT locality. `place_population` is optional (LEFT
|
|
82
83
|
// JOIN → 0 when absent). The relative-tolerance filter + relationship classification happen in JS so
|
|
83
84
|
// the SQL stays a plain join. `spr` exposes the bbox columns we need for the diagonal.
|
|
84
|
-
const candidates = db
|
|
85
|
-
.prepare(`SELECT r.id AS admin_id, r.placetype AS admin_placetype, r.country AS country, l.id AS locality_id,
|
|
85
|
+
const candidates = allRows(db.prepare(`SELECT r.id AS admin_id, r.placetype AS admin_placetype, r.country AS country, l.id AS locality_id,
|
|
86
86
|
r.latitude AS rlat, r.longitude AS rlon, l.latitude AS llat, l.longitude AS llon,
|
|
87
87
|
r.min_latitude, r.min_longitude, r.max_latitude, r.max_longitude,
|
|
88
88
|
COALESCE(p.population, 0) AS pop
|
|
@@ -92,8 +92,7 @@ export function buildCoincidentRoles(db, opts = {}) {
|
|
|
92
92
|
JOIN ${"ancestors"} a ON a.id = l.id AND a.ancestor_id = r.id
|
|
93
93
|
LEFT JOIN place_population p ON p.id = l.id
|
|
94
94
|
WHERE r.placetype = 'region'
|
|
95
|
-
AND r.is_current != 0 AND r.is_deprecated = 0`)
|
|
96
|
-
.all();
|
|
95
|
+
AND r.is_current != 0 AND r.is_deprecated = 0`));
|
|
97
96
|
onProgress("filtering", `${candidates.length} candidates`);
|
|
98
97
|
const insert = db.prepare(`INSERT OR REPLACE INTO ${COINCIDENT_ROLES_TABLE}
|
|
99
98
|
(admin_id, locality_id, relationship_type, admin_placetype, distance_km, locality_population)
|
|
@@ -143,10 +142,8 @@ export function loadCoincidentRoles(db) {
|
|
|
143
142
|
const map = new Map();
|
|
144
143
|
if (!coincidentRolesExists(db))
|
|
145
144
|
return map;
|
|
146
|
-
const rows = db
|
|
147
|
-
|
|
148
|
-
FROM ${COINCIDENT_ROLES_TABLE}`)
|
|
149
|
-
.all();
|
|
145
|
+
const rows = allRows(db.prepare(`SELECT admin_id, locality_id, relationship_type, admin_placetype, distance_km, locality_population
|
|
146
|
+
FROM ${COINCIDENT_ROLES_TABLE}`));
|
|
150
147
|
for (const r of rows) {
|
|
151
148
|
const entry = {
|
|
152
149
|
localityID: r.locality_id,
|
|
@@ -165,4 +162,41 @@ export function loadCoincidentRoles(db) {
|
|
|
165
162
|
}
|
|
166
163
|
return map;
|
|
167
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* The relation joined with `spr`, as an in-memory map keyed by `admin_id` — the resolver-facing view of
|
|
167
|
+
* {@link loadCoincidentRoles}, carrying the canonical name and coordinates each coincident locality resolves to.
|
|
168
|
+
* Returns an empty map when the relation table is absent.
|
|
169
|
+
*/
|
|
170
|
+
export function loadCoincidentLocalities(db) {
|
|
171
|
+
const map = new Map();
|
|
172
|
+
if (coincidentRolesExists(db)) {
|
|
173
|
+
const rows = allRows(db.prepare(`SELECT cr.admin_id AS adminID, s.id AS id, s.name AS name, s.country AS country,
|
|
174
|
+
s.latitude AS lat, s.longitude AS lon,
|
|
175
|
+
cr.relationship_type AS relationshipType, cr.locality_population AS population,
|
|
176
|
+
cr.distance_km AS distanceKm
|
|
177
|
+
FROM ${COINCIDENT_ROLES_TABLE} cr JOIN spr s ON s.id = cr.locality_id`));
|
|
178
|
+
for (const r of rows) {
|
|
179
|
+
const candidate = {
|
|
180
|
+
id: r.id,
|
|
181
|
+
name: r.name,
|
|
182
|
+
placetype: "locality",
|
|
183
|
+
country: r.country,
|
|
184
|
+
lat: r.lat,
|
|
185
|
+
lon: r.lon,
|
|
186
|
+
score: 0,
|
|
187
|
+
relationshipType: r.relationshipType,
|
|
188
|
+
population: r.population,
|
|
189
|
+
distanceKm: r.distanceKm,
|
|
190
|
+
};
|
|
191
|
+
const list = map.get(r.adminID);
|
|
192
|
+
if (list) {
|
|
193
|
+
list.push(candidate);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
map.set(r.adminID, [candidate]);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return map;
|
|
201
|
+
}
|
|
168
202
|
//# sourceMappingURL=coincident-roles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coincident-roles.js","sourceRoot":"","sources":["../coincident-roles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;
|
|
1
|
+
{"version":3,"file":"coincident-roles.js","sourceRoot":"","sources":["../coincident-roles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAKH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE3C;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAA;AAwDxD,SAAS,WAAW,CAAC,EAAgB,EAAE,IAAY;IAClD,OAAO,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,6DAA6D,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC7F,CAAC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set — the `address_convention` table `SqliteConventionSource` probes, plus the
|
|
7
|
+
* `meta` provenance row every sealed artifact here carries. The interface is the read/write contract and
|
|
8
|
+
* {@link createAddressConventionTable} creates the table, so a column added to one is a compile error against the
|
|
9
|
+
* other.
|
|
10
|
+
*/
|
|
11
|
+
import type { Kysely } from "kysely";
|
|
12
|
+
/**
|
|
13
|
+
* One convention profile, keyed by the WOF admin polygon it attaches to.
|
|
14
|
+
*/
|
|
15
|
+
export interface AddressConventionTable {
|
|
16
|
+
wof_id: number;
|
|
17
|
+
/**
|
|
18
|
+
* The `Convention` record, JSON-encoded. Parsed at read time by `SqliteConventionSource`.
|
|
19
|
+
*/
|
|
20
|
+
convention: string;
|
|
21
|
+
/**
|
|
22
|
+
* Provenance: why this row exists and where it came from.
|
|
23
|
+
*/
|
|
24
|
+
source: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Key/value provenance for the sealed artifact.
|
|
28
|
+
*/
|
|
29
|
+
export interface ConventionMetaTable {
|
|
30
|
+
key: string;
|
|
31
|
+
value: string | null;
|
|
32
|
+
}
|
|
33
|
+
export interface ConventionDatabase {
|
|
34
|
+
address_convention: AddressConventionTable;
|
|
35
|
+
meta: ConventionMetaTable;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The slice of a Kysely handle the convention DDL touches. Kysely is invariant in its schema parameter, so naming only
|
|
39
|
+
* `schema` lets a builder holding a wider handle pass it without a cast.
|
|
40
|
+
*/
|
|
41
|
+
export type ConventionSchemaHandle = Pick<Kysely<ConventionDatabase>, "schema">;
|
|
42
|
+
/**
|
|
43
|
+
* Create `address_convention`. The table name comes from {@link ADDRESS_CONVENTION_TABLE} so the build script, the
|
|
44
|
+
* runtime source, and the shard auto-detect cannot drift apart.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createAddressConventionTable(db: ConventionSchemaHandle): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Create the artifact's `meta` table.
|
|
49
|
+
*/
|
|
50
|
+
export declare function createConventionMetaTable(db: ConventionSchemaHandle): Promise<void>;
|
|
51
|
+
//# sourceMappingURL=convention-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convention-schema.d.ts","sourceRoot":"","sources":["../convention-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAIpC;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB;AAED,MAAM,WAAW,kBAAkB;IAClC,kBAAkB,EAAE,sBAAsB,CAAA;IAC1C,IAAI,EAAE,mBAAmB,CAAA;CACzB;AAED;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,QAAQ,CAAC,CAAA;AAE/E;;;GAGG;AACH,wBAAsB,4BAA4B,CAAC,EAAE,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAO5F;AAED;;GAEG;AACH,wBAAsB,yBAAyB,CAAC,EAAE,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Typed schema for the convention asset — the `address_convention` table `SqliteConventionSource` probes, plus the
|
|
7
|
+
* `meta` provenance row every sealed artifact here carries. The interface is the read/write contract and
|
|
8
|
+
* {@link createAddressConventionTable} creates the table, so a column added to one is a compile error against the
|
|
9
|
+
* other.
|
|
10
|
+
*/
|
|
11
|
+
import { ADDRESS_CONVENTION_TABLE } from "./convention.js";
|
|
12
|
+
/**
|
|
13
|
+
* Create `address_convention`. The table name comes from {@link ADDRESS_CONVENTION_TABLE} so the build script, the
|
|
14
|
+
* runtime source, and the shard auto-detect cannot drift apart.
|
|
15
|
+
*/
|
|
16
|
+
export async function createAddressConventionTable(db) {
|
|
17
|
+
await db.schema
|
|
18
|
+
.createTable(ADDRESS_CONVENTION_TABLE)
|
|
19
|
+
.addColumn("wof_id", "integer", (column) => column.primaryKey())
|
|
20
|
+
.addColumn("convention", "text", (column) => column.notNull())
|
|
21
|
+
.addColumn("source", "text", (column) => column.notNull())
|
|
22
|
+
.execute();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create the artifact's `meta` table.
|
|
26
|
+
*/
|
|
27
|
+
export async function createConventionMetaTable(db) {
|
|
28
|
+
await db.schema
|
|
29
|
+
.createTable("meta")
|
|
30
|
+
.addColumn("key", "text", (column) => column.primaryKey())
|
|
31
|
+
.addColumn("value", "text")
|
|
32
|
+
.execute();
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=convention-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convention-schema.js","sourceRoot":"","sources":["../convention-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAoC1D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,EAA0B;IAC5E,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,wBAAwB,CAAC;SACrC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;SAC/D,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;SAC7D,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;SACzD,OAAO,EAAE,CAAA;AACZ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAA0B;IACzE,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,MAAM,CAAC;SACnB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;SACzD,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;SAC1B,OAAO,EAAE,CAAA;AACZ,CAAC"}
|
package/out/convention.d.ts
CHANGED
|
@@ -102,5 +102,5 @@ export declare function mergeConventions(base: Convention, ...overrides: Array<C
|
|
|
102
102
|
* region, …, locality). Starts from `WORLD_DEFAULT` so every field is defined regardless of which (if any) ancestors
|
|
103
103
|
* carry an override.
|
|
104
104
|
*/
|
|
105
|
-
export declare function resolveConvention(source: ConventionSource,
|
|
105
|
+
export declare function resolveConvention(source: ConventionSource, ancestorIDs: readonly number[]): ResolvedConvention;
|
|
106
106
|
//# sourceMappingURL=convention.d.ts.map
|
package/out/convention.js
CHANGED
|
@@ -81,8 +81,8 @@ export function mergeConventions(base, ...overrides) {
|
|
|
81
81
|
* region, …, locality). Starts from `WORLD_DEFAULT` so every field is defined regardless of which (if any) ancestors
|
|
82
82
|
* carry an override.
|
|
83
83
|
*/
|
|
84
|
-
export function resolveConvention(source,
|
|
85
|
-
const layers =
|
|
84
|
+
export function resolveConvention(source, ancestorIDs) {
|
|
85
|
+
const layers = ancestorIDs.map((id) => source.get(id));
|
|
86
86
|
const merged = mergeConventions(WORLD_DEFAULT, ...layers);
|
|
87
87
|
return {
|
|
88
88
|
candidateStrategies: merged.candidateStrategies ?? WORLD_DEFAULT.candidateStrategies,
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import { hardCountrySafelistFromCoverage, } from "@mailwoman/core/resolver";
|
|
26
26
|
import { sql } from "kysely";
|
|
27
|
-
import { hasTable } from "./sqlite-utils.js";
|
|
27
|
+
import { allRows, hasTable } from "./sqlite-utils.js";
|
|
28
28
|
/**
|
|
29
29
|
* Table names the lookup probes (existence-gated, so a candidate.db built before the manifest is byte-stable).
|
|
30
30
|
*/
|
|
@@ -113,9 +113,7 @@ export function readGazetteerCoverageManifest(db) {
|
|
|
113
113
|
return undefined;
|
|
114
114
|
const countryCoverage = new Map();
|
|
115
115
|
if (hasCoverage) {
|
|
116
|
-
const rows = db
|
|
117
|
-
.prepare(`SELECT country, hard_filter_safe, hard_resolve_rate, sample_size, measured_at, source FROM ${COUNTRY_COVERAGE_TABLE}`)
|
|
118
|
-
.all();
|
|
116
|
+
const rows = allRows(db.prepare(`SELECT country, hard_filter_safe, hard_resolve_rate, sample_size, measured_at, source FROM ${COUNTRY_COVERAGE_TABLE}`));
|
|
119
117
|
for (const row of rows) {
|
|
120
118
|
const country = String(row.country).toUpperCase();
|
|
121
119
|
countryCoverage.set(country, {
|
|
@@ -130,9 +128,7 @@ export function readGazetteerCoverageManifest(db) {
|
|
|
130
128
|
}
|
|
131
129
|
const countryBBoxes = new Map();
|
|
132
130
|
if (hasBBox) {
|
|
133
|
-
const rows = db
|
|
134
|
-
.prepare(`SELECT country, lat_min, lat_max, lon_min, lon_max, source FROM ${COUNTRY_BBOX_TABLE}`)
|
|
135
|
-
.all();
|
|
131
|
+
const rows = allRows(db.prepare(`SELECT country, lat_min, lat_max, lon_min, lon_max, source FROM ${COUNTRY_BBOX_TABLE}`));
|
|
136
132
|
for (const row of rows) {
|
|
137
133
|
const country = String(row.country).toUpperCase();
|
|
138
134
|
countryBBoxes.set(country, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coverage-manifest-schema.js","sourceRoot":"","sources":["../coverage-man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AE,CAAA;YAEjD,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE;gBAC1B,OAAO;gBACP,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;gBAC3B,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;gBAC3B,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;gBAC3B,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;gBAC3B,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;aAC1B,CAAC,CAAA;QACH,CAAC;IACF,CAAC;IAED,OAAO;QACN,eAAe;QACf,aAAa;QACb,mBAAmB,EAAE,+BAA+B,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;KAC9E,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Pass 1c of the candidate build (#1737): resurrect deprecated-with-no-successor WOF localities that a second
|
|
7
|
+
* source independently attests. Extracted from `build-candidate.ts` as a cohesive unit — the gates, their measured
|
|
8
|
+
* constants, and the GeoNames dump reader live together here; the build calls {@link resurrectCurrencyHoles} once,
|
|
9
|
+
* between the primaries pass and the alias pass.
|
|
10
|
+
*/
|
|
11
|
+
import type { DatabaseSync } from "node:sqlite";
|
|
12
|
+
import type { loadImportanceIndex } from "./candidate-importance.ts";
|
|
13
|
+
import type { PlaceAttrs, StageRow } from "./candidate/place-attrs.ts";
|
|
14
|
+
/**
|
|
15
|
+
* Pass 1c (#1737): resurrect deprecated-with-no-successor localities that a second source independently attests.
|
|
16
|
+
*
|
|
17
|
+
* WOF deprecations WITH a successor need nothing — the successor indexes. A deprecation with `is_superseded = 0` on a
|
|
18
|
+
* populated place is the shape of an upstream mistake (Rochester Kent, Aldershot, Telford; 120 GB localities alone),
|
|
19
|
+
* and it is indistinguishable from a correct pruning at this layer without outside evidence. So every resurrection
|
|
20
|
+
* requires all three gates, positive evidence only:
|
|
21
|
+
*
|
|
22
|
+
* 1. NO live same-name spr row of any placetype within {@link CURRENCY_BACKFILL_RADIUS_KM} of the dead record — a live row
|
|
23
|
+
* means the place is alive (possibly under another placetype) and there is no hole. A DISTANT same-name row is a
|
|
24
|
+
* namesake and does not block.
|
|
25
|
+
* 2. A GeoNames feature-class-P attestation of the same folded name within the radius.
|
|
26
|
+
* 3. The attestor at or above {@link CURRENCY_BACKFILL_POP_FLOOR}.
|
|
27
|
+
*
|
|
28
|
+
* The staged row keeps the WOF identity — id, name, centroid, bbox, region ancestry — because the dead record's own
|
|
29
|
+
* data is not what is wrong with it. GeoNames contributes exactly two things: the attestation, and the population that
|
|
30
|
+
* lets the row stand in prominence races (the dead record's own population is absent). Each name is judged once per
|
|
31
|
+
* country; the resurrected place joins `attrs`, so the alias pass explodes its alt names like any primary's.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resurrectCurrencyHoles(ctx: {
|
|
34
|
+
src: DatabaseSync;
|
|
35
|
+
tx: DatabaseSync;
|
|
36
|
+
geonamesDir: string;
|
|
37
|
+
countries: readonly string[];
|
|
38
|
+
attrs: Map<number, PlaceAttrs>;
|
|
39
|
+
ccID: (code: string | null) => number;
|
|
40
|
+
ptID: (pt: string | null) => number;
|
|
41
|
+
regionOf: Map<number, number>;
|
|
42
|
+
importance: ReturnType<typeof loadImportanceIndex> | undefined;
|
|
43
|
+
stageRow: StageRow;
|
|
44
|
+
progress: (phase: string, message: string) => void;
|
|
45
|
+
}): Promise<number>;
|
|
46
|
+
//# sourceMappingURL=currency-backfill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currency-backfill.d.ts","sourceRoot":"","sources":["../currency-backfill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAmBtE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE;IACjD,GAAG,EAAE,YAAY,CAAA;IACjB,EAAE,EAAE,YAAY,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;IAC5B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9B,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,MAAM,CAAA;IACrC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,MAAM,CAAA;IACnC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,UAAU,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,GAAG,SAAS,CAAA;IAC9D,QAAQ,EAAE,QAAQ,CAAA;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAClD,GAAG,OAAO,CAAC,MAAM,CAAC,CAkLlB"}
|