@finbheara/domain 0.23.0 → 0.25.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",
@@ -4167,6 +4169,15 @@ var PLACE_NODES = [
4167
4169
  prints: ["co wexford", "county wexford", "wexford"],
4168
4170
  codes: ["IE-WX"]
4169
4171
  },
4172
+ {
4173
+ id: "MEX-CMX",
4174
+ kind: "subdivision",
4175
+ name: "Ciudad de México",
4176
+ geo: "MEX",
4177
+ admin: null,
4178
+ prints: ["ciudad de mexico", "mexico city"],
4179
+ codes: ["MX-CMX"]
4180
+ },
4170
4181
  {
4171
4182
  id: "MEX-QUE",
4172
4183
  kind: "subdivision",
@@ -5936,6 +5947,15 @@ var PLACE_NODES = [
5936
5947
  prints: ["baton rouge"],
5937
5948
  codes: []
5938
5949
  },
5950
+ {
5951
+ id: "USA-LA/kenner",
5952
+ kind: "city",
5953
+ name: "Kenner",
5954
+ geo: "USA-LA",
5955
+ admin: "IDTANA-SRO",
5956
+ prints: ["kenner"],
5957
+ codes: []
5958
+ },
5939
5959
  {
5940
5960
  id: "USA-LA/new-orleans",
5941
5961
  kind: "city",
@@ -6920,6 +6940,15 @@ var PLACE_NODES = [
6920
6940
  admin: "IDTANA-MAO",
6921
6941
  prints: ["milwaukee"],
6922
6942
  codes: []
6943
+ },
6944
+ {
6945
+ id: "USA-WI/new-berlin",
6946
+ kind: "city",
6947
+ name: "New Berlin",
6948
+ geo: "USA-WI",
6949
+ admin: "IDTANA-MAO",
6950
+ prints: ["new berlin"],
6951
+ codes: []
6923
6952
  }
6924
6953
  ];
6925
6954
 
@@ -7094,6 +7123,7 @@ var PLACE_WITHIN = {
7094
7123
  "USA-KY/lexington": { nodes: [], names: ["Fayette", "Fayette County", "Kentucky"] },
7095
7124
  "USA-KY/louisville": { nodes: [], names: ["Jefferson", "Jefferson County", "Kentucky"] },
7096
7125
  "USA-LA/baton-rouge": { nodes: [], names: ["East Baton Rouge Parish", "Louisiana"] },
7126
+ "USA-LA/kenner": { nodes: [], names: ["Jefferson Parish", "Louisiana"] },
7097
7127
  "USA-LA/new-orleans": { nodes: [], names: ["Louisiana", "Orleans Parish"] },
7098
7128
  "USA-MA/boston": { nodes: [], names: ["Massachusetts", "Suffolk", "Suffolk County"] },
7099
7129
  "USA-MA/lexington": { nodes: [], names: ["Massachusetts", "Middlesex", "Middlesex County"] },
@@ -7211,7 +7241,8 @@ var PLACE_WITHIN = {
7211
7241
  "USA-WA/spokane": { nodes: [], names: ["Spokane", "Spokane County", "Washington"] },
7212
7242
  "USA-WA/tacoma": { nodes: [], names: ["Pierce", "Pierce County", "Washington"] },
7213
7243
  "USA-WI/madison": { nodes: [], names: ["Dane", "Dane County", "Wisconsin"] },
7214
- "USA-WI/milwaukee": { nodes: [], names: ["Milwaukee", "Milwaukee County", "Wisconsin"] }
7244
+ "USA-WI/milwaukee": { nodes: [], names: ["Milwaukee", "Milwaukee County", "Wisconsin"] },
7245
+ "USA-WI/new-berlin": { nodes: [], names: ["Waukesha", "Waukesha County", "Wisconsin"] }
7215
7246
  };
7216
7247
 
7217
7248
  var QUALIFIER_DELIMITER = /[,;:()[\]/–—-]/;
@@ -7510,12 +7541,26 @@ function createPlaceReader2(options = {}) {
7510
7541
  const parents = new Map;
7511
7542
  for (const n of source)
7512
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
+ };
7513
7554
  const ancestorsOf = new Map;
7514
7555
  for (const n of source) {
7515
7556
  const out = new Set;
7516
7557
  const todo = [n];
7558
+ const own = countryOnMap(n);
7517
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;
7518
7561
  for (const parent of parents.get(at.id) ?? []) {
7562
+ if (foreign && parent.id === at.geo)
7563
+ continue;
7519
7564
  if (parent.id === n.id || out.has(parent.id))
7520
7565
  continue;
7521
7566
  out.add(parent.id);
@@ -8794,4 +8839,4 @@ function sameReading2(a, b) {
8794
8839
  return DEFAULT_PLACE_READER2.sameReading(a, b);
8795
8840
  }
8796
8841
 
8797
- 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";