@mailwoman/resolver-wof-sqlite 11.0.0 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- 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 +12 -79
- 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 +18 -47
- package/lib/ancestry.ts +10 -10
- package/lib/build/candidate.ts +44 -48
- package/lib/build/population-corrections.ts +4 -4
- package/lib/build/slim.ts +3 -6
- package/lib/candidate/alias-bags.ts +58 -18
- 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 +30 -24
- package/lib/candidate/key-fold.ts +132 -0
- package/lib/candidate/lookup.ts +25 -18
- package/lib/candidate/name-roles.ts +4 -4
- package/lib/candidate/nickname-namesakes.ts +140 -0
- 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 +36 -50
- package/lib/fst/builder.ts +32 -11
- package/lib/fst/deserialize-web.ts +9 -8
- package/lib/fst/format.ts +153 -14
- package/lib/fst/freshness.ts +3 -4
- package/lib/fst/matcher.ts +6 -6
- package/lib/fst/serialize.ts +94 -69
- 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 +189 -46
- package/lib/geonames/postal.ts +17 -15
- package/lib/geonames.ts +2 -5
- package/lib/importance-source.ts +210 -0
- package/lib/index.ts +4 -5
- package/lib/interpolation.ts +7 -6
- package/lib/landmark/rows.ts +5 -5
- package/lib/landmark.ts +6 -6
- package/lib/lookup.ts +8 -8
- 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 +42 -7
- 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 -6
- 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 +62 -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 +3 -6
- 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 +12 -71
- 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 +11 -13
- package/out/ancestry/backfill.d.ts.map +1 -1
- package/out/ancestry/backfill.js +6 -44
- 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 +20 -22
- package/out/build/candidate.d.ts.map +1 -1
- package/out/build/candidate.js +16 -28
- 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 +0 -5
- package/out/build/slim.d.ts.map +1 -1
- package/out/build/slim.js +3 -6
- package/out/build/slim.js.map +1 -1
- package/out/candidate/alias-bags.d.ts +9 -4
- package/out/candidate/alias-bags.d.ts.map +1 -1
- package/out/candidate/alias-bags.js +46 -19
- 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 +29 -24
- package/out/candidate/importance.js.map +1 -1
- package/out/candidate/key-fold.d.ts +55 -0
- package/out/candidate/key-fold.d.ts.map +1 -0
- package/out/candidate/key-fold.js +80 -0
- package/out/candidate/key-fold.js.map +1 -0
- package/out/candidate/lookup.d.ts +0 -5
- package/out/candidate/lookup.d.ts.map +1 -1
- package/out/candidate/lookup.js +24 -17
- 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/nickname-namesakes.d.ts +32 -0
- package/out/candidate/nickname-namesakes.d.ts.map +1 -0
- package/out/candidate/nickname-namesakes.js +98 -0
- package/out/candidate/nickname-namesakes.js.map +1 -0
- 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 +12 -43
- 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 +66 -16
- package/out/fst/format.d.ts.map +1 -1
- package/out/fst/format.js +100 -16
- 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 +68 -60
- 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 +108 -44
- 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/importance-source.d.ts +90 -0
- package/out/importance-source.d.ts.map +1 -0
- package/out/importance-source.js +133 -0
- package/out/importance-source.js.map +1 -0
- package/out/index.d.ts +2 -5
- 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 +2 -5
- package/out/landmark/rows.d.ts.map +1 -1
- package/out/landmark/rows.js +2 -8
- package/out/landmark/rows.js.map +1 -1
- package/out/landmark.d.ts +3 -6
- package/out/landmark.d.ts.map +1 -1
- package/out/landmark.js +2 -8
- package/out/landmark.js.map +1 -1
- package/out/lookup.d.ts +0 -7
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +7 -8
- 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 +20 -6
- package/out/primary-preference.d.ts.map +1 -1
- package/out/primary-preference.js +33 -6
- 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 -6
- 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 +29 -12
- package/out/street/normalize.d.ts.map +1 -1
- package/out/street/normalize.js +53 -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 +1 -6
- 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/currency-backfill.ts +0 -289
- 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
package/lib/street/normalize.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
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 { AbbreviationToDirectional, US_STREET_SUFFIX_LOOKUP } from "@mailwoman/codex/us"
|
|
8
5
|
import type { Tagged } from "type-fest"
|
|
9
6
|
|
|
7
|
+
import { streetLocaleForCountry } from "#street/locale"
|
|
8
|
+
|
|
10
9
|
/**
|
|
11
10
|
* A place name folded by {@link normalizeLocalityForKey}, minted only by calling the fold.
|
|
12
11
|
*/
|
|
@@ -20,8 +19,8 @@ export type NameKey = Tagged<string, "NameKey">
|
|
|
20
19
|
export type StreetKey = Tagged<string, "StreetKey">
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
|
-
* A street key that
|
|
24
|
-
*
|
|
22
|
+
* A street key that's also passed {@link canonicalizeRouteKey}; binding a plain {@link StreetKey}
|
|
23
|
+
* to a route-folded column silently misses rows whose route spelling differs.
|
|
25
24
|
*/
|
|
26
25
|
export type RouteKey = Tagged<string, "RouteKey">
|
|
27
26
|
|
|
@@ -146,7 +145,7 @@ export function normalizeStreetForKey(street: string): StreetKey {
|
|
|
146
145
|
* Names the rule set {@link normalizeStreetForKeyLocale} uses to fold a street
|
|
147
146
|
* name into an address-point key.
|
|
148
147
|
*/
|
|
149
|
-
export type StreetLocale = "us" | "en" | "es" | "fr" | "de" | "it" | "nl" | "pl" | "vn" | "id" | "zh"
|
|
148
|
+
export type StreetLocale = "us" | "en" | "es" | "fr" | "de" | "it" | "nl" | "pl" | "vn" | "id" | "zh" | "und"
|
|
150
149
|
|
|
151
150
|
/**
|
|
152
151
|
* Every locale {@link normalizeStreetForKeyLocale} keys streets under.
|
|
@@ -163,6 +162,7 @@ export const STREET_LOCALES = [
|
|
|
163
162
|
"vn",
|
|
164
163
|
"id",
|
|
165
164
|
"zh",
|
|
165
|
+
"und",
|
|
166
166
|
] as const satisfies readonly StreetLocale[]
|
|
167
167
|
|
|
168
168
|
function foldHan(input: string): string {
|
|
@@ -170,24 +170,27 @@ function foldHan(input: string): string {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
|
173
|
-
* Creates
|
|
174
|
-
*
|
|
173
|
+
* Creates the street-locale lookup for one source's built databases.
|
|
174
|
+
*
|
|
175
|
+
* `localeFor` answers {@link streetLocaleForCountry} for a country in `countries`
|
|
176
|
+
* and throws for any other, since that source has built no database there to fold a query for.
|
|
177
|
+
* Every source therefore folds a country's streets under one locale.
|
|
175
178
|
*/
|
|
176
179
|
export function createStreetLocaleRegistry(
|
|
177
|
-
|
|
180
|
+
countries: readonly string[],
|
|
178
181
|
label: string
|
|
179
182
|
): { localeFor: (countryCode: string) => StreetLocale; supported: () => string[] } {
|
|
183
|
+
const built = new Set(countries.map((country) => country.toLowerCase()))
|
|
184
|
+
|
|
180
185
|
return {
|
|
181
186
|
localeFor: (countryCode) => {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
if (!locale) {
|
|
185
|
-
throw new Error(`No street-normalization locale registered for country "${countryCode}". ${label}`)
|
|
187
|
+
if (!built.has(countryCode.toLowerCase())) {
|
|
188
|
+
throw new Error(`No database is registered for country "${countryCode}". ${label}`)
|
|
186
189
|
}
|
|
187
190
|
|
|
188
|
-
return
|
|
191
|
+
return streetLocaleForCountry(countryCode)
|
|
189
192
|
},
|
|
190
|
-
supported: () => [...
|
|
193
|
+
supported: () => [...built],
|
|
191
194
|
}
|
|
192
195
|
}
|
|
193
196
|
|
|
@@ -344,6 +347,48 @@ export function normalizeLocalityForKey(locality: string): NameKey {
|
|
|
344
347
|
return fold(locality) as NameKey
|
|
345
348
|
}
|
|
346
349
|
|
|
350
|
+
/**
|
|
351
|
+
* Apostrophe-like marks that romanized names contain and {@link normalizeLocalityForKey} keeps.
|
|
352
|
+
*
|
|
353
|
+
* The set holds the Hawaiian, Tongan and Uzbek ʻokina (U+02BB), the modifier
|
|
354
|
+
* apostrophe (U+02BC), the reversed comma above (U+02BD), the prime (U+02B9),
|
|
355
|
+
* the ʾalif and ʿayn half rings (U+02BE, U+02BF), and the left quotation mark (U+2018)
|
|
356
|
+
* and backtick (U+0060) that romanized Arabic, Persian and Pashto names write for ʿayn.
|
|
357
|
+
* A writer typing in ASCII leaves them out or types `'`, which the key drops.
|
|
358
|
+
*/
|
|
359
|
+
const APOSTROPHE_LIKE_MARKS = /[ʹʻ-ʿ‘`]/gu
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* The key with every apostrophe-like mark removed, so `Hawaiʻi` and `` `Ajman ``
|
|
363
|
+
* are also found as `hawaii` and `ajman`.
|
|
364
|
+
*
|
|
365
|
+
* The candidate build stages it as one more alias of the place.
|
|
366
|
+
* The query-side key is unchanged, so a query written with the mark still matches the source spelling.
|
|
367
|
+
*/
|
|
368
|
+
export function withoutApostropheLikeMarks(key: NameKey): NameKey {
|
|
369
|
+
return key.replaceAll(APOSTROPHE_LIKE_MARKS, "").replaceAll(/\s+/g, " ").trim() as NameKey
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* The tatweel (U+0640), the short-vowel and shadda marks (U+064B–U+065F) and the superscript
|
|
374
|
+
* alef (U+0670), with the hamza and madda that NFKD splits off `أ`, `إ`, `آ`, `ؤ` and `ئ`.
|
|
375
|
+
*/
|
|
376
|
+
const ARABIC_MARKS = /[ـً-ٰٟ]/gu
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* The key with the Arabic letters that writers interchange folded together, so `الاسماعيليه`
|
|
380
|
+
* and `الإسماعيلية`, or `الوادى الجديد` and `الوادي الجديد`, meet at one key.
|
|
381
|
+
*
|
|
382
|
+
* It removes {@link ARABIC_MARKS}, which leaves a hamza-carrying alef as a bare `ا`,
|
|
383
|
+
* and writes `ى` (alef maqsura) as `ي` (yeh) and `ة` (taa marbuta) as `ه` (heh).
|
|
384
|
+
* {@link normalizeLocalityForKey} doesn't apply it, so the columns keyed by that fold are unchanged.
|
|
385
|
+
* A candidate build applies it to `name_key` only under the `arabic-letter-variants` key fold
|
|
386
|
+
* (`#candidate/key-fold`), which the artifact records so its reader folds query keys too.
|
|
387
|
+
*/
|
|
388
|
+
export function withArabicLetterVariantsFolded(key: NameKey): NameKey {
|
|
389
|
+
return key.normalize("NFKD").replaceAll(ARABIC_MARKS, "").replaceAll("ى", "ي").replaceAll("ة", "ه") as NameKey
|
|
390
|
+
}
|
|
391
|
+
|
|
347
392
|
/**
|
|
348
393
|
* Folds a locality name into a {@link NameKey} with the Han fold for `zh`
|
|
349
394
|
* and {@link normalizeLocalityForKey} otherwise.
|
|
@@ -1,18 +1,20 @@
|
|
|
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
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* The
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* {@link STREET_SEGMENT_COLUMNS} so it cannot drift from the DDL.
|
|
5
|
+
* Typed schema for the tiger street-segment interpolation extracts
|
|
6
|
+
* (`street-segments-<cc>-<st>.db`, built by `scripts/build-interpolation-extract.ts` from tiger edges).
|
|
7
|
+
*
|
|
8
|
+
* This is the Method-3 fallback the resolver drops to when the address-point
|
|
9
|
+
* tier (Method 2) cannot bracket.
|
|
10
|
+
* It is the definition of the columns the builder writes and the reader ({@link StreetInterpolator})
|
|
11
|
+
* probes, so a column rename in one is a compile error in the other.
|
|
12
|
+
*
|
|
13
|
+
* The builder reads geometry from shapefiles via DuckDB's spatial extension
|
|
14
|
+
* (raw `ST_Read`, see agents.md "Database / inline SQL") and writes here through `node:sqlite`.
|
|
15
|
+
* The hot positional insert (every edge in a county) stays raw.
|
|
16
|
+
*
|
|
17
|
+
* Its column list derives from {@link STREET_SEGMENT_COLUMNS} so it cannot drift from the DDL.
|
|
16
18
|
*/
|
|
17
19
|
|
|
18
20
|
import { type Kysely, sql } from "kysely"
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The street table's schema and reads: merged streets and their crossings,
|
|
6
|
+
* with each row tied to the places that hold it by Who's On First id.
|
|
7
|
+
*
|
|
8
|
+
* The builder, a native reader and a Worker's range reader share these statements.
|
|
9
|
+
* The file holds no database client, so a Worker bundle can import it.
|
|
10
|
+
*
|
|
11
|
+
* A read clusters on the written name, so a range reader fetches one run of pages for each lookup.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { normalizeStreetForKey } from "#street/normalize"
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* One merged street: road links with one name, joined through a shared node.
|
|
18
|
+
*/
|
|
19
|
+
export interface StreetTable {
|
|
20
|
+
id: number
|
|
21
|
+
name: string
|
|
22
|
+
latitude: number
|
|
23
|
+
longitude: number
|
|
24
|
+
/**
|
|
25
|
+
* The merged street's length in meters.
|
|
26
|
+
*/
|
|
27
|
+
meters: number
|
|
28
|
+
/**
|
|
29
|
+
* A flat JSON array, `[lat0, lon0, lat1, lon1, …]`, with the midpoint of each road link.
|
|
30
|
+
*/
|
|
31
|
+
points: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* One name a street is read under, with the street's extent so a search near
|
|
36
|
+
* a point skips distant namesakes.
|
|
37
|
+
*/
|
|
38
|
+
export interface StreetNameTable {
|
|
39
|
+
name_key: string
|
|
40
|
+
street_id: number
|
|
41
|
+
min_lat: number
|
|
42
|
+
max_lat: number
|
|
43
|
+
min_lon: number
|
|
44
|
+
max_lon: number
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* One place that holds part of a street, with the street's point inside that place.
|
|
49
|
+
*/
|
|
50
|
+
export interface StreetPlaceTable {
|
|
51
|
+
name_key: string
|
|
52
|
+
place_id: number
|
|
53
|
+
street_id: number
|
|
54
|
+
latitude: number
|
|
55
|
+
longitude: number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* One location where two streets with different names meet.
|
|
60
|
+
*/
|
|
61
|
+
export interface StreetCrossingTable {
|
|
62
|
+
/**
|
|
63
|
+
* The lower of the two name keys, in code-unit order.
|
|
64
|
+
*/
|
|
65
|
+
a_key: string
|
|
66
|
+
b_key: string
|
|
67
|
+
id: number
|
|
68
|
+
latitude: number
|
|
69
|
+
longitude: number
|
|
70
|
+
/**
|
|
71
|
+
* The shared nodes merged into this location.
|
|
72
|
+
*/
|
|
73
|
+
nodes: number
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* One place that holds a crossing.
|
|
78
|
+
*/
|
|
79
|
+
export interface StreetCrossingPlaceTable {
|
|
80
|
+
crossing_id: number
|
|
81
|
+
place_id: number
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface StreetTableDatabase {
|
|
85
|
+
street: StreetTable
|
|
86
|
+
street_name: StreetNameTable
|
|
87
|
+
street_place: StreetPlaceTable
|
|
88
|
+
street_crossing: StreetCrossingTable
|
|
89
|
+
street_crossing_place: StreetCrossingPlaceTable
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Creates the tables, clustered on the keys the reads below seek.
|
|
94
|
+
*/
|
|
95
|
+
export const STREET_TABLE_DDL = `
|
|
96
|
+
CREATE TABLE street (
|
|
97
|
+
id INTEGER PRIMARY KEY,
|
|
98
|
+
name TEXT NOT NULL,
|
|
99
|
+
latitude REAL NOT NULL,
|
|
100
|
+
longitude REAL NOT NULL,
|
|
101
|
+
meters REAL NOT NULL,
|
|
102
|
+
points TEXT NOT NULL
|
|
103
|
+
);
|
|
104
|
+
CREATE TABLE street_name (
|
|
105
|
+
name_key TEXT NOT NULL,
|
|
106
|
+
street_id INTEGER NOT NULL,
|
|
107
|
+
min_lat REAL NOT NULL,
|
|
108
|
+
max_lat REAL NOT NULL,
|
|
109
|
+
min_lon REAL NOT NULL,
|
|
110
|
+
max_lon REAL NOT NULL,
|
|
111
|
+
PRIMARY KEY (name_key, street_id)
|
|
112
|
+
) WITHOUT ROWID;
|
|
113
|
+
CREATE TABLE street_place (
|
|
114
|
+
name_key TEXT NOT NULL,
|
|
115
|
+
place_id INTEGER NOT NULL,
|
|
116
|
+
street_id INTEGER NOT NULL,
|
|
117
|
+
latitude REAL NOT NULL,
|
|
118
|
+
longitude REAL NOT NULL,
|
|
119
|
+
PRIMARY KEY (name_key, place_id, street_id)
|
|
120
|
+
) WITHOUT ROWID;
|
|
121
|
+
CREATE TABLE street_crossing (
|
|
122
|
+
a_key TEXT NOT NULL,
|
|
123
|
+
b_key TEXT NOT NULL,
|
|
124
|
+
id INTEGER NOT NULL,
|
|
125
|
+
latitude REAL NOT NULL,
|
|
126
|
+
longitude REAL NOT NULL,
|
|
127
|
+
nodes INTEGER NOT NULL,
|
|
128
|
+
PRIMARY KEY (a_key, b_key, id)
|
|
129
|
+
) WITHOUT ROWID;
|
|
130
|
+
CREATE TABLE street_crossing_place (
|
|
131
|
+
crossing_id INTEGER NOT NULL,
|
|
132
|
+
place_id INTEGER NOT NULL,
|
|
133
|
+
PRIMARY KEY (crossing_id, place_id)
|
|
134
|
+
) WITHOUT ROWID;
|
|
135
|
+
`
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* One way of reading a street.
|
|
139
|
+
*/
|
|
140
|
+
export interface StreetTableHit {
|
|
141
|
+
streetID: number
|
|
142
|
+
name: string
|
|
143
|
+
lat: number
|
|
144
|
+
lon: number
|
|
145
|
+
meters: number
|
|
146
|
+
/**
|
|
147
|
+
* Meters from the point the query searched near, or `null` for a query by place.
|
|
148
|
+
*/
|
|
149
|
+
distanceM: number | null
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* One location where two streets meet.
|
|
154
|
+
*/
|
|
155
|
+
export interface CrossingHit {
|
|
156
|
+
lat: number
|
|
157
|
+
lon: number
|
|
158
|
+
nodes: number
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* A point to search around, with its radius in meters.
|
|
163
|
+
*/
|
|
164
|
+
export interface StreetTableArea {
|
|
165
|
+
lat: number
|
|
166
|
+
lon: number
|
|
167
|
+
radiusM: number
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface StreetTableQuery {
|
|
171
|
+
street: string
|
|
172
|
+
/**
|
|
173
|
+
* The Who's On First ids of the places that may hold the street.
|
|
174
|
+
*/
|
|
175
|
+
places?: readonly number[]
|
|
176
|
+
/**
|
|
177
|
+
* The area a street must pass through.
|
|
178
|
+
* A query holds this or `places`.
|
|
179
|
+
*/
|
|
180
|
+
near?: StreetTableArea
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface CrossingTableQuery {
|
|
184
|
+
first: string
|
|
185
|
+
second: string
|
|
186
|
+
/**
|
|
187
|
+
* The places that may hold the crossing, or every place when absent.
|
|
188
|
+
*/
|
|
189
|
+
places?: readonly number[]
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Reads the street table.
|
|
194
|
+
*
|
|
195
|
+
* A failed read throws, because an empty answer claims the table holds no such street.
|
|
196
|
+
*/
|
|
197
|
+
export interface StreetTableLookup {
|
|
198
|
+
findStreets(query: StreetTableQuery): Promise<StreetTableHit[]>
|
|
199
|
+
findCrossings(query: CrossingTableQuery): Promise<CrossingHit[]>
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* The most rows one lookup returns.
|
|
204
|
+
*/
|
|
205
|
+
export const STREET_TABLE_ROW_LIMIT = 50
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Returns the sorted pair of keys a crossing is stored under.
|
|
209
|
+
*/
|
|
210
|
+
export function crossingKeys(first: string, second: string): [string, string] {
|
|
211
|
+
const a = String(normalizeStreetForKey(first))
|
|
212
|
+
const b = String(normalizeStreetForKey(second))
|
|
213
|
+
|
|
214
|
+
return a < b ? [a, b] : [b, a]
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const placeholders = (values: readonly unknown[]) => values.map(() => "?").join(", ")
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The statement and parameters that read a street's rows inside the given places.
|
|
221
|
+
*/
|
|
222
|
+
export function streetsInPlacesStatement(street: string, places: readonly number[]): [string, Array<string | number>] {
|
|
223
|
+
return [
|
|
224
|
+
`SELECT DISTINCT s.id AS id, s.name AS name, p.latitude AS latitude, p.longitude AS longitude, s.meters AS meters
|
|
225
|
+
FROM street_place p JOIN street s ON s.id = p.street_id
|
|
226
|
+
WHERE p.name_key = ? AND p.place_id IN (${placeholders(places)})
|
|
227
|
+
LIMIT ${STREET_TABLE_ROW_LIMIT}`,
|
|
228
|
+
[String(normalizeStreetForKey(street)), ...places],
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const METERS_PER_DEGREE_LATITUDE = 111_320
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* The statement and parameters that read every street with this name whose extent reaches the area.
|
|
236
|
+
*/
|
|
237
|
+
export function streetsNearStatement(street: string, area: StreetTableArea): [string, Array<string | number>] {
|
|
238
|
+
const latSpan = area.radiusM / METERS_PER_DEGREE_LATITUDE
|
|
239
|
+
const lonSpan = latSpan / Math.max(Math.cos((area.lat * Math.PI) / 180), 0.01)
|
|
240
|
+
|
|
241
|
+
return [
|
|
242
|
+
`SELECT s.id AS id, s.name AS name, s.points AS points, s.meters AS meters
|
|
243
|
+
FROM street_name n JOIN street s ON s.id = n.street_id
|
|
244
|
+
WHERE n.name_key = ? AND n.max_lat >= ? AND n.min_lat <= ? AND n.max_lon >= ? AND n.min_lon <= ?
|
|
245
|
+
LIMIT ${STREET_TABLE_ROW_LIMIT}`,
|
|
246
|
+
[
|
|
247
|
+
String(normalizeStreetForKey(street)),
|
|
248
|
+
area.lat - latSpan,
|
|
249
|
+
area.lat + latSpan,
|
|
250
|
+
area.lon - lonSpan,
|
|
251
|
+
area.lon + lonSpan,
|
|
252
|
+
],
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* The statement and parameters that read a crossing, inside the given places when there are any.
|
|
258
|
+
*/
|
|
259
|
+
export function crossingsStatement(query: CrossingTableQuery): [string, Array<string | number>] {
|
|
260
|
+
const [a, b] = crossingKeys(query.first, query.second)
|
|
261
|
+
|
|
262
|
+
if (!query.places?.length) {
|
|
263
|
+
return [
|
|
264
|
+
`SELECT latitude, longitude, nodes FROM street_crossing WHERE a_key = ? AND b_key = ? LIMIT ${STREET_TABLE_ROW_LIMIT}`,
|
|
265
|
+
[a, b],
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return [
|
|
270
|
+
`SELECT DISTINCT c.latitude AS latitude, c.longitude AS longitude, c.nodes AS nodes
|
|
271
|
+
FROM street_crossing c JOIN street_crossing_place p ON p.crossing_id = c.id
|
|
272
|
+
WHERE c.a_key = ? AND c.b_key = ? AND p.place_id IN (${placeholders(query.places)})
|
|
273
|
+
LIMIT ${STREET_TABLE_ROW_LIMIT}`,
|
|
274
|
+
[a, b, ...query.places],
|
|
275
|
+
]
|
|
276
|
+
}
|
package/lib/street.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
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
|
export * from "#street/centroid"
|
|
8
5
|
export * from "#street/centroid/schema"
|
|
9
6
|
export * from "#street/morphology/fst/builder"
|
|
10
7
|
export * from "#street/morphology/fst/loader"
|
|
8
|
+
export * from "#street/locale"
|
|
11
9
|
export * from "#street/name-lookup"
|
|
12
10
|
export * from "#street/normalize"
|
|
13
11
|
export * from "#street/segment-schema"
|
package/lib/types.ts
CHANGED
|
@@ -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 { LatLon, LatLonBounds } from "@mailwoman/spatial"
|
|
8
5
|
|
|
@@ -99,7 +96,7 @@ export interface PlaceCandidate {
|
|
|
99
96
|
/**
|
|
100
97
|
* Whether the ancestors sidecar places this candidate under the query's
|
|
101
98
|
* {@link FindPlaceQuery.regionQualifier}, with `false` meaning the check ran
|
|
102
|
-
* and an absent value meaning it
|
|
99
|
+
* and an absent value meaning it didn't.
|
|
103
100
|
*/
|
|
104
101
|
containedByQualifier: boolean | null
|
|
105
102
|
|
package/lib/unified-schema.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
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
|
+
* Schema for the unified WOF SQLite database built from cloned WOF GeoJSON
|
|
6
|
+
* repos (`scripts/build-unified-wof.ts`).
|
|
7
|
+
*
|
|
8
|
+
* The table and column names match the resolver's expectations (`lookup.ts`)
|
|
9
|
+
* so `WOFSQLitePlaceLookup` works unchanged.
|
|
10
|
+
* The `ancestors` table table is what lookup.ts's parent-constraint subquery
|
|
11
|
+
* reads (see `populateAncestors`).
|
|
5
12
|
*
|
|
6
|
-
* Schema for the unified WOF SQLite database built from cloned WOF GeoJSON repos
|
|
7
|
-
* (`scripts/build-unified-wof.ts`). The table and column names match the resolver's
|
|
8
|
-
* expectations (`lookup.ts`) so `WOFSQLitePlaceLookup` works unchanged. The `ancestors` table
|
|
9
|
-
* table is what lookup.ts's parent-constraint subquery reads (see `populateAncestors`).
|
|
10
13
|
* The `place_search` FTS5 and `place_bbox` R*Tree tables are built separately by `build-fts` (fts.ts).
|
|
11
14
|
*/
|
|
12
15
|
|
|
@@ -14,14 +17,27 @@ import type { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
|
14
17
|
|
|
15
18
|
import type { WOFDatabase } from "#schema"
|
|
16
19
|
|
|
20
|
+
/**
|
|
21
|
+
* The datasets a `names` or `concordances` row can come from.
|
|
22
|
+
*
|
|
23
|
+
* `libaddressinput` is the region abbreviations from the address specs.
|
|
24
|
+
* `mailwoman` is a row this repository wrote by hand or derived from no external dataset.
|
|
25
|
+
*/
|
|
26
|
+
export const ROW_SOURCES = ["wof", "overture", "geonames", "libaddressinput", "mailwoman"] as const
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* One of {@link ROW_SOURCES}.
|
|
30
|
+
*/
|
|
31
|
+
export type RowSource = (typeof ROW_SOURCES)[number]
|
|
32
|
+
|
|
17
33
|
export async function createUnifiedSchema(db: DatabaseClient<WOFDatabase>): Promise<void> {
|
|
18
|
-
// PRAGMAs run raw because Kysely
|
|
34
|
+
// PRAGMAs run raw because Kysely doesn't model them.
|
|
19
35
|
// They tune the bulk build.
|
|
20
36
|
db.exec("PRAGMA journal_mode = WAL")
|
|
21
37
|
db.exec("PRAGMA busy_timeout = 10000")
|
|
22
38
|
db.exec("PRAGMA synchronous = OFF")
|
|
23
39
|
|
|
24
|
-
// The caller owns `db`'s lifecycle, so this function
|
|
40
|
+
// The caller owns `db`'s lifecycle, so this function doesn't destroy it.
|
|
25
41
|
// The bulk INSERTs (populateAncestors + build-unified-wof) run on the raw handle.
|
|
26
42
|
|
|
27
43
|
await db.schema
|
|
@@ -56,6 +72,10 @@ export async function createUnifiedSchema(db: DatabaseClient<WOFDatabase>): Prom
|
|
|
56
72
|
// The name-exact tier already consults spr.name.
|
|
57
73
|
// `official` only marks the aliases eligible to join it.
|
|
58
74
|
// Both are ingest-time facts, never computed at query time.
|
|
75
|
+
//
|
|
76
|
+
// `source` on `names` and `concordances` is the dataset the row came from, one of {@link ROW_SOURCES}.
|
|
77
|
+
// A name another source adds to a WOF record keeps that source, so a license filter can find it.
|
|
78
|
+
// The empty default marks a writer that's not stated a source, and the admin verify step refuses it.
|
|
59
79
|
await db.schema
|
|
60
80
|
.createTable("names")
|
|
61
81
|
.ifNotExists()
|
|
@@ -67,6 +87,7 @@ export async function createUnifiedSchema(db: DatabaseClient<WOFDatabase>): Prom
|
|
|
67
87
|
.addColumn("privateuse", "text", (c) => c.notNull().defaultTo(""))
|
|
68
88
|
.addColumn("official", "integer", (c) => c.notNull().defaultTo(0))
|
|
69
89
|
.addColumn("lastmodified", "integer", (c) => c.notNull().defaultTo(0))
|
|
90
|
+
.addColumn("source", "text", (c) => c.notNull().defaultTo(""))
|
|
70
91
|
.execute()
|
|
71
92
|
|
|
72
93
|
await db.schema
|
|
@@ -76,6 +97,7 @@ export async function createUnifiedSchema(db: DatabaseClient<WOFDatabase>): Prom
|
|
|
76
97
|
.addColumn("other_id", "text", (c) => c.notNull())
|
|
77
98
|
.addColumn("other_source", "text", (c) => c.notNull())
|
|
78
99
|
.addColumn("lastmodified", "integer", (c) => c.notNull().defaultTo(0))
|
|
100
|
+
.addColumn("source", "text", (c) => c.notNull().defaultTo(""))
|
|
79
101
|
.execute()
|
|
80
102
|
|
|
81
103
|
await db.schema
|
package/lib/uprn/existence.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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 consult `./lookup.ts`'s docstring instructs: "callers building negative evidence must consult
|
|
6
6
|
* `readLayerCoverage`, not this reader by itself." A bare `null` from `nearestUPRN` is two different facts — no uprn here,
|
|
7
7
|
* or an unsurveyed area — and this is the only place that separates them. It answers an {@link Exclusion} or `null`,
|
|
8
8
|
* so a caller cannot read an unsurveyed cell as an empty one by accident.
|
|
9
9
|
*
|
|
10
|
-
* `radiusM` is a caller'S parameter with no default. There
|
|
10
|
+
* `radiusM` is a caller'S parameter with no default. There's no radius that's correct for both "which property is
|
|
11
11
|
* this coordinate" and "is this street built at all", and picking one here would bury that choice where reviewers
|
|
12
12
|
* reviewing an exclusion can see it.
|
|
13
13
|
*/
|
|
@@ -20,18 +20,18 @@ import type { UPRNLookup } from "#uprn/lookup"
|
|
|
20
20
|
import { UPRN_COVERAGE_H3_RESOLUTION, UPRN_H3_RESOLUTION, uprnH3Cell } from "#uprn/schema"
|
|
21
21
|
/**
|
|
22
22
|
* The identity fold, on purpose: this probe keys on a coordinate rather than a name,
|
|
23
|
-
* so there
|
|
23
|
+
* so there's no string folding for the builder and the probe to disagree about.
|
|
24
24
|
*
|
|
25
25
|
* The same identity in both `probeFold` and `layerFold` records that the fold axis
|
|
26
|
-
*
|
|
27
|
-
* It
|
|
26
|
+
* isn't in play here, rather than silently omitting the check.
|
|
27
|
+
* It isn't a stub.
|
|
28
28
|
*/
|
|
29
29
|
export const UPRN_EXISTENCE_FOLD = foldIdentity((s) => s)
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* The countries OS Open uprn covers.
|
|
33
33
|
*
|
|
34
|
-
* Northern Ireland is outside the product, so a `null` there
|
|
34
|
+
* Northern Ireland is outside the product, so a `null` there's unknown
|
|
35
35
|
* and must never become evidence of absence.
|
|
36
36
|
* The country check is what keeps it out.
|
|
37
37
|
*/
|
|
@@ -65,8 +65,8 @@ export function uprnCoverageCell(latitude: number, longitude: number): number {
|
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* An {@link Exclusion} when no uprn lies within `radiusM` and the layer's coverage licenses
|
|
68
|
-
* saying so; `null` on a hit (presence
|
|
69
|
-
* (unsurveyed cell, `source_present` basis, a country the product
|
|
68
|
+
* saying so; `null` on a hit (presence isn't this probe's business) and on every refusal
|
|
69
|
+
* (unsurveyed cell, `source_present` basis, a country the product doesn't cover).
|
|
70
70
|
*
|
|
71
71
|
* Never throws on a refusal: the caller falls open to the ranking it already had.
|
|
72
72
|
*/
|
package/lib/uprn/lookup.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* Node reader for `uprn.db`, where a `null` is evidence of absence only inside published coverage, so callers building negative evidence must consult `readLayerCoverage`.
|
|
5
|
+
* Node reader for `uprn.db`, where a `null` is evidence of absence only inside published
|
|
6
|
+
* coverage, so callers building negative evidence must consult `readLayerCoverage`.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { allRows } from "@mailwoman/core/utils"
|
|
@@ -70,8 +70,7 @@ interface UPRNRow {
|
|
|
70
70
|
export class UPRNLookup implements Disposable {
|
|
71
71
|
#db: DatabaseClient<UPRNDatabase>
|
|
72
72
|
/**
|
|
73
|
-
* Ownership is membership: a connection handed in by a caller
|
|
74
|
-
* so disposal cannot reach it.
|
|
73
|
+
* Ownership is membership: a connection handed in by a caller isn't in here, so disposal cannot reach it.
|
|
75
74
|
*/
|
|
76
75
|
readonly #resources: DisposableStack
|
|
77
76
|
|
|
@@ -105,7 +104,7 @@ export class UPRNLookup implements Disposable {
|
|
|
105
104
|
* The single nearest uprn within `radiusM` meters of the query point, or `null`
|
|
106
105
|
* when no uprn lies inside the radius.
|
|
107
106
|
*
|
|
108
|
-
* @throws {RangeError} When `radiusM`
|
|
107
|
+
* @throws {RangeError} When `radiusM` isn't a positive finite number, or exceeds the cap.
|
|
109
108
|
*/
|
|
110
109
|
nearestUPRN(latitude: number, longitude: number, radiusM: number): UPRNNearestHit | null {
|
|
111
110
|
if (!Number.isFinite(radiusM) || radiusM <= 0) {
|
package/lib/uprn/schema.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* Typed schema for `uprn.db`, storing OS's own WGS84 latitude/longitude verbatim rather than reconverting from the source's eastings.
|
|
5
|
+
* Typed schema for `uprn.db`, storing OS's own WGS84 latitude/longitude verbatim
|
|
6
|
+
* rather than reconverting from the source's eastings.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { layerschemadatabase } from "@mailwoman/core/layers"
|
package/lib/uprn.ts
CHANGED
|
@@ -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
|
export * from "#uprn/existence"
|
|
8
5
|
export * from "#uprn/lookup"
|