@mailwoman/resolver-wof-sqlite 9.1.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 +36 -20
- package/lib/address/index.ts +9 -0
- package/{address-point-interpolation.ts → lib/address/point-interpolation.ts} +40 -28
- package/{address-point-schema.ts → lib/address/point-schema.ts} +34 -8
- package/lib/address/point.ts +280 -0
- package/{ancestry-backfill.ts → lib/ancestry/backfill.ts} +14 -19
- package/{ancestry.ts → lib/ancestry/index.ts} +13 -8
- package/{build-candidate.ts → lib/build-candidate.ts} +243 -199
- package/{build-slim.ts → lib/build-slim.ts} +153 -168
- package/lib/candidate/alias-bags.ts +56 -0
- package/lib/candidate/ancestors-sidecar.ts +204 -0
- package/lib/candidate/country-display-names.ts +79 -0
- package/lib/candidate/extract-fold.ts +138 -0
- package/lib/candidate/name-roles.ts +238 -0
- package/lib/candidate/own-name.ts +146 -0
- package/lib/candidate/place-attrs.ts +44 -0
- package/lib/candidate-ancestors-schema.ts +195 -0
- package/{candidate-fts.ts → lib/candidate-fts.ts} +7 -5
- package/{candidate-importance.ts → lib/candidate-importance.ts} +54 -57
- package/lib/candidate-lookup.ts +976 -0
- package/{candidate-schema.ts → lib/candidate-schema.ts} +34 -6
- package/lib/candidate-scoring.ts +261 -0
- package/lib/capital-schema.ts +89 -0
- package/lib/capitals.ts +148 -0
- package/{coincident-roles.ts → lib/coincident-roles.ts} +75 -19
- package/{convention.ts → lib/convention/index.ts} +5 -5
- package/lib/convention/schema.ts +72 -0
- package/{coverage-manifest-schema.ts → lib/coverage-manifest-schema.ts} +15 -16
- package/lib/currency-backfill.ts +334 -0
- package/lib/env.ts +50 -0
- package/lib/exact-match.ts +113 -0
- package/{sharding.ts → lib/extracts.ts} +63 -60
- package/lib/fst/autocomplete.ts +176 -0
- package/{fst-builder.ts → lib/fst/builder.ts} +30 -27
- 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} +42 -75
- 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} +28 -23
- package/{fts-query.ts → lib/fts/query.ts} +2 -2
- 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} +16 -15
- package/{index.ts → lib/index.ts} +52 -48
- package/{interpolation.ts → lib/interpolation.ts} +137 -41
- package/lib/lookup.ts +861 -0
- package/{name-score.ts → lib/name-score.ts} +6 -4
- 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} +70 -22
- package/lib/poi/index.ts +8 -0
- package/{poi-lookup.ts → lib/poi/lookup.ts} +32 -39
- package/{poi-schema.ts → lib/poi/schema.ts} +10 -6
- package/lib/polygon-schema.ts +47 -0
- package/{postal-city-alias-lookup.ts → lib/postal/city-alias-lookup.ts} +15 -21
- package/{postal-city-candidate-schema.ts → lib/postal/city-candidate-schema.ts} +4 -2
- package/lib/postal/index.ts +9 -0
- package/{postcode-point-lookup.ts → lib/postcode-point-lookup.ts} +17 -15
- package/lib/primary-preference.ts +226 -0
- package/lib/proximity-rerank.ts +120 -0
- package/{ranking-weights.ts → lib/ranking-weights.ts} +30 -4
- package/lib/region-keys.ts +144 -0
- package/{reverse.ts → lib/reverse.ts} +45 -56
- package/{schema.ts → lib/schema.ts} +11 -1
- package/lib/search-fetch.ts +257 -0
- package/{sqlite-convention-source.ts → lib/sqlite-convention-source.ts} +9 -10
- package/lib/sqlite-utils.ts +83 -0
- package/{street-centroid-schema.ts → lib/street/centroid-schema.ts} +12 -6
- package/{street-centroid.ts → lib/street/centroid.ts} +26 -28
- 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/lib/street/normalize.ts +572 -0
- package/{street-segment-schema.ts → lib/street/segment-schema.ts} +13 -8
- package/{types.ts → lib/types.ts} +49 -9
- package/{unified-schema.ts → lib/unified-schema.ts} +21 -25
- package/lib/uprn/existence.ts +84 -0
- package/lib/uprn/index.ts +9 -0
- package/lib/uprn/lookup.ts +206 -0
- package/lib/uprn/schema.ts +124 -0
- 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} +29 -23
- package/out/address/point-interpolation.js.map +1 -0
- package/out/{address-point-schema.d.ts → address/point-schema.d.ts} +30 -10
- 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 +191 -0
- 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} +6 -5
- package/out/ancestry/index.d.ts.map +1 -0
- package/out/{ancestry.js → ancestry/index.js} +7 -7
- package/out/ancestry/index.js.map +1 -0
- package/out/build-candidate.d.ts +88 -7
- package/out/build-candidate.d.ts.map +1 -1
- package/out/build-candidate.js +145 -149
- package/out/build-candidate.js.map +1 -1
- package/out/build-slim.d.ts +5 -5
- package/out/build-slim.d.ts.map +1 -1
- package/out/build-slim.js +127 -142
- package/out/build-slim.js.map +1 -1
- package/out/candidate/alias-bags.d.ts +19 -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 +32 -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/extract-fold.d.ts +32 -0
- package/out/candidate/extract-fold.d.ts.map +1 -0
- package/out/candidate/extract-fold.js +104 -0
- package/out/candidate/extract-fold.js.map +1 -0
- package/out/candidate/name-roles.d.ts +57 -0
- package/out/candidate/name-roles.d.ts.map +1 -0
- package/out/candidate/name-roles.js +166 -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-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 +7 -5
- package/out/candidate-fts.d.ts.map +1 -1
- package/out/candidate-fts.js +5 -3
- 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 +47 -52
- package/out/candidate-importance.js.map +1 -1
- package/out/candidate-lookup.d.ts +31 -52
- package/out/candidate-lookup.d.ts.map +1 -1
- package/out/candidate-lookup.js +380 -172
- package/out/candidate-lookup.js.map +1 -1
- package/out/candidate-schema.d.ts +31 -7
- package/out/candidate-schema.d.ts.map +1 -1
- package/out/candidate-schema.js +3 -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 +196 -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 +12 -4
- package/out/coincident-roles.d.ts.map +1 -1
- package/out/coincident-roles.js +43 -11
- package/out/coincident-roles.js.map +1 -1
- package/out/{convention.d.ts → convention/index.d.ts} +5 -5
- package/out/convention/index.d.ts.map +1 -0
- package/out/{convention.js → convention/index.js} +4 -4
- package/out/convention/index.js.map +1 -0
- 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/coverage-manifest-schema.d.ts +8 -8
- package/out/coverage-manifest-schema.d.ts.map +1 -1
- package/out/coverage-manifest-schema.js +6 -10
- package/out/coverage-manifest-schema.js.map +1 -1
- package/out/currency-backfill.d.ts +90 -0
- package/out/currency-backfill.d.ts.map +1 -0
- package/out/currency-backfill.js +196 -0
- package/out/currency-backfill.js.map +1 -0
- 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 +25 -0
- package/out/exact-match.d.ts.map +1 -0
- package/out/exact-match.js +88 -0
- package/out/exact-match.js.map +1 -0
- 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} +13 -13
- package/out/fst/autocomplete.d.ts.map +1 -0
- package/out/fst/autocomplete.js +113 -0
- 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} +24 -24
- 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} +11 -14
- package/out/fst/freshness.d.ts.map +1 -0
- package/out/{fst-freshness.js → fst/freshness.js} +42 -74
- 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} +20 -13
- package/out/fts/index.d.ts.map +1 -0
- package/out/{fts.js → fts/index.js} +20 -15
- 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} +2 -2
- 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} +12 -10
- package/out/geonames/postal.d.ts.map +1 -0
- package/out/{geonames-postal.js → geonames/postal.js} +11 -11
- package/out/geonames/postal.js.map +1 -0
- package/out/index.d.ts +32 -31
- 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 +18 -9
- package/out/interpolation.d.ts.map +1 -1
- package/out/interpolation.js +108 -36
- package/out/interpolation.js.map +1 -1
- package/out/lookup.d.ts +25 -25
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +174 -558
- 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/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 +47 -10
- package/out/place-importance-schema.d.ts.map +1 -1
- package/out/place-importance-schema.js +56 -10
- 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} +24 -29
- package/out/poi/lookup.js.map +1 -0
- package/out/{poi-schema.d.ts → poi/schema.d.ts} +10 -6
- 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 +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 → postal/city-alias-lookup.d.ts} +7 -6
- package/out/postal/city-alias-lookup.d.ts.map +1 -0
- package/out/{postal-city-alias-lookup.js → postal/city-alias-lookup.js} +12 -16
- 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} +4 -3
- package/out/postal/city-candidate-schema.d.ts.map +1 -0
- 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 +133 -0
- package/out/primary-preference.d.ts.map +1 -0
- package/out/primary-preference.js +146 -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/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 +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 +6 -6
- package/out/reverse.d.ts.map +1 -1
- package/out/reverse.js +23 -35
- package/out/reverse.js.map +1 -1
- package/out/schema.d.ts +10 -1
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js.map +1 -1
- package/out/search-fetch.d.ts +59 -0
- package/out/search-fetch.d.ts.map +1 -0
- package/out/search-fetch.js +184 -0
- package/out/search-fetch.js.map +1 -0
- 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 +24 -6
- package/out/sqlite-utils.d.ts.map +1 -1
- package/out/sqlite-utils.js +24 -7
- package/out/sqlite-utils.js.map +1 -1
- package/out/{street-centroid-schema.d.ts → street/centroid-schema.d.ts} +12 -7
- package/out/street/centroid-schema.d.ts.map +1 -0
- 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} +18 -24
- 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 +179 -0
- package/out/street/normalize.d.ts.map +1 -0
- package/out/street/normalize.js +457 -0
- package/out/street/normalize.js.map +1 -0
- package/out/{street-segment-schema.d.ts → street/segment-schema.d.ts} +13 -9
- package/out/street/segment-schema.d.ts.map +1 -0
- 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 +49 -9
- package/out/types.d.ts.map +1 -1
- package/out/types.js.map +1 -1
- package/out/unified-schema.d.ts +6 -5
- package/out/unified-schema.d.ts.map +1 -1
- package/out/unified-schema.js +16 -19
- 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 +85 -0
- package/out/uprn/lookup.d.ts.map +1 -0
- package/out/uprn/lookup.js +149 -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 +299 -0
- package/out/weights-overlay-linker.d.ts.map +1 -0
- package/out/weights-overlay-linker.js +511 -0
- package/out/weights-overlay-linker.js.map +1 -0
- package/package.json +622 -154
- package/address-point.ts +0 -125
- package/candidate-lookup.ts +0 -720
- package/fst-autocomplete.ts +0 -204
- package/geo.ts +0 -121
- package/lookup.ts +0 -1354
- 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 +0 -84
- 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/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 +0 -130
- 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/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
- 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/postal-city-candidate-schema.d.ts.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-schema.d.ts.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 +0 -95
- package/out/street-normalize.d.ts.map +0 -1
- package/out/street-normalize.js +0 -272
- package/out/street-normalize.js.map +0 -1
- package/out/street-segment-schema.d.ts.map +0 -1
- package/sqlite-utils.ts +0 -46
- package/street-normalize.ts +0 -318
- /package/{postal-city-alias-schema.ts → lib/postal/city-alias-schema.ts} +0 -0
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
* ABOVE the place every user means. Referentially the suburb wins by 230x on population. One score
|
|
27
27
|
* cannot serve both readers, which is why there are two.
|
|
28
28
|
*
|
|
29
|
-
* THE LEGACY COLUMN STAYS, AND IS DERIVED. `importance`
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* THE LEGACY COLUMN STAYS, AND IS DERIVED. `importance` is written by {@link blendImportance} — the
|
|
30
|
+
* bounded blend the bare-toponym fame consumer (#28) ranks on. It is the CONFLATION, and nothing new
|
|
31
|
+
* should read it; new code reads the split columns.
|
|
32
32
|
*/
|
|
33
|
-
import type {
|
|
33
|
+
import type { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
34
34
|
import type { Kysely } from "kysely";
|
|
35
35
|
/**
|
|
36
36
|
* One row of `place_importance`. Keyed by WOF place id.
|
|
@@ -49,8 +49,8 @@ export interface PlaceImportanceTable {
|
|
|
49
49
|
*/
|
|
50
50
|
encyclopedic: number | null;
|
|
51
51
|
/**
|
|
52
|
-
* DEPRECATED — the pre-split conflation, written
|
|
53
|
-
*
|
|
52
|
+
* DEPRECATED — the pre-split conflation, written by {@link blendImportance} so the bare-toponym fame consumer (#28)
|
|
53
|
+
* keeps one cross-bearer scale. New code reads {@link PlaceImportanceTable.referential} (to rank) or
|
|
54
54
|
* {@link PlaceImportanceTable.encyclopedic} (to display).
|
|
55
55
|
*/
|
|
56
56
|
importance: number;
|
|
@@ -77,6 +77,43 @@ export declare function createPlaceImportanceTable(db: Kysely<PlaceImportanceDat
|
|
|
77
77
|
* the one-stop read for the table: the column and the function that fills it are one hop apart.
|
|
78
78
|
*/
|
|
79
79
|
export { compareReferential, REFERENTIAL_LOG2_SCALE, REFERENTIAL_POPULATION_DIVISOR, REFERENTIAL_SATURATION_POPULATION, referentialFromPopulation, } from "@mailwoman/core/resolver";
|
|
80
|
+
/**
|
|
81
|
+
* The most the encyclopedic channel may raise a place's blended importance above its population-anchored referential
|
|
82
|
+
* score.
|
|
83
|
+
*
|
|
84
|
+
* In referential units 0.25 is 3.5 population doublings (the referential curve divides log2 by 14), so an article can
|
|
85
|
+
* promote a place as if it were up to ~11x its recorded population — never more. The bound exists because the two
|
|
86
|
+
* channels' scales CROSS at the article floor: merely having a Wikipedia article scores ~0.25–0.35, which exceeds the
|
|
87
|
+
* referential score of a mid-size town, so an unbounded blend ranks a 136-person village with an article above a
|
|
88
|
+
* 16,026-person town without one.
|
|
89
|
+
*
|
|
90
|
+
* The value is bracketed by two decided contests, measured on the 2026-08-24 staging build:
|
|
91
|
+
*
|
|
92
|
+
* - `> 0.2282`, or bare `Whitby` stops answering Whitby GB (pop 13,130, referential 0.2729, encyclopedic 0.5496) over
|
|
93
|
+
* Whitby CA (pop 128,377, referential 0.5011) — the #28 design case the fame prior exists to serve.
|
|
94
|
+
* - `< 0.2790`, or bare `Tó`/`To` answers Tó PT (pop 136, referential 0.0131, encyclopedic 0.3375) over Tô BF (pop
|
|
95
|
+
* 16,026, no article) — the `bf-gloss-to-*` board pair.
|
|
96
|
+
*
|
|
97
|
+
* 0.25 sits mid-interval with ~0.02 margin to each bound.
|
|
98
|
+
*/
|
|
99
|
+
export declare const ENCYCLOPEDIC_BOOST_CAP = 0.25;
|
|
100
|
+
/**
|
|
101
|
+
* The legacy `importance` blend — one cross-bearer fame scale for the #28 consumer, derived from the two split
|
|
102
|
+
* channels:
|
|
103
|
+
*
|
|
104
|
+
* - No article → the referential score.
|
|
105
|
+
* - No population evidence (`referential` 0) → the encyclopedic score stands alone: there is nothing to bound the
|
|
106
|
+
* article's claim against, and a constant cap would demote every famous place WOF records no population for
|
|
107
|
+
* (meaning-of-zero: referential 0 is "unmeasured", not "tiny").
|
|
108
|
+
* - Both present → the encyclopedic value clamped to at most {@link ENCYCLOPEDIC_BOOST_CAP} above the referential score,
|
|
109
|
+
* and never below it. The floor half repairs the downward inversion (the Seine-Saint-Denis suburb's weak article
|
|
110
|
+
* scored 0.1173 and REPLACED its referential 0.4716 under the old `COALESCE`, so a 418-person Aude hamlet outranked
|
|
111
|
+
* it 4.8x); the cap half repairs the upward one (`Tó`, above).
|
|
112
|
+
*
|
|
113
|
+
* Scale of the clamp on the 2026-08-24 staging build: of 628,202 article-bearing rows, 209,738 sit above the cap and
|
|
114
|
+
* 13,888 sit below their referential floor; the 305,168 article-without-population rows pass through unchanged.
|
|
115
|
+
*/
|
|
116
|
+
export declare function blendImportance(referential: number, encyclopedic: number | null | undefined): number;
|
|
80
117
|
/**
|
|
81
118
|
* Where a reader's two scores came from. Recorded into the FST stamp so an artifact says, in its own provenance,
|
|
82
119
|
* whether its encyclopedic channel is real, reconstructed, or absent.
|
|
@@ -112,12 +149,12 @@ export type ImportanceSplitSource = (typeof IMPORTANCE_SPLIT_SOURCES)[keyof type
|
|
|
112
149
|
*
|
|
113
150
|
* There is deliberately no ORDER BY counterpart, and there should never be one: §2's policy is that this score is
|
|
114
151
|
* carried and never ranked on. Without the column the select degrades to a literal `NULL` and the join is the empty
|
|
115
|
-
* string, so a pre-split
|
|
152
|
+
* string, so a pre-split extract's query plan is byte-identical to what it was before the split. No shipped gazetteer
|
|
116
153
|
* carries the column yet, so today that degraded form is the only one anything builds.
|
|
117
154
|
*
|
|
118
|
-
* Call it ONCE per
|
|
155
|
+
* Call it ONCE per extract and cache the result — it runs a `PRAGMA`, and the callers are per-keystroke hot.
|
|
119
156
|
*/
|
|
120
|
-
export declare function encyclopedicClauses(db:
|
|
157
|
+
export declare function encyclopedicClauses<DB>(db: DatabaseClient<DB>, schemaName: string): {
|
|
121
158
|
select: string;
|
|
122
159
|
join: string;
|
|
123
160
|
};
|
|
@@ -185,5 +222,5 @@ export interface ImportanceSplit {
|
|
|
185
222
|
* builder in particular must read the shipped population-only databases, the read-only 2026-08-05 staging database
|
|
186
223
|
* (legacy conflated column), and post-split builds with one code path.
|
|
187
224
|
*/
|
|
188
|
-
export declare function loadImportanceSplit(db:
|
|
225
|
+
export declare function loadImportanceSplit<DB>(db: DatabaseClient<DB>): ImportanceSplit;
|
|
189
226
|
//# sourceMappingURL=place-importance-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place-importance-schema.d.ts","sourceRoot":"","sources":["../place-importance-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;
|
|
1
|
+
{"version":3,"file":"place-importance-schema.d.ts","sourceRoot":"","sources":["../lib/place-importance-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAMpC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,EAAE,EAAE,MAAM,CAAA;IACV;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,gBAAgB,EAAE,oBAAoB,CAAA;CACtC;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,8DAKuB,CAAA;AAE5D;;;GAGG;AACH,wBAAsB,0BAA0B,CAAC,EAAE,EAAE,MAAM,CAAC,uBAAuB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAUnG;AAMD;;;;GAIG;AACH,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,8BAA8B,EAC9B,iCAAiC,EACjC,yBAAyB,GACzB,MAAM,0BAA0B,CAAA;AAMjC;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAA;AAE1C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAMpG;AAMD;;;GAGG;AACH,eAAO,MAAM,wBAAwB;IACpC;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;CAEM,CAAA;AAEV,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAA;AAE5G;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAiBpH;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,QAAqB,CAAA;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACnC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAQhD;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC;;OAEG;IACH,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,MAAM,EAAE,qBAAqB,CAAA;IAC7B;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAA;CAC1B;AAeD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,GAAG,eAAe,CAgF/E"}
|
|
@@ -26,11 +26,12 @@
|
|
|
26
26
|
* ABOVE the place every user means. Referentially the suburb wins by 230x on population. One score
|
|
27
27
|
* cannot serve both readers, which is why there are two.
|
|
28
28
|
*
|
|
29
|
-
* THE LEGACY COLUMN STAYS, AND IS DERIVED. `importance`
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* THE LEGACY COLUMN STAYS, AND IS DERIVED. `importance` is written by {@link blendImportance} — the
|
|
30
|
+
* bounded blend the bare-toponym fame consumer (#28) ranks on. It is the CONFLATION, and nothing new
|
|
31
|
+
* should read it; new code reads the split columns.
|
|
32
32
|
*/
|
|
33
33
|
import { referentialFromPopulation } from "@mailwoman/core/resolver";
|
|
34
|
+
import { allRows } from "#sqlite-utils";
|
|
34
35
|
/**
|
|
35
36
|
* The columns in declaration order. The builder's INSERT derives its column list from this, so a field added to
|
|
36
37
|
* {@link PlaceImportanceTable} without a matching DDL column is a compile error at the insert site.
|
|
@@ -64,6 +65,51 @@ export async function createPlaceImportanceTable(db) {
|
|
|
64
65
|
*/
|
|
65
66
|
export { compareReferential, REFERENTIAL_LOG2_SCALE, REFERENTIAL_POPULATION_DIVISOR, REFERENTIAL_SATURATION_POPULATION, referentialFromPopulation, } from "@mailwoman/core/resolver";
|
|
66
67
|
//#endregion
|
|
68
|
+
//#region The legacy blend
|
|
69
|
+
/**
|
|
70
|
+
* The most the encyclopedic channel may raise a place's blended importance above its population-anchored referential
|
|
71
|
+
* score.
|
|
72
|
+
*
|
|
73
|
+
* In referential units 0.25 is 3.5 population doublings (the referential curve divides log2 by 14), so an article can
|
|
74
|
+
* promote a place as if it were up to ~11x its recorded population — never more. The bound exists because the two
|
|
75
|
+
* channels' scales CROSS at the article floor: merely having a Wikipedia article scores ~0.25–0.35, which exceeds the
|
|
76
|
+
* referential score of a mid-size town, so an unbounded blend ranks a 136-person village with an article above a
|
|
77
|
+
* 16,026-person town without one.
|
|
78
|
+
*
|
|
79
|
+
* The value is bracketed by two decided contests, measured on the 2026-08-24 staging build:
|
|
80
|
+
*
|
|
81
|
+
* - `> 0.2282`, or bare `Whitby` stops answering Whitby GB (pop 13,130, referential 0.2729, encyclopedic 0.5496) over
|
|
82
|
+
* Whitby CA (pop 128,377, referential 0.5011) — the #28 design case the fame prior exists to serve.
|
|
83
|
+
* - `< 0.2790`, or bare `Tó`/`To` answers Tó PT (pop 136, referential 0.0131, encyclopedic 0.3375) over Tô BF (pop
|
|
84
|
+
* 16,026, no article) — the `bf-gloss-to-*` board pair.
|
|
85
|
+
*
|
|
86
|
+
* 0.25 sits mid-interval with ~0.02 margin to each bound.
|
|
87
|
+
*/
|
|
88
|
+
export const ENCYCLOPEDIC_BOOST_CAP = 0.25;
|
|
89
|
+
/**
|
|
90
|
+
* The legacy `importance` blend — one cross-bearer fame scale for the #28 consumer, derived from the two split
|
|
91
|
+
* channels:
|
|
92
|
+
*
|
|
93
|
+
* - No article → the referential score.
|
|
94
|
+
* - No population evidence (`referential` 0) → the encyclopedic score stands alone: there is nothing to bound the
|
|
95
|
+
* article's claim against, and a constant cap would demote every famous place WOF records no population for
|
|
96
|
+
* (meaning-of-zero: referential 0 is "unmeasured", not "tiny").
|
|
97
|
+
* - Both present → the encyclopedic value clamped to at most {@link ENCYCLOPEDIC_BOOST_CAP} above the referential score,
|
|
98
|
+
* and never below it. The floor half repairs the downward inversion (the Seine-Saint-Denis suburb's weak article
|
|
99
|
+
* scored 0.1173 and REPLACED its referential 0.4716 under the old `COALESCE`, so a 418-person Aude hamlet outranked
|
|
100
|
+
* it 4.8x); the cap half repairs the upward one (`Tó`, above).
|
|
101
|
+
*
|
|
102
|
+
* Scale of the clamp on the 2026-08-24 staging build: of 628,202 article-bearing rows, 209,738 sit above the cap and
|
|
103
|
+
* 13,888 sit below their referential floor; the 305,168 article-without-population rows pass through unchanged.
|
|
104
|
+
*/
|
|
105
|
+
export function blendImportance(referential, encyclopedic) {
|
|
106
|
+
if (encyclopedic === null || encyclopedic === undefined)
|
|
107
|
+
return referential;
|
|
108
|
+
if (referential <= 0)
|
|
109
|
+
return encyclopedic;
|
|
110
|
+
return Math.max(referential, Math.min(encyclopedic, referential + ENCYCLOPEDIC_BOOST_CAP));
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
67
113
|
//#region Reading a database that may or may not carry the split
|
|
68
114
|
/**
|
|
69
115
|
* Where a reader's two scores came from. Recorded into the FST stamp so an artifact says, in its own provenance,
|
|
@@ -99,15 +145,15 @@ export const IMPORTANCE_SPLIT_SOURCES = {
|
|
|
99
145
|
*
|
|
100
146
|
* There is deliberately no ORDER BY counterpart, and there should never be one: §2's policy is that this score is
|
|
101
147
|
* carried and never ranked on. Without the column the select degrades to a literal `NULL` and the join is the empty
|
|
102
|
-
* string, so a pre-split
|
|
148
|
+
* string, so a pre-split extract's query plan is byte-identical to what it was before the split. No shipped gazetteer
|
|
103
149
|
* carries the column yet, so today that degraded form is the only one anything builds.
|
|
104
150
|
*
|
|
105
|
-
* Call it ONCE per
|
|
151
|
+
* Call it ONCE per extract and cache the result — it runs a `PRAGMA`, and the callers are per-keystroke hot.
|
|
106
152
|
*/
|
|
107
153
|
export function encyclopedicClauses(db, schemaName) {
|
|
108
154
|
let present;
|
|
109
155
|
try {
|
|
110
|
-
const rows = db.prepare(`PRAGMA ${schemaName}.table_info(place_importance)`)
|
|
156
|
+
const rows = allRows(db.prepare(`PRAGMA ${schemaName}.table_info(place_importance)`));
|
|
111
157
|
present = rows.some((r) => r.name === "encyclopedic");
|
|
112
158
|
}
|
|
113
159
|
catch {
|
|
@@ -167,7 +213,7 @@ export function splitLegacyImportance(legacy, population) {
|
|
|
167
213
|
*/
|
|
168
214
|
function tableColumns(db, table) {
|
|
169
215
|
try {
|
|
170
|
-
const rows = db.prepare(`PRAGMA table_info(${table})`)
|
|
216
|
+
const rows = allRows(db.prepare(`PRAGMA table_info(${table})`));
|
|
171
217
|
return new Set(rows.map((r) => r.name));
|
|
172
218
|
}
|
|
173
219
|
catch {
|
|
@@ -187,7 +233,7 @@ export function loadImportanceSplit(db) {
|
|
|
187
233
|
const population = new Map();
|
|
188
234
|
const populationColumns = tableColumns(db, "place_population");
|
|
189
235
|
if (populationColumns.has("population")) {
|
|
190
|
-
const rows = db.prepare("SELECT id, population FROM place_population")
|
|
236
|
+
const rows = allRows(db.prepare("SELECT id, population FROM place_population"));
|
|
191
237
|
for (const row of rows) {
|
|
192
238
|
population.set(row.id, row.population);
|
|
193
239
|
const score = referentialFromPopulation(row.population);
|
|
@@ -201,7 +247,7 @@ export function loadImportanceSplit(db) {
|
|
|
201
247
|
// Post-split build: the columns ARE the contract. Referential is read verbatim rather than
|
|
202
248
|
// re-derived, so a build that scored referential differently stays visible instead of being
|
|
203
249
|
// silently overwritten by this reader's own formula.
|
|
204
|
-
const rows = db.prepare("SELECT id, referential, encyclopedic FROM place_importance")
|
|
250
|
+
const rows = allRows(db.prepare("SELECT id, referential, encyclopedic FROM place_importance"));
|
|
205
251
|
for (const row of rows) {
|
|
206
252
|
if (row.referential > 0) {
|
|
207
253
|
referential.set(row.id, row.referential);
|
|
@@ -213,7 +259,7 @@ export function loadImportanceSplit(db) {
|
|
|
213
259
|
return { referential, encyclopedic, source: IMPORTANCE_SPLIT_SOURCES.splitColumns, legacyFallbackRows: 0 };
|
|
214
260
|
}
|
|
215
261
|
if (importanceColumns.has("importance")) {
|
|
216
|
-
const rows = db.prepare("SELECT id, importance FROM place_importance")
|
|
262
|
+
const rows = allRows(db.prepare("SELECT id, importance FROM place_importance"));
|
|
217
263
|
let legacyFallbackRows = 0;
|
|
218
264
|
for (const row of rows) {
|
|
219
265
|
const split = splitLegacyImportance(row.importance, population.get(row.id));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place-importance-schema.js","sourceRoot":"","sources":["../place-importance-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;
|
|
1
|
+
{"version":3,"file":"place-importance-schema.js","sourceRoot":"","sources":["../lib/place-importance-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AAIpE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAmCvC;;;GAGG;AACH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qB,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;YAE3E,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;gBACtC,kBAAkB,EAAE,CAAA;YACrB,CAAC;iBAAM,CAAC;gBACP,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,YAAY,CAAC,CAAA;YAC7C,CAAC;QACF,CAAC;QAED,OAAO;YACN,WAAW;YACX,YAAY;YACZ,MAAM,EAAE,wBAAwB,CAAC,mBAAmB;YACpD,kBAAkB;SAClB,CAAA;IACF,CAAC;IAED,OAAO;QACN,WAAW;QACX,YAAY;QACZ,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,wBAAwB,CAAC,cAAc,CAAC,CAAC,CAAC,wBAAwB,CAAC,IAAI;QAClG,kBAAkB,EAAE,CAAC;KACrB,CAAA;AACF,CAAC;AAED,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/poi/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
|
package/out/poi/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/poi/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
* is NEVER reimplemented here (see AGENTS.md on `@mailwoman/spatial` being the one true home for
|
|
25
25
|
* it).
|
|
26
26
|
*/
|
|
27
|
-
import {
|
|
27
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
28
|
+
import type { POIDatabase } from "#poi/schema";
|
|
28
29
|
/**
|
|
29
30
|
* Resolution the `poi` table's `h3_cell` column is keyed at — matches the builder (spec §3.4).
|
|
30
31
|
*/
|
|
@@ -77,7 +78,7 @@ export interface POISearchHit {
|
|
|
77
78
|
gersID: string | null;
|
|
78
79
|
distanceM?: number;
|
|
79
80
|
}
|
|
80
|
-
export interface POILookupOpts {
|
|
81
|
+
export interface POILookupOpts<DB extends POIDatabase = POIDatabase> {
|
|
81
82
|
/**
|
|
82
83
|
* Path to a `poi.db` built by the (future) POI builder. Opened read-only.
|
|
83
84
|
*/
|
|
@@ -85,18 +86,15 @@ export interface POILookupOpts {
|
|
|
85
86
|
/**
|
|
86
87
|
* Pre-opened handle (tests / shared connections). Mutually exclusive with `databasePath`.
|
|
87
88
|
*/
|
|
88
|
-
database?:
|
|
89
|
+
database?: DatabaseClient<DB>;
|
|
89
90
|
}
|
|
90
91
|
/**
|
|
91
|
-
* Node reader over `poi.db`.
|
|
92
|
-
* `[Symbol.dispose]()` explicitly), the same precedent as {@link WOFCandidateTableLookup} /
|
|
93
|
-
* {@link WOFSqlitePlaceLookup}.
|
|
92
|
+
* Node reader over `poi.db`.
|
|
94
93
|
*/
|
|
95
|
-
export declare class POILookup implements Disposable {
|
|
94
|
+
export declare class POILookup<DB extends POIDatabase = POIDatabase> implements Disposable {
|
|
96
95
|
#private;
|
|
97
|
-
constructor(opts: POILookupOpts);
|
|
96
|
+
constructor(opts: POILookupOpts<DB>);
|
|
98
97
|
search(query: POISearchQuery): POISearchHit[];
|
|
99
|
-
close(): void;
|
|
100
98
|
[Symbol.dispose](): void;
|
|
101
99
|
}
|
|
102
|
-
//# sourceMappingURL=
|
|
100
|
+
//# sourceMappingURL=lookup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../lib/poi/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAG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CAAC,KAAK,EAAE,cAAc,GAAG,YAAY,EAAE;IA8J7C,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGxB"}
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
* is NEVER reimplemented here (see AGENTS.md on `@mailwoman/spatial` being the one true home for
|
|
25
25
|
* it).
|
|
26
26
|
*/
|
|
27
|
-
import { DatabaseSync } from "node:sqlite";
|
|
28
27
|
import { haversineKm, shortCellToInt } from "@mailwoman/spatial";
|
|
28
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
29
29
|
import { gridDisk, latLngToCell } from "h3-js";
|
|
30
|
+
import { allRows } from "#sqlite-utils";
|
|
30
31
|
/**
|
|
31
32
|
* Resolution the `poi` table's `h3_cell` column is keyed at — matches the builder (spec §3.4).
|
|
32
33
|
*/
|
|
@@ -41,8 +42,9 @@ export const POI_H3_RESOLUTION = 9;
|
|
|
41
42
|
* unaffected: the loop breaks the ring it accumulates `limit` rows (cafe@Paris fills 20 by ring 2), so this ceiling
|
|
42
43
|
* never enters their probe budget. Only sparse-but-present categories that never reach `limit` scan the fuller budget —
|
|
43
44
|
* a cold, one-shot `mailwoman poi` path, not per-keystroke. 16 (not the bare threshold 14) leaves ~2 rings of margin so
|
|
44
|
-
* the
|
|
45
|
-
* window (no wrong-city false positives). The browser reader passes its own smaller `maxRings` and is
|
|
45
|
+
* the radius is stable against small db rebuilds, while staying ~4x tighter than the board's 25 km "roughly right
|
|
46
|
+
* place" window (no wrong-city false positives). The browser reader passes its own smaller `maxRings` and is
|
|
47
|
+
* untouched.
|
|
46
48
|
*/
|
|
47
49
|
const DEFAULT_MAX_RINGS = 16;
|
|
48
50
|
/**
|
|
@@ -56,13 +58,15 @@ const BRAND_MAX_DISTANCE_KM = 500;
|
|
|
56
58
|
*/
|
|
57
59
|
const DEFAULT_LIMIT = 20;
|
|
58
60
|
/**
|
|
59
|
-
* Node reader over `poi.db`.
|
|
60
|
-
* `[Symbol.dispose]()` explicitly), the same precedent as {@link WOFCandidateTableLookup} /
|
|
61
|
-
* {@link WOFSqlitePlaceLookup}.
|
|
61
|
+
* Node reader over `poi.db`.
|
|
62
62
|
*/
|
|
63
63
|
export class POILookup {
|
|
64
64
|
#db;
|
|
65
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Resources this instance opened. A connection handed in by a caller is NOT in here, so disposal cannot reach it —
|
|
67
|
+
* ownership is membership rather than a flag a later branch has to check.
|
|
68
|
+
*/
|
|
69
|
+
#resources = new DisposableStack();
|
|
66
70
|
#categoryToID = new Map();
|
|
67
71
|
#idToCategory = new Map();
|
|
68
72
|
/**
|
|
@@ -80,20 +84,16 @@ export class POILookup {
|
|
|
80
84
|
constructor(opts) {
|
|
81
85
|
if (opts.database) {
|
|
82
86
|
this.#db = opts.database;
|
|
83
|
-
this.#ownsDB = false;
|
|
84
87
|
}
|
|
85
88
|
else if (opts.databasePath) {
|
|
86
|
-
this.#db = new
|
|
87
|
-
this.#ownsDB = true;
|
|
89
|
+
this.#db = this.#resources.use(new DatabaseClient(opts.databasePath, { readOnly: true }));
|
|
88
90
|
}
|
|
89
91
|
else {
|
|
90
92
|
throw new Error("POILookup needs `databasePath` or `database`");
|
|
91
93
|
}
|
|
92
94
|
// The category dictionary is tiny (poi-taxonomy's category count) — load it once at
|
|
93
95
|
// construction so `search` never round-trips to it.
|
|
94
|
-
for (const r of this.#db
|
|
95
|
-
.prepare("SELECT id, category FROM poi_category_codes")
|
|
96
|
-
.all()) {
|
|
96
|
+
for (const r of allRows(this.#db.prepare("SELECT id, category FROM poi_category_codes"))) {
|
|
97
97
|
this.#categoryToID.set(String(r.category), Number(r.id));
|
|
98
98
|
this.#idToCategory.set(Number(r.id), String(r.category));
|
|
99
99
|
}
|
|
@@ -127,7 +127,7 @@ export class POILookup {
|
|
|
127
127
|
* nearest at any distance — the reach ceiling k-ring hits on sparse brand rows is gone.
|
|
128
128
|
*/
|
|
129
129
|
#searchBrand(brandWikidata, center, limit) {
|
|
130
|
-
const rows = this.#brandProbe
|
|
130
|
+
const rows = allRows(this.#brandProbe, brandWikidata);
|
|
131
131
|
return sortByDistance(rows, center)
|
|
132
132
|
.filter((row) => haversineKm(center.latitude, center.longitude, row.latitude, row.longitude) <= BRAND_MAX_DISTANCE_KM)
|
|
133
133
|
.slice(0, limit)
|
|
@@ -139,18 +139,18 @@ export class POILookup {
|
|
|
139
139
|
#searchKRing(query, limit) {
|
|
140
140
|
const center = query.center;
|
|
141
141
|
const maxRings = query.maxRings ?? DEFAULT_MAX_RINGS;
|
|
142
|
-
const
|
|
142
|
+
const categoryIDs = [];
|
|
143
143
|
// `categoryIDs` (the fan-out list) supersedes the single `categoryID`; either way, resolve each id through the
|
|
144
144
|
// dictionary and drop the ones the db doesn't carry (Overture-taxonomy drift, or an identity id with no rows).
|
|
145
145
|
const seedIDs = query.categoryIDs?.length ? query.categoryIDs : query.categoryID ? [query.categoryID] : [];
|
|
146
146
|
for (const id of seedIDs) {
|
|
147
147
|
const resolved = this.#categoryToID.get(id);
|
|
148
148
|
if (resolved !== undefined) {
|
|
149
|
-
|
|
149
|
+
categoryIDs.push(resolved);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
// No resolvable leaf (every id unknown to the dictionary) can't have rows — a clean miss, not a throw.
|
|
153
|
-
if (!
|
|
153
|
+
if (!categoryIDs.length)
|
|
154
154
|
return [];
|
|
155
155
|
const origin = latLngToCell(center.latitude, center.longitude, POI_H3_RESOLUTION);
|
|
156
156
|
const seenCells = new Set();
|
|
@@ -166,8 +166,8 @@ export class POILookup {
|
|
|
166
166
|
const shortCell = shortCellToInt(cell);
|
|
167
167
|
// Fan-out: probe every resolved Overture leaf for this canonical category, unioning the rows. The
|
|
168
168
|
// post-ring distance sort + `slice(0, limit)` below dedupes the pool down to the nearest `limit`.
|
|
169
|
-
for (const categoryID of
|
|
170
|
-
rows.push(...this.#categoryCellProbe
|
|
169
|
+
for (const categoryID of categoryIDs) {
|
|
170
|
+
rows.push(...allRows(this.#categoryCellProbe, shortCell, categoryID, limit));
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
rows = sortByDistance(rows, center);
|
|
@@ -187,7 +187,7 @@ export class POILookup {
|
|
|
187
187
|
const matchQuery = sanitizePOINameQuery(name);
|
|
188
188
|
if (!matchQuery)
|
|
189
189
|
return [];
|
|
190
|
-
const ftsHits = this.#nameFTSProbe
|
|
190
|
+
const ftsHits = allRows(this.#nameFTSProbe, matchQuery, limit);
|
|
191
191
|
const uniqueKeys = [];
|
|
192
192
|
const seenKeys = new Set();
|
|
193
193
|
for (const hit of ftsHits) {
|
|
@@ -229,15 +229,10 @@ export class POILookup {
|
|
|
229
229
|
const columns = "name, category_id, brand_wikidata, latitude, longitude, country, confidence, name_key, gers_id";
|
|
230
230
|
const placeholders = nameKeys.map(() => "?").join(", ");
|
|
231
231
|
const stmt = this.#db.prepare(`SELECT ${columns} FROM poi WHERE name_key IN (${placeholders})`);
|
|
232
|
-
return stmt
|
|
233
|
-
}
|
|
234
|
-
close() {
|
|
235
|
-
if (this.#ownsDB) {
|
|
236
|
-
this.#db.close();
|
|
237
|
-
}
|
|
232
|
+
return allRows(stmt, ...nameKeys);
|
|
238
233
|
}
|
|
239
234
|
[Symbol.dispose]() {
|
|
240
|
-
this.
|
|
235
|
+
this.#resources[Symbol.dispose]();
|
|
241
236
|
}
|
|
242
237
|
}
|
|
243
238
|
function sortByDistance(rows, center) {
|
|
@@ -273,8 +268,8 @@ function sanitizePOINameQuery(text) {
|
|
|
273
268
|
.replaceAll(/["*:]/g, "")
|
|
274
269
|
.trim()
|
|
275
270
|
.split(/\s+/u)
|
|
276
|
-
.filter(
|
|
271
|
+
.filter((token) => token.length > 0)
|
|
277
272
|
.map((token) => `"${token.replaceAll('"', '""')}"`)
|
|
278
273
|
.join(" ");
|
|
279
274
|
}
|
|
280
|
-
//# sourceMappingURL=
|
|
275
|
+
//# sourceMappingURL=lookup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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AG,CAAC,QAAQ,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE;YACnG,CAAC,CAAC,EAAE,CAAC;KACN,CAAA;AACF,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,oBAAoB,CAAC,IAAY;IACzC,OAAO,IAAI;SACT,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC;SACxB,IAAI,EAAE;SACN,KAAK,CAAC,MAAM,CAAC;SACb,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;SACnC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;SAClD,IAAI,CAAC,GAAG,CAAC,CAAA;AACZ,CAAC"}
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
* embeds the layer-contract tables from `@mailwoman/core/layers` — the builder writes the
|
|
12
12
|
* manifest (tier `shipped`, spine `h3` res 9) and per-res-6-cell coverage.
|
|
13
13
|
*/
|
|
14
|
-
import type { DatabaseSync } from "node:sqlite";
|
|
15
14
|
import type { LayerContractDatabase } from "@mailwoman/core/layers";
|
|
15
|
+
import type { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
16
16
|
import { type Kysely } from "kysely";
|
|
17
|
+
import type { NameKey } from "#street/normalize";
|
|
17
18
|
/**
|
|
18
19
|
* One POI row. Clustered PK: h3_cell → category_id → neg_rank → rowid_key.
|
|
19
20
|
*/
|
|
@@ -36,9 +37,12 @@ export interface POITable {
|
|
|
36
37
|
rowid_key: number;
|
|
37
38
|
name: string | null;
|
|
38
39
|
/**
|
|
39
|
-
*
|
|
40
|
+
* Probe key for exact name lookups, minted by {@link normalizeLocalityForKey} at build AND at query.
|
|
41
|
+
*
|
|
42
|
+
* Branded because a `toLowerCase()` approximation of the fold is still a `string`: it binds to the parameter, returns
|
|
43
|
+
* fewer rows, and the shortfall reads as a coverage gap in the data rather than a defect in the probe.
|
|
40
44
|
*/
|
|
41
|
-
name_key:
|
|
45
|
+
name_key: NameKey | null;
|
|
42
46
|
brand_wikidata: string | null;
|
|
43
47
|
latitude: number;
|
|
44
48
|
longitude: number;
|
|
@@ -65,7 +69,7 @@ export interface POIStageTable {
|
|
|
65
69
|
neg_rank: number | null;
|
|
66
70
|
rowid_key: number | null;
|
|
67
71
|
name: string | null;
|
|
68
|
-
name_key:
|
|
72
|
+
name_key: NameKey | null;
|
|
69
73
|
brand_wikidata: string | null;
|
|
70
74
|
latitude: number;
|
|
71
75
|
longitude: number;
|
|
@@ -111,5 +115,5 @@ export declare const POI_FTS_TABLE = "poi_search";
|
|
|
111
115
|
/**
|
|
112
116
|
* FTS5 stays raw SQL by project rule (Kysely can't express virtual tables). Content-keyed by name_key.
|
|
113
117
|
*/
|
|
114
|
-
export declare function createPOISearchFTS(db:
|
|
115
|
-
//# sourceMappingURL=
|
|
118
|
+
export declare function createPOISearchFTS<DB>(db: DatabaseClient<DB>): void;
|
|
119
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../lib/poi/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAO,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,SAAS,EAAE,MAA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AAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBnF;AAED,wBAAsB,cAAc,CAAC,EAAE,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAmB3E;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAElF;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,EAAE,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAOhF;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,eAAe,CAAA;AAEzC;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,GAAG,IAAI,CAInE"}
|
|
@@ -103,4 +103,4 @@ export const POI_FTS_TABLE = "poi_search";
|
|
|
103
103
|
export function createPOISearchFTS(db) {
|
|
104
104
|
db.exec(`CREATE VIRTUAL TABLE ${POI_FTS_TABLE} USING fts5(name, name_key UNINDEXED, h3_cell UNINDEXED, tokenize = 'unicode61')`);
|
|
105
105
|
}
|
|
106
|
-
//# sourceMappingURL=
|
|
106
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../lib/poi/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,GAAG,EAAe,MAAM,QAAQ,CAAA;AAkFzC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B,SAAS;IACT,aAAa;IACb,UAAU;IACV,WAAW;IACX,MAAM;IACN,UAAU;IACV,gBAAgB;IAChB,UAAU;IACV,WAAW;IACX,SAAS;IACT,YAAY;IACZ,SAAS;CACA,CAAA;AAEV,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,EAAuB;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CAAC,EAAuB;IAChE,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,oBAAoB,CAAC;SACjC,EAAE,CAAC,KAAK,CAAC;SACT,MAAM,CAAC,gBAAgB,CAAC;SACxB,KAAK,CAAC,gBAAgB,EAAE,QAAQ,EAAE,IAAI,CAAC;SACvC,OAAO,EAAE,CAAA;AACZ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAA;AAEzC;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAK,EAAsB;IAC5D,EAAE,CAAC,IAAI,CACN,wBAAwB,aAAa,kFAAkF,CACvH,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Typed schema for the polygon sidecar (`wof-polygons.db`) — the one table `WOFReverseGeocoder` probes for a
|
|
7
|
+
* place's geometry. The interface is the read/write contract and {@link createPolygonsTable} creates the table, so a
|
|
8
|
+
* column added to one is a compile error against the other.
|
|
9
|
+
*
|
|
10
|
+
* The sidecar is OPTIONAL to the reverse geocoder: without it every result falls back to a centroid, so the reader
|
|
11
|
+
* checks for the table's presence rather than assuming it.
|
|
12
|
+
*/
|
|
13
|
+
import type { Kysely } from "kysely";
|
|
14
|
+
/**
|
|
15
|
+
* One admin polygon, keyed by WOF id.
|
|
16
|
+
*/
|
|
17
|
+
export interface PolygonsTable {
|
|
18
|
+
id: number;
|
|
19
|
+
/**
|
|
20
|
+
* The GeoJSON geometry, JSON-encoded. A row that fails to parse reads as no-polygon, never as an error — a malformed
|
|
21
|
+
* geometry must not fail the whole reverse query.
|
|
22
|
+
*/
|
|
23
|
+
geom: string;
|
|
24
|
+
}
|
|
25
|
+
export interface PolygonDatabase {
|
|
26
|
+
polygons: PolygonsTable;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The slice of a Kysely handle the polygon DDL touches. Kysely is invariant in its schema parameter, so naming only
|
|
30
|
+
* `schema` lets a builder holding a wider handle pass it without a cast.
|
|
31
|
+
*/
|
|
32
|
+
export type PolygonSchemaHandle = Pick<Kysely<PolygonDatabase>, "schema">;
|
|
33
|
+
/**
|
|
34
|
+
* Create the `polygons` table — called before the streaming bulk load.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createPolygonsTable(db: PolygonSchemaHandle): Promise<void>;
|
|
37
|
+
//# sourceMappingURL=polygon-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polygon-schema.d.ts","sourceRoot":"","sources":["../lib/polygon-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,EAAE,aAAa,CAAA;CACvB;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,CAAA;AAEzE;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Typed schema for the polygon sidecar (`wof-polygons.db`) — the one table `WOFReverseGeocoder` probes for a
|
|
7
|
+
* place's geometry. The interface is the read/write contract and {@link createPolygonsTable} creates the table, so a
|
|
8
|
+
* column added to one is a compile error against the other.
|
|
9
|
+
*
|
|
10
|
+
* The sidecar is OPTIONAL to the reverse geocoder: without it every result falls back to a centroid, so the reader
|
|
11
|
+
* checks for the table's presence rather than assuming it.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Create the `polygons` table — called before the streaming bulk load.
|
|
15
|
+
*/
|
|
16
|
+
export async function createPolygonsTable(db) {
|
|
17
|
+
await db.schema
|
|
18
|
+
.createTable("polygons")
|
|
19
|
+
.addColumn("id", "integer", (column) => column.primaryKey())
|
|
20
|
+
.addColumn("geom", "text", (column) => column.notNull())
|
|
21
|
+
.execute();
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=polygon-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polygon-schema.js","sourceRoot":"","sources":["../lib/polygon-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA0BH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,EAAuB;IAChE,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,UAAU,CAAC;SACvB,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;SAC3D,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;SACvD,OAAO,EAAE,CAAA;AACZ,CAAC"}
|