@finbheara/domain 0.28.0 → 0.30.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 +8 -0
- package/dist/geocode.js +30 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -121,8 +121,16 @@ geocode("Yonkers, NY").region; // "IDTANA-MARO"
|
|
|
121
121
|
geocode("Brooklyn").isPlace(); // false: a town of six US states and more, so only
|
|
122
122
|
// `Brooklyn, NY` reads
|
|
123
123
|
place("Drogheda").arm; // "unread": the store holds no Drogheda
|
|
124
|
+
geocode("Prague", { near: "RCCEA", declared: true }).isPlace();
|
|
125
|
+
// false: the context lies outside the layer's
|
|
126
|
+
// countries, so no namesake town is read
|
|
124
127
|
```
|
|
125
128
|
|
|
129
|
+
A context (a `country` or `near`) that reads to a place outside those six countries stops the
|
|
130
|
+
layer for a bare town, so a city elsewhere is never read as its namesake in them. With no
|
|
131
|
+
context `geocode("Prague")` is Prague, Oklahoma, the one Prague the layer holds. A print with a
|
|
132
|
+
qualifier (`Yonkers, NY`) is never stopped: the context never overrules the print.
|
|
133
|
+
|
|
126
134
|
A `Place` is one of four arms: `resolved`, `plural` (a print naming more than one place),
|
|
127
135
|
`ambiguous` (one print, several readings) and `unread`. Only `conflict` between two readings
|
|
128
136
|
says they cannot be one place; `same`, `contains` and `overlaps` do not.
|
package/dist/geocode.js
CHANGED
|
@@ -2,7 +2,9 @@ import"./chunks/place-tcgfvemw.js";
|
|
|
2
2
|
import {
|
|
3
3
|
PLACE_NODES,
|
|
4
4
|
createPlaceReader2,
|
|
5
|
-
place2
|
|
5
|
+
place2,
|
|
6
|
+
placeFromId2,
|
|
7
|
+
placeParts2
|
|
6
8
|
} from "./chunks/place-h2s1w0tq.js";
|
|
7
9
|
|
|
8
10
|
var PLACE_TOWNS = {
|
|
@@ -199,6 +201,31 @@ function oneTown(t) {
|
|
|
199
201
|
function townInside(t, s) {
|
|
200
202
|
return oneTown(t) && t.nodes.some((n) => n.id === s.pl3);
|
|
201
203
|
}
|
|
204
|
+
var layerCountries;
|
|
205
|
+
function townCountries() {
|
|
206
|
+
if (layerCountries !== undefined)
|
|
207
|
+
return layerCountries;
|
|
208
|
+
const out = new Set;
|
|
209
|
+
for (const parent of Object.keys(PLACE_TOWNS)) {
|
|
210
|
+
const c = placeFromId2(parent).country;
|
|
211
|
+
if (c !== undefined)
|
|
212
|
+
out.add(c);
|
|
213
|
+
}
|
|
214
|
+
layerCountries = [...out].sort();
|
|
215
|
+
return layerCountries;
|
|
216
|
+
}
|
|
217
|
+
function outsideLayer(want) {
|
|
218
|
+
const byId = placeFromId2(want);
|
|
219
|
+
const p = byId.isPlace() ? byId : place2(want);
|
|
220
|
+
return p.isPlace() && !townCountries().some((c) => p.overlaps(c));
|
|
221
|
+
}
|
|
222
|
+
function ruledOut(print, t, ctx) {
|
|
223
|
+
if (ctx === undefined || typeof ctx === "string")
|
|
224
|
+
return false;
|
|
225
|
+
if (placeParts2(print).length !== 1)
|
|
226
|
+
return false;
|
|
227
|
+
return [ctx.country, ctx.near].some((w) => w !== undefined && w.trim() !== "" && t.misses.includes(w) && outsideLayer(w));
|
|
228
|
+
}
|
|
202
229
|
function geocode(print, ctx) {
|
|
203
230
|
const s = place2(print, ctx);
|
|
204
231
|
if (s.refusal !== null)
|
|
@@ -206,6 +233,8 @@ function geocode(print, ctx) {
|
|
|
206
233
|
if (s.isPlace() && !(s.isSingular() && s.level === "subdivision"))
|
|
207
234
|
return s;
|
|
208
235
|
const t = layerReader().place(print, ctx);
|
|
236
|
+
if (ruledOut(print, t, ctx))
|
|
237
|
+
return s;
|
|
209
238
|
if (!s.isPlace())
|
|
210
239
|
return oneTown(t) ? t : s;
|
|
211
240
|
return townInside(t, s) ? t : s;
|
package/package.json
CHANGED