@finbheara/domain 0.24.0 → 0.26.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 CHANGED
@@ -34,6 +34,7 @@ ESM, Node ≥ 22 or Bun ≥ 1.4.2. MIT. Not affiliated with or endorsed by any d
34
34
  | import | what |
35
35
  |---|---|
36
36
  | `@finbheara/domain/place` | `place()`, `createPlaceReader`, `placeRelation`, the `Place` types |
37
+ | `@finbheara/domain/geocode` | `geocode()`: a location field read by the place store, then by every GeoNames town of AU, CA, GB, IE, NZ and US; `townCell` |
37
38
  | `@finbheara/domain/clrg-regions` | `REGIONS`, `regionOf`, `resolvePhrase` |
38
39
  | `@finbheara/domain/school` | `createSchoolNameReader`, `DEFAULT_SCHOOL_NAME_READER`, `compareSchoolNames`, `foldSchoolName`, `schoolEncoder`, `schoolColumns` |
39
40
  | `@finbheara/domain/tune` | `tune()`, `tuneRelation`, `tempoLegal`, `settingAt`, `TUNE_NODES`: the CLRG set dance list, each tune with its time, speeds and bars |
@@ -104,6 +105,24 @@ A town followed by a county, district or region reads as the town only where tha
104
105
  it: `place("Coventry, West Midlands")` is Coventry, and `place("Coventry, Kent")` is two places.
105
106
  Which units hold each town is a table read off GeoNames.
106
107
 
108
+ ### Geocoding a location field
109
+
110
+ `place()` holds the places a print of a school or a person may carry, and it reads no other
111
+ town: a town name is often a surname or a word. A caller holding a LOCATION field reads it with
112
+ `geocode()`, which keeps the store's reading and, where the store reads nothing or reads only
113
+ the county or state, reads the GeoNames town layer, and answers only where it reads ONE town: every `cities500` town of Australia, Canada,
114
+ Great Britain, Ireland, New Zealand and the United States, under the store node that holds it.
115
+
116
+ ```ts
117
+ import { geocode } from "@finbheara/domain/geocode";
118
+
119
+ geocode("Drogheda").pl3; // "IRL-LH/drogheda", in Leinster
120
+ geocode("Yonkers, NY").region; // "IDTANA-MARO"
121
+ geocode("Brooklyn").isPlace(); // false: a town of six US states and more, so only
122
+ // `Brooklyn, NY` reads
123
+ place("Drogheda").arm; // "unread": the store holds no Drogheda
124
+ ```
125
+
107
126
  A `Place` is one of four arms: `resolved`, `plural` (a print naming more than one place),
108
127
  `ambiguous` (one print, several readings) and `unread`. Only `conflict` between two readings
109
128
  says they cannot be one place; `same`, `contains` and `overlaps` do not.
@@ -507,5 +526,8 @@ seatName("Aoife Mhaolvarna").nn2; // "Mhaolvarna<<Aoife": nam
507
526
 
508
527
  MIT, Copyright (c) 2026 Finbheara Systems.
509
528
 
510
- The place-containment table contains data from GeoNames (https://www.geonames.org/), licensed
511
- under CC BY 4.0.
529
+ The place-containment table and the town layer contain data from GeoNames
530
+ (https://www.geonames.org/), licensed under CC BY 4.0
531
+ (https://creativecommons.org/licenses/by/4.0/). The town layer is GeoNames' `cities500`,
532
+ filtered to six countries and filed under this package's place nodes, each town citing its
533
+ geonameid.
package/dist/ceili.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  ceiliById2,
5
5
  ceili2,
6
6
  ceiliRelation2
7
- } from "./chunks/place-kk48pfja.js";
7
+ } from "./chunks/place-1cfxanhy.js";
8
8
  import"./chunks/place-htxgptyv.js";
9
9
  export {
10
10
  CEILI_NODES2 as CEILI_NODES,
@@ -6,6 +6,7 @@ import {
6
6
  validity
7
7
  } from "./place-q9kwsmzd.js";
8
8
 
9
+ var FOREIGN_MEMBER_REGIONS = ["IDTANA-SRO"];
9
10
  var PLACE_NODES = [
10
11
  {
11
12
  id: "world",
@@ -260,6 +261,7 @@ var PLACE_NODES = [
260
261
  "s usa",
261
262
  "so usa",
262
263
  "southern region",
264
+ "southern region mexico usa",
263
265
  "southern region usa",
264
266
  "southern us",
265
267
  "southern usa",
@@ -2094,7 +2096,7 @@ var PLACE_NODES = [
2094
2096
  kind: "country",
2095
2097
  name: "Mexico",
2096
2098
  geo: "north-america",
2097
- admin: null,
2099
+ admin: "IDTANA-SRO",
2098
2100
  prints: ["meicsiceo", "mex", "mexican", "mexico"],
2099
2101
  codes: ["MEX", "MX"],
2100
2102
  iso2: "MX",
@@ -7539,12 +7541,26 @@ function createPlaceReader2(options = {}) {
7539
7541
  const parents = new Map;
7540
7542
  for (const n of source)
7541
7543
  parents.set(n.id, upOf(n));
7544
+ const countryOnMap = (n) => {
7545
+ const seen = new Set;
7546
+ for (let at = n;at !== undefined && !seen.has(at.id); ) {
7547
+ if (at.kind === "country")
7548
+ return at.id;
7549
+ seen.add(at.id);
7550
+ at = at.geo === null ? undefined : byId.get(at.geo);
7551
+ }
7552
+ return;
7553
+ };
7542
7554
  const ancestorsOf = new Map;
7543
7555
  for (const n of source) {
7544
7556
  const out = new Set;
7545
7557
  const todo = [n];
7558
+ const own = countryOnMap(n);
7546
7559
  for (let at = todo.pop();at !== undefined; at = todo.pop()) {
7560
+ const foreign = at.kind === "region" && FOREIGN_MEMBER_REGIONS.includes(at.id) && own !== undefined && countryOnMap(at) !== own;
7547
7561
  for (const parent of parents.get(at.id) ?? []) {
7562
+ if (foreign && parent.id === at.geo)
7563
+ continue;
7548
7564
  if (parent.id === n.id || out.has(parent.id))
7549
7565
  continue;
7550
7566
  out.add(parent.id);
@@ -8823,4 +8839,4 @@ function sameReading2(a, b) {
8823
8839
  return DEFAULT_PLACE_READER2.sameReading(a, b);
8824
8840
  }
8825
8841
 
8826
- export { NEVER_NAME, printZones, opensLocation, DEFAULT_PLACE_CAPACITY2, createPlaceReader2, DEFAULT_PLACE_READER2, place2, isPlaceToken2, countryCodeOf2, areAllPlaceTokens2, placeFromId2, placeWindows2, placeParts2, oireachtasOfRegion2, regionOfOireachtas2, placeStats2, resetPlaceCache2, placeRelation2, placesRelation2, probablySamePlace2, sameReading2 };
8842
+ export { PLACE_NODES, NEVER_NAME, printZones, opensLocation, DEFAULT_PLACE_CAPACITY2, createPlaceReader2, DEFAULT_PLACE_READER2, place2, isPlaceToken2, countryCodeOf2, areAllPlaceTokens2, placeFromId2, placeWindows2, placeParts2, oireachtasOfRegion2, regionOfOireachtas2, placeStats2, resetPlaceCache2, placeRelation2, placesRelation2, probablySamePlace2, sameReading2 };
package/dist/dance.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import"./chunks/place-htxgptyv.js";
2
2
  import {
3
3
  ceili2
4
- } from "./chunks/place-kk48pfja.js";
4
+ } from "./chunks/place-1cfxanhy.js";
5
5
  import {
6
6
  tune2
7
- } from "./chunks/place-yndzaae5.js";
7
+ } from "./chunks/place-26pfr6ak.js";
8
8
  import {
9
9
  validity
10
10
  } from "./chunks/place-q9kwsmzd.js";