@mailwoman/resolver-wof-sqlite 9.2.0 → 9.3.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 +16 -19
- package/lib/address/index.ts +9 -0
- package/{address-point-interpolation.ts → lib/address/point-interpolation.ts} +24 -22
- package/{address-point-schema.ts → lib/address/point-schema.ts} +18 -4
- package/{address-point.ts → lib/address/point.ts} +89 -27
- package/{ancestry-backfill.ts → lib/ancestry/backfill.ts} +14 -19
- package/{ancestry.ts → lib/ancestry/index.ts} +5 -3
- package/{build-candidate.ts → lib/build-candidate.ts} +84 -77
- package/{build-slim.ts → lib/build-slim.ts} +150 -165
- package/{candidate → lib/candidate}/alias-bags.ts +8 -6
- package/{candidate → lib/candidate}/ancestors-sidecar.ts +13 -15
- package/{candidate → lib/candidate}/country-display-names.ts +2 -2
- package/{candidate/shard-fold.ts → lib/candidate/extract-fold.ts} +26 -25
- package/{candidate → lib/candidate}/name-roles.ts +17 -16
- package/{candidate → lib/candidate}/own-name.ts +1 -1
- package/{candidate → lib/candidate}/place-attrs.ts +3 -3
- package/{candidate-ancestors-schema.ts → lib/candidate-ancestors-schema.ts} +4 -4
- package/{candidate-fts.ts → lib/candidate-fts.ts} +3 -3
- package/{candidate-importance.ts → lib/candidate-importance.ts} +53 -57
- package/{candidate-lookup.ts → lib/candidate-lookup.ts} +76 -73
- package/{candidate-schema.ts → lib/candidate-schema.ts} +5 -5
- package/{candidate-scoring.ts → lib/candidate-scoring.ts} +15 -22
- package/{capital-schema.ts → lib/capital-schema.ts} +5 -6
- package/{capitals.ts → lib/capitals.ts} +2 -2
- package/{coincident-roles.ts → lib/coincident-roles.ts} +8 -11
- package/{convention.ts → lib/convention/index.ts} +3 -3
- package/{convention-schema.ts → lib/convention/schema.ts} +2 -2
- package/{coverage-manifest-schema.ts → lib/coverage-manifest-schema.ts} +9 -10
- package/{currency-backfill.ts → lib/currency-backfill.ts} +126 -41
- package/lib/env.ts +50 -0
- package/{exact-match.ts → lib/exact-match.ts} +23 -14
- package/{sharding.ts → lib/extracts.ts} +61 -58
- package/{fst-autocomplete.ts → lib/fst/autocomplete.ts} +4 -4
- package/{fst-builder.ts → lib/fst/builder.ts} +17 -16
- package/{fst-deserialize-web.ts → lib/fst/deserialize-web.ts} +27 -87
- package/lib/fst/format.ts +106 -0
- package/{fst-freshness.ts → lib/fst/freshness.ts} +41 -74
- package/lib/fst/index.ts +14 -0
- package/{fst-matcher.ts → lib/fst/matcher.ts} +1 -1
- package/{fst-serialize.ts → lib/fst/serialize.ts} +37 -115
- package/{fst-types.ts → lib/fst/types.ts} +4 -2
- package/{fts.ts → lib/fts/index.ts} +24 -19
- package/{fts-query.ts → lib/fts/query.ts} +1 -1
- package/{geonames-aliases.ts → lib/geonames/aliases.ts} +13 -13
- package/lib/geonames/index.ts +8 -0
- package/{geonames-postal.ts → lib/geonames/postal.ts} +14 -13
- package/{index.ts → lib/index.ts} +37 -37
- package/{interpolation.ts → lib/interpolation.ts} +27 -25
- package/{lookup.ts → lib/lookup.ts} +129 -141
- package/lib/nsul/index.ts +8 -0
- package/lib/nsul/lookup.ts +144 -0
- package/lib/nsul/schema.ts +130 -0
- package/{place-importance-schema.ts → lib/place-importance-schema.ts} +7 -8
- package/lib/poi/index.ts +8 -0
- package/{poi-lookup.ts → lib/poi/lookup.ts} +22 -28
- package/{poi-schema.ts → lib/poi/schema.ts} +3 -4
- package/{postal-city-alias-lookup.ts → lib/postal/city-alias-lookup.ts} +14 -20
- package/{postal-city-candidate-schema.ts → lib/postal/city-candidate-schema.ts} +2 -2
- package/lib/postal/index.ts +9 -0
- package/{postcode-point-lookup.ts → lib/postcode-point-lookup.ts} +17 -15
- package/{primary-preference.ts → lib/primary-preference.ts} +29 -10
- package/{proximity-rerank.ts → lib/proximity-rerank.ts} +2 -2
- package/{ranking-weights.ts → lib/ranking-weights.ts} +30 -4
- package/{region-keys.ts → lib/region-keys.ts} +9 -9
- package/{reverse.ts → lib/reverse.ts} +34 -46
- package/{schema.ts → lib/schema.ts} +10 -0
- package/{search-fetch.ts → lib/search-fetch.ts} +29 -28
- package/{sqlite-convention-source.ts → lib/sqlite-convention-source.ts} +9 -10
- package/{sqlite-utils.ts → lib/sqlite-utils.ts} +14 -18
- package/{street-centroid-schema.ts → lib/street/centroid-schema.ts} +5 -5
- package/{street-centroid.ts → lib/street/centroid.ts} +14 -21
- package/lib/street/index.ts +13 -0
- package/{street-morphology-fst-builder.ts → lib/street/morphology-fst-builder.ts} +24 -14
- package/{street-morphology-fst-loader.ts → lib/street/morphology-fst-loader.ts} +14 -12
- package/{street-name-lookup.ts → lib/street/name-lookup.ts} +14 -30
- package/{street-normalize.ts → lib/street/normalize.ts} +44 -19
- package/{street-segment-schema.ts → lib/street/segment-schema.ts} +7 -7
- package/{types.ts → lib/types.ts} +18 -12
- package/{unified-schema.ts → lib/unified-schema.ts} +20 -24
- package/lib/uprn/existence.ts +84 -0
- package/lib/uprn/index.ts +9 -0
- package/{uprn-lookup.ts → lib/uprn/lookup.ts} +14 -18
- package/{uprn-schema.ts → lib/uprn/schema.ts} +3 -3
- package/lib/weights-overlay-linker.ts +878 -0
- package/out/address/index.d.ts +9 -0
- package/out/address/index.d.ts.map +1 -0
- package/out/address/index.js +9 -0
- package/out/address/index.js.map +1 -0
- package/out/{address-point-interpolation.d.ts → address/point-interpolation.d.ts} +11 -10
- package/out/address/point-interpolation.d.ts.map +1 -0
- package/out/{address-point-interpolation.js → address/point-interpolation.js} +18 -18
- package/out/address/point-interpolation.js.map +1 -0
- package/out/{address-point-schema.d.ts → address/point-schema.d.ts} +16 -6
- package/out/address/point-schema.d.ts.map +1 -0
- package/out/{address-point-schema.js → address/point-schema.js} +7 -3
- package/out/address/point-schema.js.map +1 -0
- package/out/{address-point.d.ts → address/point.d.ts} +16 -8
- package/out/address/point.d.ts.map +1 -0
- package/out/{address-point.js → address/point.js} +71 -20
- package/out/address/point.js.map +1 -0
- package/out/{ancestry-backfill.d.ts → ancestry/backfill.d.ts} +7 -5
- package/out/ancestry/backfill.d.ts.map +1 -0
- package/out/{ancestry-backfill.js → ancestry/backfill.js} +12 -16
- package/out/ancestry/backfill.js.map +1 -0
- package/out/{ancestry.d.ts → ancestry/index.d.ts} +4 -3
- package/out/ancestry/index.d.ts.map +1 -0
- package/out/{ancestry.js → ancestry/index.js} +3 -2
- package/out/ancestry/index.js.map +1 -0
- package/out/build-candidate.d.ts +30 -24
- package/out/build-candidate.d.ts.map +1 -1
- package/out/build-candidate.js +50 -52
- package/out/build-candidate.js.map +1 -1
- package/out/build-slim.d.ts +4 -4
- package/out/build-slim.d.ts.map +1 -1
- package/out/build-slim.js +124 -139
- package/out/build-slim.js.map +1 -1
- package/out/candidate/alias-bags.d.ts +5 -3
- package/out/candidate/alias-bags.d.ts.map +1 -1
- package/out/candidate/alias-bags.js +2 -2
- package/out/candidate/alias-bags.js.map +1 -1
- package/out/candidate/ancestors-sidecar.d.ts +9 -10
- package/out/candidate/ancestors-sidecar.d.ts.map +1 -1
- package/out/candidate/ancestors-sidecar.js +7 -7
- package/out/candidate/ancestors-sidecar.js.map +1 -1
- package/out/candidate/country-display-names.d.ts +1 -1
- package/out/candidate/country-display-names.d.ts.map +1 -1
- package/out/candidate/country-display-names.js +1 -1
- package/out/candidate/country-display-names.js.map +1 -1
- package/out/candidate/extract-fold.d.ts +32 -0
- package/out/candidate/extract-fold.d.ts.map +1 -0
- package/out/candidate/{shard-fold.js → extract-fold.js} +20 -20
- package/out/candidate/extract-fold.js.map +1 -0
- package/out/candidate/name-roles.d.ts +13 -11
- package/out/candidate/name-roles.d.ts.map +1 -1
- package/out/candidate/name-roles.js +11 -10
- package/out/candidate/name-roles.js.map +1 -1
- package/out/candidate/own-name.d.ts +1 -1
- package/out/candidate/own-name.d.ts.map +1 -1
- package/out/candidate/own-name.js +1 -1
- package/out/candidate/own-name.js.map +1 -1
- package/out/candidate/place-attrs.d.ts +3 -3
- package/out/candidate/place-attrs.d.ts.map +1 -1
- package/out/candidate/place-attrs.js +1 -1
- package/out/candidate/place-attrs.js.map +1 -1
- package/out/candidate-ancestors-schema.d.ts +4 -4
- package/out/candidate-ancestors-schema.d.ts.map +1 -1
- package/out/candidate-ancestors-schema.js +2 -2
- package/out/candidate-ancestors-schema.js.map +1 -1
- package/out/candidate-fts.d.ts +3 -3
- package/out/candidate-fts.d.ts.map +1 -1
- package/out/candidate-fts.js +1 -1
- package/out/candidate-fts.js.map +1 -1
- package/out/candidate-importance.d.ts +16 -16
- package/out/candidate-importance.d.ts.map +1 -1
- package/out/candidate-importance.js +46 -51
- package/out/candidate-importance.js.map +1 -1
- package/out/candidate-lookup.d.ts +11 -9
- package/out/candidate-lookup.d.ts.map +1 -1
- package/out/candidate-lookup.js +61 -58
- package/out/candidate-lookup.js.map +1 -1
- package/out/candidate-schema.d.ts +5 -5
- package/out/candidate-schema.d.ts.map +1 -1
- package/out/candidate-schema.js.map +1 -1
- package/out/candidate-scoring.d.ts +7 -7
- package/out/candidate-scoring.d.ts.map +1 -1
- package/out/candidate-scoring.js +10 -14
- package/out/candidate-scoring.js.map +1 -1
- package/out/capital-schema.d.ts +3 -3
- package/out/capital-schema.d.ts.map +1 -1
- package/out/capital-schema.js +2 -2
- package/out/capital-schema.js.map +1 -1
- package/out/capitals.d.ts +1 -1
- package/out/capitals.d.ts.map +1 -1
- package/out/capitals.js +2 -2
- package/out/capitals.js.map +1 -1
- package/out/coincident-roles.d.ts +6 -5
- package/out/coincident-roles.d.ts.map +1 -1
- package/out/coincident-roles.js +2 -4
- package/out/coincident-roles.js.map +1 -1
- package/out/{convention.d.ts → convention/index.d.ts} +4 -4
- package/out/convention/index.d.ts.map +1 -0
- package/out/{convention.js → convention/index.js} +2 -2
- package/out/convention/index.js.map +1 -0
- package/out/{convention-schema.d.ts → convention/schema.d.ts} +2 -2
- package/out/convention/schema.d.ts.map +1 -0
- package/out/{convention-schema.js → convention/schema.js} +3 -3
- package/out/convention/schema.js.map +1 -0
- package/out/coverage-manifest-schema.d.ts +8 -8
- package/out/coverage-manifest-schema.d.ts.map +1 -1
- package/out/coverage-manifest-schema.js +4 -4
- package/out/coverage-manifest-schema.js.map +1 -1
- package/out/currency-backfill.d.ts +51 -7
- package/out/currency-backfill.d.ts.map +1 -1
- package/out/currency-backfill.js +65 -49
- package/out/currency-backfill.js.map +1 -1
- package/out/env.d.ts +43 -0
- package/out/env.d.ts.map +1 -0
- package/out/env.js +48 -0
- package/out/env.js.map +1 -0
- package/out/exact-match.d.ts +5 -5
- package/out/exact-match.d.ts.map +1 -1
- package/out/exact-match.js +10 -11
- package/out/exact-match.js.map +1 -1
- package/out/extracts.d.ts +114 -0
- package/out/extracts.d.ts.map +1 -0
- package/out/{sharding.js → extracts.js} +38 -38
- package/out/extracts.js.map +1 -0
- package/out/{fst-autocomplete.d.ts → fst/autocomplete.d.ts} +2 -2
- package/out/fst/autocomplete.d.ts.map +1 -0
- package/out/{fst-autocomplete.js → fst/autocomplete.js} +3 -3
- package/out/fst/autocomplete.js.map +1 -0
- package/out/{fst-builder.d.ts → fst/builder.d.ts} +5 -5
- package/out/fst/builder.d.ts.map +1 -0
- package/out/{fst-builder.js → fst/builder.js} +14 -13
- package/out/fst/builder.js.map +1 -0
- package/out/{fst-deserialize-web.d.ts → fst/deserialize-web.d.ts} +3 -3
- package/out/fst/deserialize-web.d.ts.map +1 -0
- package/out/{fst-deserialize-web.js → fst/deserialize-web.js} +10 -74
- package/out/fst/deserialize-web.js.map +1 -0
- package/out/fst/format.d.ts +80 -0
- package/out/fst/format.d.ts.map +1 -0
- package/out/fst/format.js +91 -0
- package/out/fst/format.js.map +1 -0
- package/out/{fst-freshness.d.ts → fst/freshness.d.ts} +10 -13
- package/out/fst/freshness.d.ts.map +1 -0
- package/out/{fst-freshness.js → fst/freshness.js} +41 -73
- package/out/fst/freshness.js.map +1 -0
- package/out/fst/index.d.ts +14 -0
- package/out/fst/index.d.ts.map +1 -0
- package/out/fst/index.js +14 -0
- package/out/fst/index.js.map +1 -0
- package/out/{fst-matcher.d.ts → fst/matcher.d.ts} +2 -2
- package/out/fst/matcher.d.ts.map +1 -0
- package/out/{fst-matcher.js → fst/matcher.js} +1 -1
- package/out/fst/matcher.js.map +1 -0
- package/out/{fst-serialize.d.ts → fst/serialize.d.ts} +5 -10
- package/out/fst/serialize.d.ts.map +1 -0
- package/out/{fst-serialize.js → fst/serialize.js} +18 -98
- package/out/fst/serialize.js.map +1 -0
- package/out/{fst-types.d.ts → fst/types.d.ts} +4 -3
- package/out/fst/types.d.ts.map +1 -0
- package/out/{fst-types.js → fst/types.js} +1 -1
- package/out/fst/types.js.map +1 -0
- package/out/{fts.d.ts → fts/index.d.ts} +16 -9
- package/out/fts/index.d.ts.map +1 -0
- package/out/{fts.js → fts/index.js} +16 -11
- package/out/fts/index.js.map +1 -0
- package/out/{fts-query.d.ts → fts/query.d.ts} +2 -2
- package/out/fts/query.d.ts.map +1 -0
- package/out/{fts-query.js → fts/query.js} +1 -1
- package/out/fts/query.js.map +1 -0
- package/out/{geonames-aliases.d.ts → geonames/aliases.d.ts} +8 -6
- package/out/geonames/aliases.d.ts.map +1 -0
- package/out/{geonames-aliases.js → geonames/aliases.js} +7 -7
- package/out/geonames/aliases.js.map +1 -0
- package/out/geonames/index.d.ts +8 -0
- package/out/geonames/index.d.ts.map +1 -0
- package/out/geonames/index.js +8 -0
- package/out/geonames/index.js.map +1 -0
- package/out/{geonames-postal.d.ts → geonames/postal.d.ts} +10 -8
- package/out/geonames/postal.d.ts.map +1 -0
- package/out/{geonames-postal.js → geonames/postal.js} +9 -9
- package/out/geonames/postal.js.map +1 -0
- package/out/index.d.ts +32 -32
- package/out/index.d.ts.map +1 -1
- package/out/index.js +24 -24
- package/out/index.js.map +1 -1
- package/out/interpolation.d.ts +10 -9
- package/out/interpolation.d.ts.map +1 -1
- package/out/interpolation.js +20 -20
- package/out/interpolation.js.map +1 -1
- package/out/lookup.d.ts +21 -20
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +102 -112
- package/out/lookup.js.map +1 -1
- package/out/name-score.d.ts.map +1 -1
- package/out/name-score.js.map +1 -1
- package/out/nsul/index.d.ts +8 -0
- package/out/nsul/index.d.ts.map +1 -0
- package/out/nsul/index.js +8 -0
- package/out/nsul/index.js.map +1 -0
- package/out/nsul/lookup.d.ts +83 -0
- package/out/nsul/lookup.d.ts.map +1 -0
- package/out/nsul/lookup.js +80 -0
- package/out/nsul/lookup.js.map +1 -0
- package/out/nsul/schema.d.ts +100 -0
- package/out/nsul/schema.d.ts.map +1 -0
- package/out/nsul/schema.js +78 -0
- package/out/nsul/schema.js.map +1 -0
- package/out/place-importance-schema.d.ts +5 -5
- package/out/place-importance-schema.d.ts.map +1 -1
- package/out/place-importance-schema.js +3 -3
- package/out/place-importance-schema.js.map +1 -1
- package/out/poi/index.d.ts +8 -0
- package/out/poi/index.d.ts.map +1 -0
- package/out/poi/index.js +8 -0
- package/out/poi/index.js.map +1 -0
- package/out/{poi-lookup.d.ts → poi/lookup.d.ts} +8 -10
- package/out/poi/lookup.d.ts.map +1 -0
- package/out/{poi-lookup.js → poi/lookup.js} +14 -18
- package/out/poi/lookup.js.map +1 -0
- package/out/{poi-schema.d.ts → poi/schema.d.ts} +4 -4
- package/out/poi/schema.d.ts.map +1 -0
- package/out/{poi-schema.js → poi/schema.js} +1 -1
- package/out/poi/schema.js.map +1 -0
- package/out/polygon-schema.d.ts.map +1 -1
- package/out/polygon-schema.js.map +1 -1
- package/out/{postal-city-alias-lookup.d.ts → postal/city-alias-lookup.d.ts} +6 -5
- package/out/postal/city-alias-lookup.d.ts.map +1 -0
- package/out/{postal-city-alias-lookup.js → postal/city-alias-lookup.js} +11 -15
- package/out/postal/city-alias-lookup.js.map +1 -0
- package/out/{postal-city-alias-schema.d.ts → postal/city-alias-schema.d.ts} +1 -1
- package/out/{postal-city-alias-schema.d.ts.map → postal/city-alias-schema.d.ts.map} +1 -1
- package/out/{postal-city-alias-schema.js → postal/city-alias-schema.js} +1 -1
- package/out/{postal-city-alias-schema.js.map → postal/city-alias-schema.js.map} +1 -1
- package/out/{postal-city-candidate-schema.d.ts → postal/city-candidate-schema.d.ts} +3 -3
- package/out/{postal-city-candidate-schema.d.ts.map → postal/city-candidate-schema.d.ts.map} +1 -1
- package/out/{postal-city-candidate-schema.js → postal/city-candidate-schema.js} +2 -2
- package/out/{postal-city-candidate-schema.js.map → postal/city-candidate-schema.js.map} +1 -1
- package/out/postal/index.d.ts +9 -0
- package/out/postal/index.d.ts.map +1 -0
- package/out/postal/index.js +9 -0
- package/out/postal/index.js.map +1 -0
- package/out/postcode-point-lookup.d.ts +10 -10
- package/out/postcode-point-lookup.d.ts.map +1 -1
- package/out/postcode-point-lookup.js +13 -13
- package/out/postcode-point-lookup.js.map +1 -1
- package/out/primary-preference.d.ts +13 -5
- package/out/primary-preference.d.ts.map +1 -1
- package/out/primary-preference.js +16 -8
- package/out/primary-preference.js.map +1 -1
- package/out/proximity-rerank.d.ts +2 -2
- package/out/proximity-rerank.d.ts.map +1 -1
- package/out/proximity-rerank.js +2 -2
- package/out/proximity-rerank.js.map +1 -1
- package/out/ranking-weights.d.ts +15 -3
- package/out/ranking-weights.d.ts.map +1 -1
- package/out/ranking-weights.js +21 -3
- package/out/ranking-weights.js.map +1 -1
- package/out/region-keys.d.ts +8 -8
- package/out/region-keys.d.ts.map +1 -1
- package/out/region-keys.js +9 -9
- package/out/region-keys.js.map +1 -1
- package/out/reverse.d.ts +6 -6
- package/out/reverse.d.ts.map +1 -1
- package/out/reverse.js +20 -29
- package/out/reverse.js.map +1 -1
- package/out/schema.d.ts +9 -0
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js.map +1 -1
- package/out/search-fetch.d.ts +12 -10
- package/out/search-fetch.d.ts.map +1 -1
- package/out/search-fetch.js +21 -20
- package/out/search-fetch.js.map +1 -1
- package/out/sqlite-convention-source.d.ts +7 -7
- package/out/sqlite-convention-source.d.ts.map +1 -1
- package/out/sqlite-convention-source.js +5 -5
- package/out/sqlite-convention-source.js.map +1 -1
- package/out/sqlite-utils.d.ts +8 -8
- package/out/sqlite-utils.d.ts.map +1 -1
- package/out/sqlite-utils.js +7 -8
- package/out/sqlite-utils.js.map +1 -1
- package/out/{street-centroid-schema.d.ts → street/centroid-schema.d.ts} +6 -6
- package/out/{street-centroid-schema.d.ts.map → street/centroid-schema.d.ts.map} +1 -1
- package/out/{street-centroid-schema.js → street/centroid-schema.js} +5 -5
- package/out/{street-centroid-schema.js.map → street/centroid-schema.js.map} +1 -1
- package/out/{street-centroid.d.ts → street/centroid.d.ts} +6 -6
- package/out/street/centroid.d.ts.map +1 -0
- package/out/{street-centroid.js → street/centroid.js} +13 -19
- package/out/street/centroid.js.map +1 -0
- package/out/street/index.d.ts +13 -0
- package/out/street/index.d.ts.map +1 -0
- package/out/street/index.js +13 -0
- package/out/street/index.js.map +1 -0
- package/out/{street-morphology-fst-builder.d.ts → street/morphology-fst-builder.d.ts} +4 -4
- package/out/street/morphology-fst-builder.d.ts.map +1 -0
- package/out/{street-morphology-fst-builder.js → street/morphology-fst-builder.js} +18 -13
- package/out/street/morphology-fst-builder.js.map +1 -0
- package/out/{street-morphology-fst-loader.d.ts → street/morphology-fst-loader.d.ts} +5 -5
- package/out/street/morphology-fst-loader.d.ts.map +1 -0
- package/out/{street-morphology-fst-loader.js → street/morphology-fst-loader.js} +11 -10
- package/out/street/morphology-fst-loader.js.map +1 -0
- package/out/{street-name-lookup.d.ts → street/name-lookup.d.ts} +4 -7
- package/out/street/name-lookup.d.ts.map +1 -0
- package/out/{street-name-lookup.js → street/name-lookup.js} +9 -23
- package/out/street/name-lookup.js.map +1 -0
- package/out/{street-normalize.d.ts → street/normalize.d.ts} +25 -14
- package/out/street/normalize.d.ts.map +1 -0
- package/out/{street-normalize.js → street/normalize.js} +36 -17
- package/out/street/normalize.js.map +1 -0
- package/out/{street-segment-schema.d.ts → street/segment-schema.d.ts} +8 -8
- package/out/{street-segment-schema.d.ts.map → street/segment-schema.d.ts.map} +1 -1
- package/out/{street-segment-schema.js → street/segment-schema.js} +4 -4
- package/out/{street-segment-schema.js.map → street/segment-schema.js.map} +1 -1
- package/out/types.d.ts +18 -12
- package/out/types.d.ts.map +1 -1
- package/out/types.js.map +1 -1
- package/out/unified-schema.d.ts +5 -4
- package/out/unified-schema.d.ts.map +1 -1
- package/out/unified-schema.js +15 -18
- package/out/unified-schema.js.map +1 -1
- package/out/uprn/existence.d.ts +53 -0
- package/out/uprn/existence.d.ts.map +1 -0
- package/out/uprn/existence.js +61 -0
- package/out/uprn/existence.js.map +1 -0
- package/out/uprn/index.d.ts +9 -0
- package/out/uprn/index.d.ts.map +1 -0
- package/out/uprn/index.js +9 -0
- package/out/uprn/index.js.map +1 -0
- package/out/{uprn-lookup.d.ts → uprn/lookup.d.ts} +4 -4
- package/out/uprn/lookup.d.ts.map +1 -0
- package/out/{uprn-lookup.js → uprn/lookup.js} +11 -14
- package/out/uprn/lookup.js.map +1 -0
- package/out/{uprn-schema.d.ts → uprn/schema.d.ts} +4 -4
- package/out/uprn/schema.d.ts.map +1 -0
- package/out/{uprn-schema.js → uprn/schema.js} +4 -4
- package/out/uprn/schema.js.map +1 -0
- package/out/weights-overlay-linker.d.ts +184 -26
- package/out/weights-overlay-linker.d.ts.map +1 -1
- package/out/weights-overlay-linker.js +338 -86
- package/out/weights-overlay-linker.js.map +1 -1
- package/package.json +465 -269
- package/out/address-point-interpolation.d.ts.map +0 -1
- package/out/address-point-interpolation.js.map +0 -1
- package/out/address-point-schema.d.ts.map +0 -1
- package/out/address-point-schema.js.map +0 -1
- package/out/address-point.d.ts.map +0 -1
- package/out/address-point.js.map +0 -1
- package/out/ancestry-backfill.d.ts.map +0 -1
- package/out/ancestry-backfill.js.map +0 -1
- package/out/ancestry.d.ts.map +0 -1
- package/out/ancestry.js.map +0 -1
- package/out/candidate/shard-fold.d.ts +0 -31
- package/out/candidate/shard-fold.d.ts.map +0 -1
- package/out/candidate/shard-fold.js.map +0 -1
- package/out/convention-schema.d.ts.map +0 -1
- package/out/convention-schema.js.map +0 -1
- package/out/convention.d.ts.map +0 -1
- package/out/convention.js.map +0 -1
- package/out/fst-autocomplete.d.ts.map +0 -1
- package/out/fst-autocomplete.js.map +0 -1
- package/out/fst-builder.d.ts.map +0 -1
- package/out/fst-builder.js.map +0 -1
- package/out/fst-deserialize-web.d.ts.map +0 -1
- package/out/fst-deserialize-web.js.map +0 -1
- package/out/fst-freshness.d.ts.map +0 -1
- package/out/fst-freshness.js.map +0 -1
- package/out/fst-matcher.d.ts.map +0 -1
- package/out/fst-matcher.js.map +0 -1
- package/out/fst-serialize.d.ts.map +0 -1
- package/out/fst-serialize.js.map +0 -1
- package/out/fst-types.d.ts.map +0 -1
- package/out/fst-types.js.map +0 -1
- package/out/fts-query.d.ts.map +0 -1
- package/out/fts-query.js.map +0 -1
- package/out/fts.d.ts.map +0 -1
- package/out/fts.js.map +0 -1
- package/out/geonames-aliases.d.ts.map +0 -1
- package/out/geonames-aliases.js.map +0 -1
- package/out/geonames-postal.d.ts.map +0 -1
- package/out/geonames-postal.js.map +0 -1
- package/out/poi-lookup.d.ts.map +0 -1
- package/out/poi-lookup.js.map +0 -1
- package/out/poi-schema.d.ts.map +0 -1
- package/out/poi-schema.js.map +0 -1
- package/out/postal-city-alias-lookup.d.ts.map +0 -1
- package/out/postal-city-alias-lookup.js.map +0 -1
- package/out/sharding.d.ts +0 -114
- package/out/sharding.d.ts.map +0 -1
- package/out/sharding.js.map +0 -1
- package/out/street-centroid.d.ts.map +0 -1
- package/out/street-centroid.js.map +0 -1
- package/out/street-morphology-fst-builder.d.ts.map +0 -1
- package/out/street-morphology-fst-builder.js.map +0 -1
- package/out/street-morphology-fst-loader.d.ts.map +0 -1
- package/out/street-morphology-fst-loader.js.map +0 -1
- package/out/street-name-lookup.d.ts.map +0 -1
- package/out/street-name-lookup.js.map +0 -1
- package/out/street-normalize.d.ts.map +0 -1
- package/out/street-normalize.js.map +0 -1
- package/out/uprn-lookup.d.ts.map +0 -1
- package/out/uprn-lookup.js.map +0 -1
- package/out/uprn-schema.d.ts.map +0 -1
- package/out/uprn-schema.js.map +0 -1
- package/weights-overlay-linker.ts +0 -377
- /package/{name-score.ts → lib/name-score.ts} +0 -0
- /package/{polygon-schema.ts → lib/polygon-schema.ts} +0 -0
- /package/{postal-city-alias-schema.ts → lib/postal/city-alias-schema.ts} +0 -0
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* #920 — fold GeoNames POSTAL codes into a WOF/unified postcode
|
|
6
|
+
* #920 — fold GeoNames POSTAL codes into a WOF/unified postcode extract as first-class
|
|
7
7
|
* `postalcode` places, for the countries whose WOF postalcode repos don't exist (the
|
|
8
8
|
* namesake-tail locales: FI/CZ/SK/SI/DK/NO/HR/PL and any future gap).
|
|
9
9
|
*
|
|
10
10
|
* Why: the night-31 taxonomy measured the cross-locale resolve tail as NAMESAKE COLLISION
|
|
11
|
-
* (FI 300/1k … PL 75/1k offender rows), and the controlled experiment showed postcode-
|
|
11
|
+
* (FI 300/1k … PL 75/1k offender rows), and the controlled experiment showed postcode-extract
|
|
12
12
|
* coverage alone collapses it (FI 300→1, CZ 131→4): a resolvable postcode node feeds the
|
|
13
13
|
* resolver's coordinate-first sibling-postcode candidate injection, which binds the locality
|
|
14
|
-
* pick to its postcode neighborhood. The
|
|
14
|
+
* pick to its postcode neighborhood. The implementation already ships; it was coverage-starved.
|
|
15
15
|
*
|
|
16
16
|
* Two hard-won laws from the experiment are enforced HERE, in code, not in a runbook:
|
|
17
17
|
*
|
|
@@ -30,16 +30,17 @@
|
|
|
30
30
|
* --geonames-postal-countries`, any standalone fold, and the `mailwoman gazetteer` commands
|
|
31
31
|
* share ONE implementation. GeoNames postal dump = `download.geonames.org/export/zip/<CC>.zip`
|
|
32
32
|
* → `<CC>.txt` (TSV: country, postcode, place, admin1, code1, admin2, code2, admin3, code3,
|
|
33
|
-
* lat, lon, accuracy). License CC BY 4.0 — attribution rides the
|
|
33
|
+
* lat, lon, accuracy). License CC BY 4.0 — attribution rides the extract's `meta` provenance and
|
|
34
34
|
* the model card like the existing GeoNames alias fold.
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
-
import {
|
|
38
|
-
import type {
|
|
39
|
-
|
|
40
|
-
import { join } from "path-ts"
|
|
37
|
+
import { pathExists } from "@mailwoman/core/fs/readers"
|
|
38
|
+
import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
39
|
+
import { join, type PathBuilderLike } from "path-ts"
|
|
41
40
|
import { TSVSpliterator } from "spliterator"
|
|
42
41
|
|
|
42
|
+
import type { WOFDatabase } from "#schema"
|
|
43
|
+
|
|
43
44
|
/**
|
|
44
45
|
* Column count of a GeoNames postal-code TSV row. Short rows are truncated or blank and are skipped. See the
|
|
45
46
|
* allCountries.zip readme for the field list.
|
|
@@ -77,7 +78,7 @@ export type PostcodePoint = readonly [number, number]
|
|
|
77
78
|
*
|
|
78
79
|
* Distance is squared-Euclidean in DEGREES, not haversine. At the scale a postcode spans, the ranking the two produce
|
|
79
80
|
* is the same, and this one carries no trig into a per-group inner loop. Ties go to the earliest member, which makes
|
|
80
|
-
* the result a pure function of the input order — the property a rebuilt
|
|
81
|
+
* the result a pure function of the input order — the property a rebuilt extract's ids depend on.
|
|
81
82
|
*
|
|
82
83
|
* Exported (rather than inlined at each ingest) because it is the second half of the #920 pair: every postcode source
|
|
83
84
|
* that groups member points — GeoNames postal, OSM `addr:postcode` — owes the same law, and a second hand-rolled copy
|
|
@@ -138,9 +139,9 @@ export interface GeonamesPostalIngestResult {
|
|
|
138
139
|
* freeze phase).
|
|
139
140
|
*/
|
|
140
141
|
export async function ingestGeonamesPostal(
|
|
141
|
-
db:
|
|
142
|
+
db: DatabaseClient<WOFDatabase>,
|
|
142
143
|
countries: readonly string[],
|
|
143
|
-
postalDir:
|
|
144
|
+
postalDir: PathBuilderLike
|
|
144
145
|
): Promise<GeonamesPostalIngestResult> {
|
|
145
146
|
const sprInsert = db.prepare(
|
|
146
147
|
`INSERT OR REPLACE INTO spr (id, parent_id, name, placetype, country, latitude, longitude, min_latitude, min_longitude, max_latitude, max_longitude, is_current, is_deprecated, is_ceased, is_superseded, is_superseding, lastmodified) VALUES (?, -1, ?, 'postalcode', ?, ?, ?, ?, ?, ?, ?, 1, 0, 0, 0, 0, 0)`
|
|
@@ -159,7 +160,7 @@ export async function ingestGeonamesPostal(
|
|
|
159
160
|
const cc = country.toUpperCase()
|
|
160
161
|
const file = join(postalDir, `${cc}.txt`)
|
|
161
162
|
|
|
162
|
-
if (!
|
|
163
|
+
if (!(await pathExists(file))) {
|
|
163
164
|
missing.push(cc)
|
|
164
165
|
|
|
165
166
|
console.error(
|
|
@@ -173,7 +174,7 @@ export async function ingestGeonamesPostal(
|
|
|
173
174
|
const members = new Map<string, { display: string; pts: Array<[number, number]> }>()
|
|
174
175
|
|
|
175
176
|
// Streamed: a national dump is a caller-supplied size — GB's is 177 MB, and only the caller
|
|
176
|
-
// knows which country is next. `header: false` is
|
|
177
|
+
// knows which country is next. `header: false` is required; the GeoNames postal dump is
|
|
177
178
|
// headerless, so row 1 would be consumed as column names and its postcode lost.
|
|
178
179
|
for await (const cols of TSVSpliterator.fromAsync(file, { header: false })) {
|
|
179
180
|
if (cols.length < GEONAMES_POSTAL_COLUMNS) continue
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
export type { FindPlaceQuery, GeoBbox, GeoPoint, PlaceCandidate, PlaceLookup, WOFPlacetype } from "
|
|
7
|
+
export type { FindPlaceQuery, GeoBbox, GeoPoint, PlaceCandidate, PlaceLookup, WOFPlacetype } from "#types"
|
|
8
8
|
|
|
9
9
|
export type {
|
|
10
10
|
AncestorsTable,
|
|
@@ -17,9 +17,9 @@ export type {
|
|
|
17
17
|
PlaceSearchTable,
|
|
18
18
|
SprTable,
|
|
19
19
|
WOFDatabase,
|
|
20
|
-
} from "
|
|
20
|
+
} from "#schema"
|
|
21
21
|
|
|
22
|
-
export { WOFSQLitePlaceLookup, type RankingWeights, type WOFSQLitePlaceLookupOpts } from "
|
|
22
|
+
export { WOFSQLitePlaceLookup, type RankingWeights, type WOFSQLitePlaceLookupOpts } from "#lookup"
|
|
23
23
|
|
|
24
24
|
export {
|
|
25
25
|
CANDIDATE_ANCESTOR_COLUMNS,
|
|
@@ -29,25 +29,25 @@ export {
|
|
|
29
29
|
createCandidateIntervalTable,
|
|
30
30
|
intervalContains,
|
|
31
31
|
MAX_ANCESTOR_DEPTH,
|
|
32
|
-
} from "
|
|
32
|
+
} from "#candidate-ancestors-schema"
|
|
33
33
|
|
|
34
34
|
export type {
|
|
35
35
|
CandidateAncestorsDatabase,
|
|
36
36
|
CandidateAncestorTable,
|
|
37
37
|
CandidateIntervalTable,
|
|
38
38
|
IntervalLabel,
|
|
39
|
-
} from "
|
|
39
|
+
} from "#candidate-ancestors-schema"
|
|
40
40
|
|
|
41
|
-
export { CANDIDATE_FTS_TABLE, createCandidateFTS } from "
|
|
41
|
+
export { CANDIDATE_FTS_TABLE, createCandidateFTS } from "#candidate-fts"
|
|
42
42
|
|
|
43
43
|
export {
|
|
44
44
|
ImportanceIndex,
|
|
45
|
-
|
|
45
|
+
IMPORTANCE_JOIN_RADIUS_KM,
|
|
46
46
|
type ImportanceIndexStats,
|
|
47
47
|
loadImportanceIndex,
|
|
48
|
-
} from "
|
|
48
|
+
} from "#candidate-importance"
|
|
49
49
|
|
|
50
|
-
export { WOFCandidateTableLookup, type WOFCandidateTableLookupOpts } from "
|
|
50
|
+
export { WOFCandidateTableLookup, type WOFCandidateTableLookupOpts } from "#candidate-lookup"
|
|
51
51
|
|
|
52
52
|
export {
|
|
53
53
|
COUNTRY_BBOX_TABLE,
|
|
@@ -56,38 +56,38 @@ export {
|
|
|
56
56
|
createCountryCoverageTable,
|
|
57
57
|
readGazetteerCoverageManifest,
|
|
58
58
|
writeGazetteerCoverageManifest,
|
|
59
|
-
} from "
|
|
59
|
+
} from "#coverage-manifest-schema"
|
|
60
60
|
|
|
61
|
-
export type { CountryBBoxTable, CountryCoverageTable, GazetteerCoverageDatabase } from "
|
|
62
|
-
export { SQLiteStreetNameLookup, type SQLiteStreetNameLookupOpts } from "
|
|
61
|
+
export type { CountryBBoxTable, CountryCoverageTable, GazetteerCoverageDatabase } from "#coverage-manifest-schema"
|
|
62
|
+
export { SQLiteStreetNameLookup, type SQLiteStreetNameLookupOpts } from "#street/name-lookup"
|
|
63
63
|
|
|
64
64
|
export {
|
|
65
65
|
GEONAMES_ID_BASE,
|
|
66
66
|
type GeonamesIngestProgress,
|
|
67
67
|
ingestGeonamesAliases,
|
|
68
68
|
purgeGeonamesAliasRange,
|
|
69
|
-
} from "
|
|
69
|
+
} from "#geonames/aliases"
|
|
70
70
|
|
|
71
|
-
export { GEONAMES_POSTAL_ID_BASE } from "
|
|
71
|
+
export { GEONAMES_POSTAL_ID_BASE } from "#geonames/postal"
|
|
72
72
|
|
|
73
|
-
export { ADDRESS_POINT_COLUMNS, createAddressPointIndexes, createAddressPointTable } from "
|
|
74
|
-
export type { AddressPointDatabase, AddressPointTable } from "
|
|
73
|
+
export { ADDRESS_POINT_COLUMNS, createAddressPointIndexes, createAddressPointTable } from "#address/point-schema"
|
|
74
|
+
export type { AddressPointDatabase, AddressPointTable } from "#address/point-schema"
|
|
75
75
|
|
|
76
76
|
export {
|
|
77
77
|
WOFPostalCityAliasLookup,
|
|
78
78
|
type PostalCityAlias,
|
|
79
79
|
type WOFPostalCityAliasLookupOpts,
|
|
80
|
-
} from "
|
|
80
|
+
} from "#postal/city-alias-lookup"
|
|
81
81
|
|
|
82
|
-
export type { PostalCityAliasDatabase, PostalCityAliasTable } from "
|
|
82
|
+
export type { PostalCityAliasDatabase, PostalCityAliasTable } from "#postal/city-alias-schema"
|
|
83
83
|
|
|
84
84
|
export {
|
|
85
85
|
POSTAL_CITY_CANDIDATE_COLUMNS,
|
|
86
86
|
POSTAL_CITY_CANDIDATE_TABLE,
|
|
87
87
|
createPostalCityCandidateTable,
|
|
88
|
-
} from "
|
|
88
|
+
} from "#postal/city-candidate-schema"
|
|
89
89
|
|
|
90
|
-
export type { PostalCityCandidateDatabase, PostalCityCandidateTable } from "
|
|
90
|
+
export type { PostalCityCandidateDatabase, PostalCityCandidateTable } from "#postal/city-candidate-schema"
|
|
91
91
|
|
|
92
92
|
export {
|
|
93
93
|
ADDRESS_CONVENTION_TABLE,
|
|
@@ -101,11 +101,11 @@ export {
|
|
|
101
101
|
type ResolvedConvention,
|
|
102
102
|
type ScoringWeights,
|
|
103
103
|
type Strategy,
|
|
104
|
-
} from "
|
|
104
|
+
} from "#convention/index"
|
|
105
105
|
|
|
106
|
-
export { SqliteConventionSource } from "
|
|
106
|
+
export { SqliteConventionSource } from "#sqlite-convention-source"
|
|
107
107
|
|
|
108
|
-
export { WOFPostcodeLookup, type PostcodePlace } from "
|
|
108
|
+
export { WOFPostcodeLookup, type PostcodePlace } from "#postcode-point-lookup"
|
|
109
109
|
|
|
110
110
|
export {
|
|
111
111
|
PLACE_BBOX_TABLE,
|
|
@@ -115,9 +115,9 @@ export {
|
|
|
115
115
|
placeSearchFTSExists,
|
|
116
116
|
type BuildPlaceSearchFTSOpts,
|
|
117
117
|
type BuildPlaceSearchFTSResult,
|
|
118
|
-
} from "
|
|
118
|
+
} from "#fts/index"
|
|
119
119
|
|
|
120
|
-
export { PLACETYPE_DEPTH, ancestorLineage, placetypeDepth, type AncestorPlaceRow } from "
|
|
120
|
+
export { PLACETYPE_DEPTH, ancestorLineage, placetypeDepth, type AncestorPlaceRow } from "#ancestry/index"
|
|
121
121
|
|
|
122
122
|
export {
|
|
123
123
|
WOFReverseGeocoder,
|
|
@@ -125,31 +125,31 @@ export {
|
|
|
125
125
|
type ReverseGeocodeOpts,
|
|
126
126
|
type ReverseGeocodeResult,
|
|
127
127
|
type WOFReverseGeocoderOpts,
|
|
128
|
-
} from "
|
|
128
|
+
} from "#reverse"
|
|
129
129
|
|
|
130
|
-
export { AddressPointInterpolator } from "
|
|
131
|
-
export { AddressPointSqliteLookup } from "
|
|
130
|
+
export { AddressPointInterpolator } from "#address/point-interpolation"
|
|
131
|
+
export { AddressPointSqliteLookup } from "#address/point"
|
|
132
132
|
|
|
133
133
|
export {
|
|
134
134
|
STREET_CENTROID_COLUMNS,
|
|
135
135
|
createStreetCentroidIndexes,
|
|
136
136
|
createStreetCentroidTable,
|
|
137
|
-
} from "
|
|
137
|
+
} from "#street/centroid-schema"
|
|
138
138
|
|
|
139
|
-
export type { StreetCentroidDatabase, StreetCentroidTable } from "
|
|
140
|
-
export { StreetCentroidSqliteLookup } from "
|
|
139
|
+
export type { StreetCentroidDatabase, StreetCentroidTable } from "#street/centroid-schema"
|
|
140
|
+
export { StreetCentroidSqliteLookup } from "#street/centroid"
|
|
141
141
|
|
|
142
142
|
export {
|
|
143
143
|
StreetInterpolator,
|
|
144
144
|
type InterpolatedHit,
|
|
145
145
|
type InterpolationMethod,
|
|
146
146
|
type InterpolationQuery,
|
|
147
|
-
} from "
|
|
147
|
+
} from "#interpolation"
|
|
148
148
|
|
|
149
149
|
export {
|
|
150
150
|
deriveSchemaName,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
type
|
|
154
|
-
type
|
|
155
|
-
} from "
|
|
151
|
+
pickExtractForPlacetype,
|
|
152
|
+
resolveExtracts,
|
|
153
|
+
type ResolvedExtract,
|
|
154
|
+
type ExtractConfig,
|
|
155
|
+
} from "#extracts"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* then linear interpolation along the segment polyline. Design:
|
|
9
9
|
* `docs/articles/plan/2026-06-11-interpolation-design.md`.
|
|
10
10
|
*
|
|
11
|
-
* Reads the per-state
|
|
11
|
+
* Reads the per-state extract built by `scripts/build-interpolation-extract.ts` (`street_segment`: one
|
|
12
12
|
* row per TIGER edge SIDE — independent left/right ranges, ZIPs, parity). Query-side
|
|
13
13
|
* normalization is THE shared normalizer (`street-normalize.ts`) — identical to build-side, by
|
|
14
14
|
* construction.
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
* `AddressPointLookup.find()` to keep that wiring mechanical.
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
import { parseJSONStrict } from "@mailwoman/core/objects"
|
|
29
|
+
import { parseJSONStrict } from "@mailwoman/core/json"
|
|
32
30
|
import type { InterpolationLookup } from "@mailwoman/resolver"
|
|
33
31
|
import { clampFraction, haversineKm, pointAlong } from "@mailwoman/spatial"
|
|
32
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
34
33
|
|
|
35
|
-
import { hasTable, prepareAll, type PreparedAll } from "
|
|
36
|
-
import { canonicalizeRouteKey, type RouteKey, streetKeyVariants } from "
|
|
34
|
+
import { hasTable, prepareAll, type PreparedAll } from "#sqlite-utils"
|
|
35
|
+
import { canonicalizeRouteKey, type RouteKey, streetKeyVariants } from "#street/normalize"
|
|
36
|
+
import type { StreetSegmentDatabase } from "#street/segment-schema"
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* How an interpolated answer was computed (#483 Method 2):
|
|
40
40
|
*
|
|
41
|
-
* - `address_point` — bracketed/extrapolated between REAL neighbor points from the #476
|
|
41
|
+
* - `address_point` — bracketed/extrapolated between REAL neighbor points from the #476 extract
|
|
42
42
|
* (`AddressPointInterpolator`), replacing TIGER's uniform-spacing assumption with occupancy.
|
|
43
43
|
* - `tiger_range` — linear position within a TIGER segment's theoretical house-number range (`StreetInterpolator`), the
|
|
44
44
|
* fallback for streets too sparse to bracket.
|
|
@@ -166,27 +166,31 @@ function nearestPostcodeGroup(pool: readonly SegmentRow[], near: { lat: number;
|
|
|
166
166
|
return winner.rows
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
export class StreetInterpolator
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
export class StreetInterpolator<
|
|
170
|
+
DB extends StreetSegmentDatabase = StreetSegmentDatabase,
|
|
171
|
+
> implements InterpolationLookup {
|
|
172
|
+
readonly #db: DatabaseClient<DB>
|
|
173
|
+
/**
|
|
174
|
+
* Resources this instance opened. A connection handed in by a caller is NOT in here, so disposal cannot reach it —
|
|
175
|
+
* ownership is membership rather than a flag a later branch has to check.
|
|
176
|
+
*/
|
|
177
|
+
readonly #resources = new DisposableStack()
|
|
172
178
|
readonly #byPostcode:
|
|
173
179
|
| PreparedAll<[postcode: string, street: RouteKey, minNumber: number, maxNumber: number], SegmentRow>
|
|
174
180
|
| undefined
|
|
175
181
|
readonly #byStreet: PreparedAll<[street: RouteKey, minNumber: number, maxNumber: number], SegmentRow> | undefined
|
|
176
182
|
readonly #radiusCalibration: number | undefined
|
|
177
183
|
|
|
178
|
-
constructor(opts: { dbPath?: string; database?:
|
|
184
|
+
constructor(opts: { dbPath?: string; database?: DatabaseClient<DB> }) {
|
|
179
185
|
if (opts.database) {
|
|
180
186
|
this.#db = opts.database
|
|
181
|
-
this.#ownsDB = false
|
|
182
187
|
} else if (opts.dbPath) {
|
|
183
|
-
this.#db = new
|
|
184
|
-
this.#ownsDB = true
|
|
188
|
+
this.#db = this.#resources.use(new DatabaseClient<DB>(opts.dbPath, { readOnly: true }))
|
|
185
189
|
} else {
|
|
186
190
|
throw new Error("StreetInterpolator: one of dbPath or database is required")
|
|
187
191
|
}
|
|
188
192
|
|
|
189
|
-
// Degrade gracefully on an empty/tableless
|
|
193
|
+
// Degrade gracefully on an empty/tableless extract (interrupted build, stray 0-byte file): with no
|
|
190
194
|
// `street_segment` table this interpolator is a no-op miss, not a crash that loses the state (#568).
|
|
191
195
|
if (hasTable(this.#db, "street_segment")) {
|
|
192
196
|
const columns = `from_hn, to_hn, min_hn, max_hn, parity, postcode, geometry, source, release`
|
|
@@ -205,9 +209,9 @@ export class StreetInterpolator implements InterpolationLookup {
|
|
|
205
209
|
}
|
|
206
210
|
|
|
207
211
|
// #374 doctrine: the conformal radius multiplier is a property of the calibration set the ARTIFACT was
|
|
208
|
-
// built against, so it ships in the
|
|
212
|
+
// built against, so it ships in the extract's `interp_calibration` metadata table (street-segment-schema.ts)
|
|
209
213
|
// and is read here, once, at open time — sync raw `.prepare()` per the sync-by-interface doctrine
|
|
210
|
-
// (AGENTS.md).
|
|
214
|
+
// (AGENTS.md). Extracts predating the table (the pre-2026-07 fleet) yield `undefined`; callers then fall
|
|
211
215
|
// back to their in-code table, byte-identically.
|
|
212
216
|
if (hasTable(this.#db, "interp_calibration")) {
|
|
213
217
|
const row = this.#db.prepare("SELECT radius_multiplier FROM interp_calibration LIMIT 1").get() as
|
|
@@ -223,9 +227,9 @@ export class StreetInterpolator implements InterpolationLookup {
|
|
|
223
227
|
}
|
|
224
228
|
|
|
225
229
|
/**
|
|
226
|
-
* The artifact's own conformal radius multiplier (#374), read from the
|
|
227
|
-
* construction. `undefined` = the
|
|
228
|
-
* artifact default and callers may supply a legacy fallback.
|
|
230
|
+
* The artifact's own conformal radius multiplier (#374), read from the extract's `interp_calibration` metadata table
|
|
231
|
+
* at construction. `undefined` = the extract predates the table (or carries no valid row) — the resolver then applies
|
|
232
|
+
* no artifact default and callers may supply a legacy fallback.
|
|
229
233
|
*/
|
|
230
234
|
get radiusCalibration(): number | undefined {
|
|
231
235
|
return this.#radiusCalibration
|
|
@@ -243,7 +247,7 @@ export class StreetInterpolator implements InterpolationLookup {
|
|
|
243
247
|
// Key-variant ladder (see `streetKeyVariants`): the literal key first, then the doubled-type
|
|
244
248
|
// collapse and the saint↔st register swap. A variant advances the ladder when it produces no
|
|
245
249
|
// ANSWER, not merely no rows — a wrong-register key can cover the number in far-away towns and
|
|
246
|
-
// then fail the ambiguity
|
|
250
|
+
// then fail the ambiguity check ("saint pauls place" reaches Nassau's rows; the Brooklyn answer
|
|
247
251
|
// lives under "st pauls place"), and stopping at rows would eclipse the right variant.
|
|
248
252
|
for (const variant of streetKeyVariants(query.street)) {
|
|
249
253
|
const streetNorm = canonicalizeRouteKey(variant)
|
|
@@ -323,9 +327,7 @@ export class StreetInterpolator implements InterpolationLookup {
|
|
|
323
327
|
}
|
|
324
328
|
}
|
|
325
329
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
this.#db.close()
|
|
329
|
-
}
|
|
330
|
+
[Symbol.dispose](): void {
|
|
331
|
+
this.#resources[Symbol.dispose]()
|
|
330
332
|
}
|
|
331
333
|
}
|