@mailwoman/resolver-wof-sqlite 10.8.0 → 11.1.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 +1 -1
- package/lib/address/duplicate.ts +133 -0
- package/lib/address/keys/attribution.ts +119 -0
- package/lib/address/keys/build.ts +768 -0
- package/lib/address/keys/layout.ts +166 -0
- package/lib/address/keys/local-runner.ts +18 -0
- package/lib/address/keys/lookup.ts +205 -0
- package/lib/address/keys/open.ts +33 -0
- package/lib/address/keys/point-lookup.ts +130 -0
- package/lib/address/keys/postcode.ts +27 -0
- package/lib/address/keys/schema.ts +264 -0
- package/lib/address/number-forms.ts +61 -0
- package/lib/address/point/interpolation.ts +28 -23
- package/lib/address/point/schema.ts +2 -5
- package/lib/address/point/spine-schema.ts +4 -4
- package/lib/address/point.ts +18 -42
- package/lib/address/record.ts +155 -0
- package/lib/address/stack.ts +20 -0
- package/lib/address/subdivision-bounds.ts +81 -0
- package/lib/address.ts +2 -5
- package/lib/ancestry/backfill.ts +5 -4
- package/lib/ancestry.ts +10 -10
- package/lib/build/candidate.ts +2 -46
- package/lib/build/population-corrections.ts +4 -4
- package/lib/build/slim.ts +3 -25
- package/lib/candidate/alias-bags.ts +4 -4
- package/lib/candidate/ancestors/schema.ts +63 -43
- package/lib/candidate/ancestors/sidecar.ts +3 -3
- package/lib/candidate/bare-admin-names.ts +3 -3
- package/lib/candidate/country-display-names.ts +2 -5
- package/lib/candidate/extract-fold.ts +2 -5
- package/lib/candidate/fts.ts +5 -5
- package/lib/candidate/importance.ts +29 -24
- package/lib/candidate/lookup.ts +11 -9
- package/lib/candidate/name-roles.ts +4 -4
- package/lib/candidate/own-name.ts +12 -10
- package/lib/candidate/place-attrs.ts +4 -4
- package/lib/candidate/schema.ts +2 -5
- package/lib/candidate/scoring.ts +3 -6
- package/lib/capital-schema.ts +11 -10
- package/lib/capitals.ts +15 -12
- package/lib/convention/schema.ts +7 -7
- package/lib/convention.ts +3 -3
- package/lib/coverage-manifest-schema.ts +4 -4
- package/lib/env.ts +7 -6
- package/lib/exact-match.ts +6 -7
- package/lib/extracts.ts +11 -9
- package/lib/fst/autocomplete.ts +19 -15
- package/lib/fst/binary-matcher.ts +10 -9
- package/lib/fst/builder.ts +32 -11
- package/lib/fst/deserialize-web.ts +9 -8
- package/lib/fst/format.ts +9 -7
- package/lib/fst/freshness.ts +3 -4
- package/lib/fst/matcher.ts +6 -6
- package/lib/fst/serialize.ts +5 -9
- package/lib/fst/types.ts +4 -4
- package/lib/fst.ts +2 -5
- package/lib/fts/query.ts +3 -4
- package/lib/fts.ts +2 -5
- package/lib/geonames/aliases.ts +193 -43
- package/lib/geonames/postal.ts +17 -15
- package/lib/geonames.ts +2 -5
- package/lib/index.ts +4 -6
- package/lib/interpolation.ts +7 -6
- package/lib/landmark/rows.ts +91 -0
- package/lib/landmark.ts +94 -0
- package/lib/lookup.ts +9 -29
- package/lib/name-score.ts +7 -6
- package/lib/nsul/lookup.ts +19 -15
- package/lib/nsul/schema.ts +4 -5
- package/lib/nsul.ts +2 -5
- package/lib/paths.ts +7 -7
- package/lib/place-importance-schema.ts +5 -8
- package/lib/poi/lookup.ts +11 -10
- package/lib/poi/schema.ts +16 -10
- package/lib/poi.ts +2 -5
- package/lib/polygon-schema.ts +10 -9
- package/lib/postal/city/alias/lookup.ts +14 -13
- package/lib/postal/city/alias/schema.ts +12 -12
- package/lib/postal/city/candidate-schema.ts +15 -12
- package/lib/postal.ts +2 -5
- package/lib/postcode-point-lookup.ts +2 -5
- package/lib/primary-preference.ts +15 -25
- package/lib/proximity-rerank.ts +23 -19
- package/lib/ranking-weights.ts +8 -7
- package/lib/region-keys.ts +15 -14
- package/lib/reverse.ts +16 -17
- package/lib/schema.ts +20 -24
- package/lib/search-fetch.ts +15 -11
- package/lib/sqlite/convention-source.ts +2 -5
- package/lib/sqlite/utils.ts +4 -4
- package/lib/street/centroid/schema.ts +6 -6
- package/lib/street/centroid.ts +3 -3
- package/lib/street/locale.ts +64 -0
- package/lib/street/morphology/fst/builder.ts +21 -19
- package/lib/street/morphology/fst/loader.ts +15 -13
- package/lib/street/name-lookup.ts +15 -14
- package/lib/street/normalize.ts +111 -17
- package/lib/street/segment-schema.ts +16 -14
- package/lib/street/table.ts +276 -0
- package/lib/street.ts +3 -5
- package/lib/types.ts +10 -8
- package/lib/unified-schema.ts +31 -9
- package/lib/uprn/existence.ts +10 -10
- package/lib/uprn/lookup.ts +7 -8
- package/lib/uprn/schema.ts +5 -5
- package/lib/uprn.ts +2 -5
- package/lib/weights-overlay-linker.ts +5 -8
- package/out/address/duplicate.d.ts +74 -0
- package/out/address/duplicate.d.ts.map +1 -0
- package/out/address/duplicate.js +79 -0
- package/out/address/duplicate.js.map +1 -0
- package/out/address/keys/attribution.d.ts +56 -0
- package/out/address/keys/attribution.d.ts.map +1 -0
- package/out/address/keys/attribution.js +64 -0
- package/out/address/keys/attribution.js.map +1 -0
- package/out/address/keys/build.d.ts +154 -0
- package/out/address/keys/build.d.ts.map +1 -0
- package/out/address/keys/build.js +423 -0
- package/out/address/keys/build.js.map +1 -0
- package/out/address/keys/layout.d.ts +92 -0
- package/out/address/keys/layout.d.ts.map +1 -0
- package/out/address/keys/layout.js +87 -0
- package/out/address/keys/layout.js.map +1 -0
- package/out/address/keys/local-runner.d.ts +9 -0
- package/out/address/keys/local-runner.d.ts.map +1 -0
- package/out/address/keys/local-runner.js +13 -0
- package/out/address/keys/local-runner.js.map +1 -0
- package/out/address/keys/lookup.d.ts +80 -0
- package/out/address/keys/lookup.d.ts.map +1 -0
- package/out/address/keys/lookup.js +104 -0
- package/out/address/keys/lookup.js.map +1 -0
- package/out/address/keys/open.d.ts +10 -0
- package/out/address/keys/open.d.ts.map +1 -0
- package/out/address/keys/open.js +28 -0
- package/out/address/keys/open.js.map +1 -0
- package/out/address/keys/point-lookup.d.ts +25 -0
- package/out/address/keys/point-lookup.d.ts.map +1 -0
- package/out/address/keys/point-lookup.js +100 -0
- package/out/address/keys/point-lookup.js.map +1 -0
- package/out/address/keys/postcode.d.ts +9 -0
- package/out/address/keys/postcode.d.ts.map +1 -0
- package/out/address/keys/postcode.js +25 -0
- package/out/address/keys/postcode.js.map +1 -0
- package/out/address/keys/schema.d.ts +156 -0
- package/out/address/keys/schema.d.ts.map +1 -0
- package/out/address/keys/schema.js +119 -0
- package/out/address/keys/schema.js.map +1 -0
- package/out/address/number-forms.d.ts +19 -0
- package/out/address/number-forms.d.ts.map +1 -0
- package/out/address/number-forms.js +50 -0
- package/out/address/number-forms.js.map +1 -0
- package/out/address/point/interpolation.d.ts +24 -22
- package/out/address/point/interpolation.d.ts.map +1 -1
- package/out/address/point/interpolation.js +3 -31
- package/out/address/point/interpolation.js.map +1 -1
- package/out/address/point/schema.d.ts +0 -5
- package/out/address/point/schema.d.ts.map +1 -1
- package/out/address/point/schema.js +2 -5
- package/out/address/point/schema.js.map +1 -1
- package/out/address/point/spine-schema.d.ts +1 -4
- package/out/address/point/spine-schema.d.ts.map +1 -1
- package/out/address/point/spine-schema.js +3 -4
- package/out/address/point/spine-schema.js.map +1 -1
- package/out/address/point.d.ts +0 -3
- package/out/address/point.d.ts.map +1 -1
- package/out/address/point.js +17 -41
- package/out/address/point.js.map +1 -1
- package/out/address/record.d.ts +125 -0
- package/out/address/record.d.ts.map +1 -0
- package/out/address/record.js +49 -0
- package/out/address/record.js.map +1 -0
- package/out/address/stack.d.ts +14 -0
- package/out/address/stack.d.ts.map +1 -0
- package/out/address/stack.js +19 -0
- package/out/address/stack.js.map +1 -0
- package/out/address/subdivision-bounds.d.ts +32 -0
- package/out/address/subdivision-bounds.d.ts.map +1 -0
- package/out/address/subdivision-bounds.js +48 -0
- package/out/address/subdivision-bounds.js.map +1 -0
- package/out/address.d.ts +0 -5
- package/out/address.d.ts.map +1 -1
- package/out/address.js +2 -5
- package/out/address.js.map +1 -1
- package/out/ancestry/backfill.d.ts +0 -7
- package/out/ancestry/backfill.d.ts.map +1 -1
- package/out/ancestry/backfill.js +4 -4
- package/out/ancestry/backfill.js.map +1 -1
- package/out/ancestry.d.ts +0 -14
- package/out/ancestry.d.ts.map +1 -1
- package/out/ancestry.js +9 -10
- package/out/ancestry.js.map +1 -1
- package/out/build/candidate.d.ts +0 -22
- package/out/build/candidate.d.ts.map +1 -1
- package/out/build/candidate.js +2 -26
- package/out/build/candidate.js.map +1 -1
- package/out/build/population-corrections.d.ts +1 -4
- package/out/build/population-corrections.d.ts.map +1 -1
- package/out/build/population-corrections.js +2 -19
- package/out/build/population-corrections.js.map +1 -1
- package/out/build/slim.d.ts +1 -6
- package/out/build/slim.d.ts.map +1 -1
- package/out/build/slim.js +3 -18
- package/out/build/slim.js.map +1 -1
- package/out/candidate/alias-bags.d.ts +1 -4
- package/out/candidate/alias-bags.d.ts.map +1 -1
- package/out/candidate/alias-bags.js +3 -7
- package/out/candidate/alias-bags.js.map +1 -1
- package/out/candidate/ancestors/schema.d.ts +60 -43
- package/out/candidate/ancestors/schema.d.ts.map +1 -1
- package/out/candidate/ancestors/schema.js +62 -43
- package/out/candidate/ancestors/schema.js.map +1 -1
- package/out/candidate/ancestors/sidecar.d.ts +0 -3
- package/out/candidate/ancestors/sidecar.d.ts.map +1 -1
- package/out/candidate/ancestors/sidecar.js +2 -6
- package/out/candidate/ancestors/sidecar.js.map +1 -1
- package/out/candidate/bare-admin-names.d.ts +0 -6
- package/out/candidate/bare-admin-names.d.ts.map +1 -1
- package/out/candidate/bare-admin-names.js +2 -3
- package/out/candidate/bare-admin-names.js.map +1 -1
- package/out/candidate/country-display-names.d.ts +0 -5
- package/out/candidate/country-display-names.d.ts.map +1 -1
- package/out/candidate/country-display-names.js +2 -5
- package/out/candidate/country-display-names.js.map +1 -1
- package/out/candidate/extract-fold.d.ts +0 -5
- package/out/candidate/extract-fold.d.ts.map +1 -1
- package/out/candidate/extract-fold.js +2 -5
- package/out/candidate/extract-fold.js.map +1 -1
- package/out/candidate/fts.d.ts +2 -5
- package/out/candidate/fts.d.ts.map +1 -1
- package/out/candidate/fts.js +2 -7
- package/out/candidate/fts.js.map +1 -1
- package/out/candidate/importance.d.ts +3 -33
- package/out/candidate/importance.d.ts.map +1 -1
- package/out/candidate/importance.js +28 -24
- package/out/candidate/importance.js.map +1 -1
- package/out/candidate/lookup.d.ts +0 -5
- package/out/candidate/lookup.d.ts.map +1 -1
- package/out/candidate/lookup.js +10 -9
- package/out/candidate/lookup.js.map +1 -1
- package/out/candidate/name-roles.d.ts +0 -6
- package/out/candidate/name-roles.d.ts.map +1 -1
- package/out/candidate/name-roles.js +3 -4
- package/out/candidate/name-roles.js.map +1 -1
- package/out/candidate/own-name.d.ts +0 -18
- package/out/candidate/own-name.d.ts.map +1 -1
- package/out/candidate/own-name.js +11 -10
- package/out/candidate/own-name.js.map +1 -1
- package/out/candidate/place-attrs.d.ts +1 -4
- package/out/candidate/place-attrs.d.ts.map +1 -1
- package/out/candidate/place-attrs.js +2 -12
- package/out/candidate/place-attrs.js.map +1 -1
- package/out/candidate/schema.d.ts +0 -5
- package/out/candidate/schema.d.ts.map +1 -1
- package/out/candidate/schema.js +2 -5
- package/out/candidate/schema.js.map +1 -1
- package/out/candidate/scoring.d.ts +0 -5
- package/out/candidate/scoring.d.ts.map +1 -1
- package/out/candidate/scoring.js +3 -6
- package/out/candidate/scoring.js.map +1 -1
- package/out/capital-schema.d.ts +0 -14
- package/out/capital-schema.d.ts.map +1 -1
- package/out/capital-schema.js +10 -10
- package/out/capital-schema.js.map +1 -1
- package/out/capitals.d.ts +0 -16
- package/out/capitals.d.ts.map +1 -1
- package/out/capitals.js +14 -12
- package/out/capitals.js.map +1 -1
- package/out/convention/schema.d.ts +4 -7
- package/out/convention/schema.d.ts.map +1 -1
- package/out/convention/schema.js +2 -10
- package/out/convention/schema.js.map +1 -1
- package/out/convention.d.ts +0 -3
- package/out/convention.d.ts.map +1 -1
- package/out/convention.js +2 -8
- package/out/convention.js.map +1 -1
- package/out/coverage-manifest-schema.d.ts +1 -4
- package/out/coverage-manifest-schema.d.ts.map +1 -1
- package/out/coverage-manifest-schema.js +2 -3
- package/out/coverage-manifest-schema.js.map +1 -1
- package/out/env.d.ts +0 -8
- package/out/env.d.ts.map +1 -1
- package/out/env.js +6 -6
- package/out/env.js.map +1 -1
- package/out/exact-match.d.ts +2 -6
- package/out/exact-match.d.ts.map +1 -1
- package/out/exact-match.js +3 -9
- package/out/exact-match.js.map +1 -1
- package/out/extracts.d.ts +8 -9
- package/out/extracts.d.ts.map +1 -1
- package/out/extracts.js +9 -8
- package/out/extracts.js.map +1 -1
- package/out/fst/autocomplete.d.ts +1 -19
- package/out/fst/autocomplete.d.ts.map +1 -1
- package/out/fst/autocomplete.js +2 -18
- package/out/fst/autocomplete.js.map +1 -1
- package/out/fst/binary-matcher.d.ts +6 -8
- package/out/fst/binary-matcher.d.ts.map +1 -1
- package/out/fst/binary-matcher.js +3 -13
- package/out/fst/binary-matcher.js.map +1 -1
- package/out/fst/builder.d.ts +0 -12
- package/out/fst/builder.d.ts.map +1 -1
- package/out/fst/builder.js +23 -11
- package/out/fst/builder.js.map +1 -1
- package/out/fst/deserialize-web.d.ts +1 -12
- package/out/fst/deserialize-web.d.ts.map +1 -1
- package/out/fst/deserialize-web.js +8 -8
- package/out/fst/deserialize-web.js.map +1 -1
- package/out/fst/format.d.ts +6 -7
- package/out/fst/format.d.ts.map +1 -1
- package/out/fst/format.js +3 -10
- package/out/fst/format.js.map +1 -1
- package/out/fst/freshness.d.ts +0 -7
- package/out/fst/freshness.d.ts.map +1 -1
- package/out/fst/freshness.js +2 -4
- package/out/fst/freshness.js.map +1 -1
- package/out/fst/matcher.d.ts +3 -6
- package/out/fst/matcher.d.ts.map +1 -1
- package/out/fst/matcher.js +2 -9
- package/out/fst/matcher.js.map +1 -1
- package/out/fst/serialize.d.ts +0 -23
- package/out/fst/serialize.d.ts.map +1 -1
- package/out/fst/serialize.js +4 -8
- package/out/fst/serialize.js.map +1 -1
- package/out/fst/types.d.ts +1 -4
- package/out/fst/types.d.ts.map +1 -1
- package/out/fst/types.js +2 -6
- package/out/fst/types.js.map +1 -1
- package/out/fst.d.ts +0 -5
- package/out/fst.d.ts.map +1 -1
- package/out/fst.js +2 -5
- package/out/fst.js.map +1 -1
- package/out/fts/query.d.ts +0 -4
- package/out/fts/query.d.ts.map +1 -1
- package/out/fts/query.js +2 -7
- package/out/fts/query.js.map +1 -1
- package/out/fts.d.ts +0 -5
- package/out/fts.d.ts.map +1 -1
- package/out/fts.js +2 -5
- package/out/fts.js.map +1 -1
- package/out/geonames/aliases.d.ts +43 -5
- package/out/geonames/aliases.d.ts.map +1 -1
- package/out/geonames/aliases.js +109 -41
- package/out/geonames/aliases.js.map +1 -1
- package/out/geonames/postal.d.ts +1 -25
- package/out/geonames/postal.d.ts.map +1 -1
- package/out/geonames/postal.js +15 -14
- package/out/geonames/postal.js.map +1 -1
- package/out/geonames.d.ts +0 -5
- package/out/geonames.d.ts.map +1 -1
- package/out/geonames.js +2 -5
- package/out/geonames.js.map +1 -1
- package/out/index.d.ts +3 -6
- package/out/index.d.ts.map +1 -1
- package/out/index.js +4 -5
- package/out/index.js.map +1 -1
- package/out/interpolation.d.ts +0 -7
- package/out/interpolation.d.ts.map +1 -1
- package/out/interpolation.js +6 -6
- package/out/interpolation.js.map +1 -1
- package/out/landmark/rows.d.ts +60 -0
- package/out/landmark/rows.d.ts.map +1 -0
- package/out/landmark/rows.js +42 -0
- package/out/landmark/rows.js.map +1 -0
- package/out/landmark.d.ts +37 -0
- package/out/landmark.d.ts.map +1 -0
- package/out/landmark.js +72 -0
- package/out/landmark.js.map +1 -0
- package/out/lookup.d.ts +1 -12
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +7 -25
- package/out/lookup.js.map +1 -1
- package/out/name-score.d.ts +4 -6
- package/out/name-score.d.ts.map +1 -1
- package/out/name-score.js +6 -6
- package/out/name-score.js.map +1 -1
- package/out/nsul/lookup.d.ts +16 -15
- package/out/nsul/lookup.d.ts.map +1 -1
- package/out/nsul/lookup.js +2 -25
- package/out/nsul/lookup.js.map +1 -1
- package/out/nsul/schema.d.ts +1 -5
- package/out/nsul/schema.d.ts.map +1 -1
- package/out/nsul/schema.js +3 -8
- package/out/nsul/schema.js.map +1 -1
- package/out/nsul.d.ts +0 -5
- package/out/nsul.d.ts.map +1 -1
- package/out/nsul.js +2 -5
- package/out/nsul.js.map +1 -1
- package/out/paths.d.ts +1 -13
- package/out/paths.d.ts.map +1 -1
- package/out/paths.js +6 -7
- package/out/paths.js.map +1 -1
- package/out/place-importance-schema.d.ts +3 -8
- package/out/place-importance-schema.d.ts.map +1 -1
- package/out/place-importance-schema.js +3 -6
- package/out/place-importance-schema.js.map +1 -1
- package/out/poi/lookup.d.ts +0 -13
- package/out/poi/lookup.d.ts.map +1 -1
- package/out/poi/lookup.js +10 -10
- package/out/poi/lookup.js.map +1 -1
- package/out/poi/schema.d.ts +13 -10
- package/out/poi/schema.d.ts.map +1 -1
- package/out/poi/schema.js +2 -13
- package/out/poi/schema.js.map +1 -1
- package/out/poi.d.ts +0 -5
- package/out/poi.d.ts.map +1 -1
- package/out/poi.js +2 -5
- package/out/poi.js.map +1 -1
- package/out/polygon-schema.d.ts +7 -9
- package/out/polygon-schema.d.ts.map +1 -1
- package/out/polygon-schema.js +2 -12
- package/out/polygon-schema.js.map +1 -1
- package/out/postal/city/alias/lookup.d.ts +11 -13
- package/out/postal/city/alias/lookup.d.ts.map +1 -1
- package/out/postal/city/alias/lookup.js +13 -13
- package/out/postal/city/alias/lookup.js.map +1 -1
- package/out/postal/city/alias/schema.d.ts +9 -12
- package/out/postal/city/alias/schema.d.ts.map +1 -1
- package/out/postal/city/alias/schema.js +2 -17
- package/out/postal/city/alias/schema.js.map +1 -1
- package/out/postal/city/candidate-schema.d.ts +12 -12
- package/out/postal/city/candidate-schema.d.ts.map +1 -1
- package/out/postal/city/candidate-schema.js +14 -12
- package/out/postal/city/candidate-schema.js.map +1 -1
- package/out/postal.d.ts +0 -5
- package/out/postal.d.ts.map +1 -1
- package/out/postal.js +2 -5
- package/out/postal.js.map +1 -1
- package/out/postcode-point-lookup.d.ts +0 -5
- package/out/postcode-point-lookup.d.ts.map +1 -1
- package/out/postcode-point-lookup.js +2 -5
- package/out/postcode-point-lookup.js.map +1 -1
- package/out/primary-preference.d.ts +10 -15
- package/out/primary-preference.d.ts.map +1 -1
- package/out/primary-preference.js +10 -14
- package/out/primary-preference.js.map +1 -1
- package/out/proximity-rerank.d.ts +2 -26
- package/out/proximity-rerank.d.ts.map +1 -1
- package/out/proximity-rerank.js +22 -19
- package/out/proximity-rerank.js.map +1 -1
- package/out/ranking-weights.d.ts +5 -7
- package/out/ranking-weights.d.ts.map +1 -1
- package/out/ranking-weights.js +2 -9
- package/out/ranking-weights.js.map +1 -1
- package/out/region-keys.d.ts +0 -15
- package/out/region-keys.d.ts.map +1 -1
- package/out/region-keys.js +14 -14
- package/out/region-keys.js.map +1 -1
- package/out/reverse.d.ts +1 -24
- package/out/reverse.d.ts.map +1 -1
- package/out/reverse.js +14 -16
- package/out/reverse.js.map +1 -1
- package/out/schema.d.ts +17 -23
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js +2 -15
- package/out/schema.js.map +1 -1
- package/out/search-fetch.d.ts +0 -13
- package/out/search-fetch.d.ts.map +1 -1
- package/out/search-fetch.js +14 -11
- package/out/search-fetch.js.map +1 -1
- package/out/sqlite/convention-source.d.ts +0 -5
- package/out/sqlite/convention-source.d.ts.map +1 -1
- package/out/sqlite/convention-source.js +2 -5
- package/out/sqlite/convention-source.js.map +1 -1
- package/out/sqlite/utils.d.ts +1 -7
- package/out/sqlite/utils.d.ts.map +1 -1
- package/out/sqlite/utils.js +3 -4
- package/out/sqlite/utils.js.map +1 -1
- package/out/street/centroid/schema.d.ts +3 -6
- package/out/street/centroid/schema.d.ts.map +1 -1
- package/out/street/centroid/schema.js +2 -7
- package/out/street/centroid/schema.js.map +1 -1
- package/out/street/centroid.d.ts +0 -3
- package/out/street/centroid.d.ts.map +1 -1
- package/out/street/centroid.js +2 -6
- package/out/street/centroid.js.map +1 -1
- package/out/street/locale.d.ts +12 -0
- package/out/street/locale.d.ts.map +1 -0
- package/out/street/locale.js +54 -0
- package/out/street/locale.js.map +1 -0
- package/out/street/morphology/fst/builder.d.ts +1 -26
- package/out/street/morphology/fst/builder.d.ts.map +1 -1
- package/out/street/morphology/fst/builder.js +19 -18
- package/out/street/morphology/fst/builder.js.map +1 -1
- package/out/street/morphology/fst/loader.d.ts +0 -20
- package/out/street/morphology/fst/loader.d.ts.map +1 -1
- package/out/street/morphology/fst/loader.js +14 -13
- package/out/street/morphology/fst/loader.js.map +1 -1
- package/out/street/name-lookup.d.ts +11 -13
- package/out/street/name-lookup.d.ts.map +1 -1
- package/out/street/name-lookup.js +14 -14
- package/out/street/name-lookup.js.map +1 -1
- package/out/street/normalize.d.ts +17 -12
- package/out/street/normalize.d.ts.map +1 -1
- package/out/street/normalize.js +90 -13
- package/out/street/normalize.js.map +1 -1
- package/out/street/segment-schema.d.ts +11 -12
- package/out/street/segment-schema.d.ts.map +1 -1
- package/out/street/segment-schema.js +13 -12
- package/out/street/segment-schema.js.map +1 -1
- package/out/street/table.d.ts +154 -0
- package/out/street/table.d.ts.map +1 -0
- package/out/street/table.js +122 -0
- package/out/street/table.js.map +1 -0
- package/out/street.d.ts +1 -5
- package/out/street.d.ts.map +1 -1
- package/out/street.js +3 -5
- package/out/street.js.map +1 -1
- package/out/types.d.ts +7 -8
- package/out/types.d.ts.map +1 -1
- package/out/types.js +2 -5
- package/out/types.js.map +1 -1
- package/out/unified-schema.d.ts +18 -7
- package/out/unified-schema.d.ts.map +1 -1
- package/out/unified-schema.js +14 -10
- package/out/unified-schema.js.map +1 -1
- package/out/uprn/existence.d.ts +7 -10
- package/out/uprn/existence.d.ts.map +1 -1
- package/out/uprn/existence.js +9 -10
- package/out/uprn/existence.js.map +1 -1
- package/out/uprn/lookup.d.ts +1 -8
- package/out/uprn/lookup.d.ts.map +1 -1
- package/out/uprn/lookup.js +6 -8
- package/out/uprn/lookup.js.map +1 -1
- package/out/uprn/schema.d.ts +2 -5
- package/out/uprn/schema.d.ts.map +1 -1
- package/out/uprn/schema.js +2 -7
- package/out/uprn/schema.js.map +1 -1
- package/out/uprn.d.ts +0 -5
- package/out/uprn.d.ts.map +1 -1
- package/out/uprn.js +2 -5
- package/out/uprn.js.map +1 -1
- package/out/weights-overlay-linker.d.ts +3 -8
- package/out/weights-overlay-linker.d.ts.map +1 -1
- package/out/weights-overlay-linker.js +5 -8
- package/out/weights-overlay-linker.js.map +1 -1
- package/package.json +12 -12
- package/lib/coincident-roles.ts +0 -347
- package/lib/currency-backfill.ts +0 -289
- package/out/coincident-roles.d.ts +0 -121
- package/out/coincident-roles.d.ts.map +0 -1
- package/out/coincident-roles.js +0 -222
- package/out/coincident-roles.js.map +0 -1
- package/out/currency-backfill.d.ts +0 -68
- package/out/currency-backfill.d.ts.map +0 -1
- package/out/currency-backfill.js +0 -169
- package/out/currency-backfill.js.map +0 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The address layer's two files.
|
|
6
|
+
*
|
|
7
|
+
* `lookup.db` holds one clustered key table per level of precision a parse can reach,
|
|
8
|
+
* each row holding its answer, plus street aggregates and the `source` table.
|
|
9
|
+
* `detail.db` holds the full `address` record.
|
|
10
|
+
* A reader opens it only to show one result in detail.
|
|
11
|
+
*
|
|
12
|
+
* Every key table is `WITHOUT ROWID` and clustered on its key, so a lookup is one B-tree
|
|
13
|
+
* descent over contiguous pages, the property a reader of the file by HTTP range depends on.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { layerschemadatabase } from "@mailwoman/core/layers/schema"
|
|
17
|
+
import { type Kysely, sql } from "kysely"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* One source of address points: its wire id, publisher and terms.
|
|
21
|
+
*/
|
|
22
|
+
export interface AddressSourceTable {
|
|
23
|
+
source_id: number
|
|
24
|
+
/**
|
|
25
|
+
* The wire source id the adapter writes, such as `usgov-nad` or `openaddresses:us/wi/statewide`.
|
|
26
|
+
*/
|
|
27
|
+
name: string
|
|
28
|
+
/**
|
|
29
|
+
* The license expression its rows are published under, such as `CC-BY-4.0`,
|
|
30
|
+
* or `null` when its terms are unread.
|
|
31
|
+
*/
|
|
32
|
+
license: string | null
|
|
33
|
+
/**
|
|
34
|
+
* The publisher or assigning authority, such as `co.adams.wi.us`, or `null` when unstated.
|
|
35
|
+
*/
|
|
36
|
+
authority: string | null
|
|
37
|
+
/**
|
|
38
|
+
* The address points the file holds from this source.
|
|
39
|
+
*/
|
|
40
|
+
records: number
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* One key row: the street and number under one scope, with the point that answers it.
|
|
45
|
+
*
|
|
46
|
+
* `scope` is the level's own value: a postcode, a locality form's key, or a county's key.
|
|
47
|
+
*/
|
|
48
|
+
export interface AddressKeyTable {
|
|
49
|
+
scope: string
|
|
50
|
+
street: string
|
|
51
|
+
number: string
|
|
52
|
+
address_id: number
|
|
53
|
+
lat: number
|
|
54
|
+
lon: number
|
|
55
|
+
source_id: number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A key row under a Who's On First place id, for a locality the gazetteer resolved.
|
|
60
|
+
*/
|
|
61
|
+
export interface AddressPlaceKeyTable extends Omit<AddressKeyTable, "scope"> {
|
|
62
|
+
wof_id: number
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A key row for the file's whole region, keyed by street and number without a scope.
|
|
67
|
+
*/
|
|
68
|
+
export type AddressRegionKeyTable = Omit<AddressKeyTable, "scope">
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* One street under one scope, for a parse with no house number or a number the source lacks.
|
|
72
|
+
*/
|
|
73
|
+
export interface AddressStreetTable {
|
|
74
|
+
scope: string
|
|
75
|
+
street: string
|
|
76
|
+
lat: number
|
|
77
|
+
lon: number
|
|
78
|
+
min_lat: number
|
|
79
|
+
max_lat: number
|
|
80
|
+
min_lon: number
|
|
81
|
+
max_lon: number
|
|
82
|
+
points: number
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The `lookup.db` schema, for `new DatabaseClient<AddressLookupDatabase>(...)`,
|
|
87
|
+
* with the layer interface's `layer_manifest` and `layer_coverage` tables.
|
|
88
|
+
*/
|
|
89
|
+
export interface AddressLookupDatabase extends layerschemadatabase {
|
|
90
|
+
source: AddressSourceTable
|
|
91
|
+
key_postcode: AddressKeyTable
|
|
92
|
+
key_locality: AddressKeyTable
|
|
93
|
+
key_subregion: AddressKeyTable
|
|
94
|
+
key_place: AddressPlaceKeyTable
|
|
95
|
+
key_region: AddressRegionKeyTable
|
|
96
|
+
street_postcode: AddressStreetTable
|
|
97
|
+
street_locality: AddressStreetTable
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The key tables scoped by a text value, in the order a reader falls back through them.
|
|
102
|
+
*/
|
|
103
|
+
export const ADDRESS_SCOPED_KEY_TABLES = ["key_postcode", "key_locality", "key_subregion"] as const
|
|
104
|
+
|
|
105
|
+
export type AddressScopedKeyTableName = (typeof ADDRESS_SCOPED_KEY_TABLES)[number]
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The street aggregate tables, one per scoped level a parse without a number can state.
|
|
109
|
+
*/
|
|
110
|
+
export const ADDRESS_STREET_TABLES = ["street_postcode", "street_locality"] as const
|
|
111
|
+
|
|
112
|
+
export type AddressStreetTableName = (typeof ADDRESS_STREET_TABLES)[number]
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* One address point's full record, kept apart from the lookup file.
|
|
116
|
+
*/
|
|
117
|
+
export interface AddressDetailTable {
|
|
118
|
+
address_id: number
|
|
119
|
+
source_id: number
|
|
120
|
+
/**
|
|
121
|
+
* The publisher's own id for the point.
|
|
122
|
+
*/
|
|
123
|
+
source_record_id: string
|
|
124
|
+
country: string
|
|
125
|
+
number: string
|
|
126
|
+
unit: string | null
|
|
127
|
+
street_raw: string
|
|
128
|
+
postcode: string | null
|
|
129
|
+
/**
|
|
130
|
+
* Every name the record states, as JSON: `[{"level", "form", "value"}]`.
|
|
131
|
+
*/
|
|
132
|
+
names: string
|
|
133
|
+
admin_code: string | null
|
|
134
|
+
lat: number
|
|
135
|
+
lon: number
|
|
136
|
+
placement: string | null
|
|
137
|
+
authority: string | null
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The `detail.db` schema, for `new DatabaseClient<AddressDetailDatabase>(...)`.
|
|
142
|
+
*/
|
|
143
|
+
export interface AddressDetailDatabase {
|
|
144
|
+
address: AddressDetailTable
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Creates the `source` table.
|
|
149
|
+
*/
|
|
150
|
+
export async function createAddressSourceTable(db: Kysely<AddressLookupDatabase>): Promise<void> {
|
|
151
|
+
await db.schema
|
|
152
|
+
.createTable("source")
|
|
153
|
+
.addColumn("source_id", "integer", (c) => c.primaryKey())
|
|
154
|
+
.addColumn("name", "text", (c) => c.notNull().unique())
|
|
155
|
+
.addColumn("license", "text")
|
|
156
|
+
.addColumn("authority", "text")
|
|
157
|
+
.addColumn("records", "integer", (c) => c.notNull())
|
|
158
|
+
.execute()
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Creates one scoped key table, clustered on `(scope, street, number, address_id)`.
|
|
163
|
+
*/
|
|
164
|
+
export async function createAddressScopedKeyTable(
|
|
165
|
+
db: Kysely<AddressLookupDatabase>,
|
|
166
|
+
table: AddressScopedKeyTableName
|
|
167
|
+
): Promise<void> {
|
|
168
|
+
await db.schema
|
|
169
|
+
.createTable(table)
|
|
170
|
+
.addColumn("scope", "text", (c) => c.notNull())
|
|
171
|
+
.addColumn("street", "text", (c) => c.notNull())
|
|
172
|
+
.addColumn("number", "text", (c) => c.notNull())
|
|
173
|
+
.addColumn("address_id", "integer", (c) => c.notNull())
|
|
174
|
+
.addColumn("lat", "real", (c) => c.notNull())
|
|
175
|
+
.addColumn("lon", "real", (c) => c.notNull())
|
|
176
|
+
.addColumn("source_id", "integer", (c) => c.notNull())
|
|
177
|
+
.addPrimaryKeyConstraint(`${table}_pk`, ["scope", "street", "number", "address_id"])
|
|
178
|
+
// `without rowid` has no first-class builder. The raw modifier is the idiomatic fallback.
|
|
179
|
+
.modifyEnd(sql`without rowid`)
|
|
180
|
+
.execute()
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Creates the place key table, clustered on `(wof_id, street, number, address_id)`.
|
|
185
|
+
*/
|
|
186
|
+
export async function createAddressPlaceKeyTable(db: Kysely<AddressLookupDatabase>): Promise<void> {
|
|
187
|
+
await db.schema
|
|
188
|
+
.createTable("key_place")
|
|
189
|
+
.addColumn("wof_id", "integer", (c) => c.notNull())
|
|
190
|
+
.addColumn("street", "text", (c) => c.notNull())
|
|
191
|
+
.addColumn("number", "text", (c) => c.notNull())
|
|
192
|
+
.addColumn("address_id", "integer", (c) => c.notNull())
|
|
193
|
+
.addColumn("lat", "real", (c) => c.notNull())
|
|
194
|
+
.addColumn("lon", "real", (c) => c.notNull())
|
|
195
|
+
.addColumn("source_id", "integer", (c) => c.notNull())
|
|
196
|
+
.addPrimaryKeyConstraint("key_place_pk", ["wof_id", "street", "number", "address_id"])
|
|
197
|
+
.modifyEnd(sql`without rowid`)
|
|
198
|
+
.execute()
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Creates the region key table, clustered on `(street, number, address_id)`.
|
|
203
|
+
*/
|
|
204
|
+
export async function createAddressRegionKeyTable(db: Kysely<AddressLookupDatabase>): Promise<void> {
|
|
205
|
+
await db.schema
|
|
206
|
+
.createTable("key_region")
|
|
207
|
+
.addColumn("street", "text", (c) => c.notNull())
|
|
208
|
+
.addColumn("number", "text", (c) => c.notNull())
|
|
209
|
+
.addColumn("address_id", "integer", (c) => c.notNull())
|
|
210
|
+
.addColumn("lat", "real", (c) => c.notNull())
|
|
211
|
+
.addColumn("lon", "real", (c) => c.notNull())
|
|
212
|
+
.addColumn("source_id", "integer", (c) => c.notNull())
|
|
213
|
+
.addPrimaryKeyConstraint("key_region_pk", ["street", "number", "address_id"])
|
|
214
|
+
.modifyEnd(sql`without rowid`)
|
|
215
|
+
.execute()
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Creates one street aggregate table, clustered on `(scope, street)`.
|
|
220
|
+
*/
|
|
221
|
+
export async function createAddressStreetTable(
|
|
222
|
+
db: Kysely<AddressLookupDatabase>,
|
|
223
|
+
table: AddressStreetTableName
|
|
224
|
+
): Promise<void> {
|
|
225
|
+
await db.schema
|
|
226
|
+
.createTable(table)
|
|
227
|
+
.addColumn("scope", "text", (c) => c.notNull())
|
|
228
|
+
.addColumn("street", "text", (c) => c.notNull())
|
|
229
|
+
.addColumn("lat", "real", (c) => c.notNull())
|
|
230
|
+
.addColumn("lon", "real", (c) => c.notNull())
|
|
231
|
+
.addColumn("min_lat", "real", (c) => c.notNull())
|
|
232
|
+
.addColumn("max_lat", "real", (c) => c.notNull())
|
|
233
|
+
.addColumn("min_lon", "real", (c) => c.notNull())
|
|
234
|
+
.addColumn("max_lon", "real", (c) => c.notNull())
|
|
235
|
+
.addColumn("points", "integer", (c) => c.notNull())
|
|
236
|
+
.addPrimaryKeyConstraint(`${table}_pk`, ["scope", "street"])
|
|
237
|
+
.modifyEnd(sql`without rowid`)
|
|
238
|
+
.execute()
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Creates the `address` detail table, keyed by `address_id`.
|
|
243
|
+
*
|
|
244
|
+
* The rows store their names as JSON and are read one at a time by id, so the table keeps its rowid.
|
|
245
|
+
*/
|
|
246
|
+
export async function createAddressDetailTable(db: Kysely<AddressDetailDatabase>): Promise<void> {
|
|
247
|
+
await db.schema
|
|
248
|
+
.createTable("address")
|
|
249
|
+
.addColumn("address_id", "integer", (c) => c.primaryKey())
|
|
250
|
+
.addColumn("source_id", "integer", (c) => c.notNull())
|
|
251
|
+
.addColumn("source_record_id", "text", (c) => c.notNull())
|
|
252
|
+
.addColumn("country", "text", (c) => c.notNull())
|
|
253
|
+
.addColumn("number", "text", (c) => c.notNull())
|
|
254
|
+
.addColumn("unit", "text")
|
|
255
|
+
.addColumn("street_raw", "text", (c) => c.notNull())
|
|
256
|
+
.addColumn("postcode", "text")
|
|
257
|
+
.addColumn("names", "text", (c) => c.notNull())
|
|
258
|
+
.addColumn("admin_code", "text")
|
|
259
|
+
.addColumn("lat", "real", (c) => c.notNull())
|
|
260
|
+
.addColumn("lon", "real", (c) => c.notNull())
|
|
261
|
+
.addColumn("placement", "text")
|
|
262
|
+
.addColumn("authority", "text")
|
|
263
|
+
.execute()
|
|
264
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
import { isJoinedHouseNumber } from "@mailwoman/match/address-point"
|
|
5
|
+
|
|
6
|
+
import type { StreetLocale } from "#street/normalize"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The forms a normalized house number is probed under, the written form first,
|
|
10
|
+
* each later form tried only after every earlier one missed.
|
|
11
|
+
*
|
|
12
|
+
* - A hyphenated number that cannot be a range is joined: Hawaii's `19-4074`
|
|
13
|
+
* is stored as `194074` by some sources.
|
|
14
|
+
* This runs ahead of the range form, because that form reads it as house number 19.
|
|
15
|
+
* - A grid number leads with a compass letter, and one writer's `n3971` is another source's `n 3971`.
|
|
16
|
+
* - A range such as `385-387` falls back to its low end, since a register stores one number per point.
|
|
17
|
+
* - A number with one letter retries the other spacing, then the bare number:
|
|
18
|
+
* BAN stores `3 a`, while G-NAF and most OpenAddresses sources store `3a`.
|
|
19
|
+
* - Under `zh`, `14之12` and `30附40` fall back to `14` and `30`, the number the Taiwanese register stores.
|
|
20
|
+
* That answer is approximate.
|
|
21
|
+
*
|
|
22
|
+
* Both address readers call this, so they try one number in one order.
|
|
23
|
+
*/
|
|
24
|
+
export function* houseNumberForms(number: string, locale: StreetLocale): Generator<string> {
|
|
25
|
+
yield number
|
|
26
|
+
|
|
27
|
+
if (isJoinedHouseNumber(number)) {
|
|
28
|
+
yield number.replace("-", "")
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const grid = /^([nesw])(?:\s+)?(\d+)$/.exec(number)
|
|
32
|
+
|
|
33
|
+
if (grid) {
|
|
34
|
+
yield number.includes(" ") ? `${grid[1]}${grid[2]}` : `${grid[1]} ${grid[2]}`
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const low = /^(\d+[a-z]?)-\d+[a-z]?$/.exec(number)?.[1]
|
|
38
|
+
|
|
39
|
+
if (low) {
|
|
40
|
+
yield low
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const joined = /^(\d+)\s+([a-z])$/.exec(number)
|
|
44
|
+
const spaced = /^(\d+)([a-z])$/.exec(number)
|
|
45
|
+
|
|
46
|
+
if (joined) {
|
|
47
|
+
yield `${joined[1]}${joined[2]}`
|
|
48
|
+
yield joined[1]!
|
|
49
|
+
} else if (spaced) {
|
|
50
|
+
yield `${spaced[1]} ${spaced[2]}`
|
|
51
|
+
yield spaced[1]!
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (locale === "zh") {
|
|
55
|
+
const base = /^(\d+)(?:[之附]\d+)+$/u.exec(number)?.[1]
|
|
56
|
+
|
|
57
|
+
if (base) {
|
|
58
|
+
yield base
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -1,30 +1,35 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
+
* Address-point interpolation, the second method of the resolution ladder.
|
|
6
|
+
*
|
|
7
|
+
* When the exact address-point tier misses a house number, bracket the number with real neighbor
|
|
8
|
+
* points on the same street and interpolate linearly in house-number space between them.
|
|
9
|
+
* Real occupancy replaces the tiger range tier's uniform-spacing assumption.
|
|
10
|
+
*
|
|
11
|
+
* Tiger range interpolation (`StreetInterpolator`) is the fallback for streets too sparse to bracket.
|
|
5
12
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* replaces the tiger range tier's uniform-spacing assumption. Tiger range interpolation
|
|
10
|
-
* (`StreetInterpolator`) is the fallback for streets too sparse to bracket.
|
|
13
|
+
* The matching key is `street_key`, the shared normalizer plus the route fold (`canonicalizeRouteKey`),
|
|
14
|
+
* identical at build time (`mailwoman situs address-points`) and query time by construction.
|
|
15
|
+
* Scope is postcode-first like the segment tier.
|
|
11
16
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* time by construction. Scope is postcode-first like the segment tier. A query without a postcode
|
|
15
|
-
* goes straight to the fallback. The fallback has its own statewide-ambiguity abstention.
|
|
17
|
+
* A query without a postcode goes straight to the fallback.
|
|
18
|
+
* The fallback has its own statewide-ambiguity abstention.
|
|
16
19
|
*
|
|
17
|
-
* Neighbor candidates never include the queried number itself, so production never
|
|
18
|
-
* on-file number and grading against the same extract is non-circular.
|
|
20
|
+
* Neighbor candidates never include the queried number itself, so production never
|
|
21
|
+
* overrides an on-file number and grading against the same extract is non-circular.
|
|
19
22
|
*
|
|
20
|
-
* - Both-sided bracket (`bracket: "both"`): linear interpolation between the
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
23
|
+
* - Both-sided bracket (`bracket: "both"`): linear interpolation between the
|
|
24
|
+
* nearest known number below and above.
|
|
25
|
+
* `uncertaintyM` is half the distance between them.
|
|
26
|
+
* - Single-sided (`bracket: "single"`): linear extrapolation along the two nearest
|
|
27
|
+
* known numbers on that side, capped at one pair-span beyond the nearest point
|
|
28
|
+
* (`t ≤ 2`, past which the line provides no evidence and the query falls through).
|
|
29
|
+
* `uncertaintyM` is the pair distance plus the extrapolated overshoot,
|
|
30
|
+
* larger than the both-sided radius.
|
|
31
|
+
* - No bracket, meaning no neighbors, a single known number, or past the extrapolation cap:
|
|
32
|
+
* fall through to the tiger fallback when configured, else null.
|
|
28
33
|
*
|
|
29
34
|
* Standalone like the segment tier, wired through the ordered `spatialTiers` list.
|
|
30
35
|
*/
|
|
@@ -71,7 +76,7 @@ export class AddressPointInterpolator<
|
|
|
71
76
|
/**
|
|
72
77
|
* Resources this instance opened.
|
|
73
78
|
*
|
|
74
|
-
* A connection handed in by a caller
|
|
79
|
+
* A connection handed in by a caller isn't in here, so disposal cannot reach it.
|
|
75
80
|
* Ownership is membership rather than a flag a later branch checks.
|
|
76
81
|
*/
|
|
77
82
|
readonly #resources: DisposableStack
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
6
3
|
|
|
7
4
|
import type { Kysely } from "kysely"
|
|
8
5
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
* @copyright Sister Software.
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
5
|
* @file The shared rooftop schema with an H3 spine column and the layer-interface tables.
|
|
6
6
|
*
|
|
7
7
|
* The OpenStreetMap and G-NAF rooftop builders write this shape. Readers of existing address points
|
|
@@ -52,7 +52,7 @@ export async function createSpineAddressPointTables(db: Kysely<SpineAddressPoint
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
* Build after the bulk load so the spine index
|
|
55
|
+
* Build after the bulk load so the spine index isn't updated on every streaming insert.
|
|
56
56
|
*/
|
|
57
57
|
export async function createSpineAddressPointIndexes(db: Kysely<SpineAddressPointDatabase>): Promise<void> {
|
|
58
58
|
await db.schema.createIndex("idx_ap_h3").on("address_point").column("h3_cell").execute()
|
package/lib/address/point.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
5
|
* @file SQLite implementation of core's `AddressPointLookup`.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { AddressPointHit, AddressPointLookup } from "@mailwoman/core/resolver"
|
|
9
|
+
import { latLonBoundsContain } from "@mailwoman/spatial/bbox"
|
|
9
10
|
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
11
|
+
import { indexExists } from "@mailwoman/sqlite/introspection"
|
|
10
12
|
import type { PathBuilderLike } from "path-ts"
|
|
11
13
|
|
|
14
|
+
import { houseNumberForms } from "#address/number-forms"
|
|
12
15
|
import type { AddressPointDatabase, AddressPointTable } from "#address/point/schema"
|
|
13
16
|
import { hasTable, prepareGet, type PreparedGet } from "#sqlite-utils"
|
|
14
17
|
import {
|
|
@@ -73,6 +76,7 @@ export class AddressPointSqliteLookup<DB extends AddressPointDatabase = AddressP
|
|
|
73
76
|
readonly #byLocalityTail:
|
|
74
77
|
| PreparedGet<[street: StreetKey, number: string, tailPattern: string], AddressPointRow>
|
|
75
78
|
| undefined
|
|
79
|
+
readonly #hasStreetIndex: boolean = false
|
|
76
80
|
readonly #byBbox:
|
|
77
81
|
| PreparedGet<
|
|
78
82
|
[street: StreetKey, number: string, minLat: number, maxLat: number, minLon: number, maxLon: number],
|
|
@@ -140,6 +144,8 @@ export class AddressPointSqliteLookup<DB extends AddressPointDatabase = AddressP
|
|
|
140
144
|
WHERE locality_norm = ? AND street_norm = ? AND number = ? LIMIT 1`
|
|
141
145
|
)
|
|
142
146
|
|
|
147
|
+
this.#hasStreetIndex = indexExists(this.#db, "idx_ap_street")
|
|
148
|
+
|
|
143
149
|
this.#byBbox = prepareGet(
|
|
144
150
|
this.#db,
|
|
145
151
|
`SELECT ${SELECT_COLS} FROM address_point
|
|
@@ -218,44 +224,13 @@ export class AddressPointSqliteLookup<DB extends AddressPointDatabase = AddressP
|
|
|
218
224
|
bbox: { minLat: number; maxLat: number; minLon: number; maxLon: number } | null
|
|
219
225
|
}
|
|
220
226
|
) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
// The registers store one number per point, so a range such as "385-387" falls back to its low end.
|
|
224
|
-
if (!row) {
|
|
225
|
-
const low = /^(\d+[a-z]?)-\d+[a-z]?$/.exec(number)?.[1]
|
|
226
|
-
|
|
227
|
-
if (low) {
|
|
228
|
-
row = this.#probe(streetNorm, low, query)
|
|
229
|
-
}
|
|
230
|
-
}
|
|
227
|
+
for (const form of houseNumberForms(number, this.#locale)) {
|
|
228
|
+
const row = this.#probe(streetNorm, form, query)
|
|
231
229
|
|
|
232
|
-
|
|
233
|
-
// For a number of digits plus one letter, the lookup retries the other spacing
|
|
234
|
-
// and then the bare number.
|
|
235
|
-
if (!row) {
|
|
236
|
-
const joined = /^(\d+)\s+([a-z])$/.exec(number)
|
|
237
|
-
const spaced = /^(\d+)([a-z])$/.exec(number)
|
|
238
|
-
|
|
239
|
-
if (joined) {
|
|
240
|
-
row = this.#probe(streetNorm, `${joined[1]}${joined[2]}`, query) ?? this.#probe(streetNorm, joined[1]!, query)
|
|
241
|
-
} else if (spaced) {
|
|
242
|
-
row = this.#probe(streetNorm, `${spaced[1]} ${spaced[2]}`, query) ?? this.#probe(streetNorm, spaced[1]!, query)
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// The Taiwanese register stores `14之12` and `30附40` as numbers `14` and `30`.
|
|
247
|
-
// It stores the rest in `unit`.
|
|
248
|
-
// A query number that still includes the sub-number falls back to the base number.
|
|
249
|
-
// That result is approximate.
|
|
250
|
-
if (!row && this.#locale === "zh") {
|
|
251
|
-
const base = /^(\d+)(?:[之附]\d+)+$/u.exec(number)?.[1]
|
|
252
|
-
|
|
253
|
-
if (base) {
|
|
254
|
-
row = this.#probe(streetNorm, base, query)
|
|
255
|
-
}
|
|
230
|
+
if (row) return row
|
|
256
231
|
}
|
|
257
232
|
|
|
258
|
-
return
|
|
233
|
+
return null
|
|
259
234
|
}
|
|
260
235
|
|
|
261
236
|
/**
|
|
@@ -307,7 +282,8 @@ export class AddressPointSqliteLookup<DB extends AddressPointDatabase = AddressP
|
|
|
307
282
|
}
|
|
308
283
|
|
|
309
284
|
// The bounding box serves extracts whose points have no postcode or locality, such as OSM.
|
|
310
|
-
|
|
285
|
+
// A database without the street index skips this search, because each miss would scan the whole table.
|
|
286
|
+
if (!row && query.bbox && this.#hasStreetIndex) {
|
|
311
287
|
const b = query.bbox
|
|
312
288
|
const candidate = this.#byBbox!(streetNorm, number, b.minLat, b.maxLat, b.minLon, b.maxLon)
|
|
313
289
|
|
|
@@ -333,11 +309,11 @@ export class AddressPointSqliteLookup<DB extends AddressPointDatabase = AddressP
|
|
|
333
309
|
/**
|
|
334
310
|
* Returns whether the row's own postcode or locality differs from the query's.
|
|
335
311
|
*
|
|
336
|
-
* A row field that
|
|
312
|
+
* A row field that's empty never contradicts.
|
|
337
313
|
* The locality is compared only when the extract's `localityKeys` is `"full"`,
|
|
338
314
|
* because abbreviated keys would reject correct rows.
|
|
339
315
|
*
|
|
340
|
-
* Two locality keys agree when they
|
|
316
|
+
* Two locality keys agree when they're equal or when one is the leading words of the other.
|
|
341
317
|
* A German disambiguated name such as `Lauta b Hoyerswerda` or `Freiberg Sachs` begins with the place
|
|
342
318
|
* name that OSM's `addr:city` records, and a word boundary keeps `lauta` apart from `lautabach`.
|
|
343
319
|
*/
|
|
@@ -385,7 +361,7 @@ export class AddressPointSqliteLookup<DB extends AddressPointDatabase = AddressP
|
|
|
385
361
|
|
|
386
362
|
if (!bbox) return true
|
|
387
363
|
|
|
388
|
-
return
|
|
364
|
+
return latLonBoundsContain(bbox, row.lat, row.lon)
|
|
389
365
|
}
|
|
390
366
|
|
|
391
367
|
[Symbol.dispose](): void {
|