Skip to content

Name a derived context the way a reader knows the place - #209

Merged
clarkbw merged 3 commits into
mainfrom
derived-places
Sep 27, 2026
Merged

clarkbw merged 3 commits into
mainfrom
derived-places

Conversation

@clarkbw

@clarkbw clarkbw commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Derived contexts now name the place a reader knows, spelled the way GeoNames spells it. This is the database half of dropping station-metadata from Slackwater iOS (openwatersio/slackwater-ios#469). The app's region lines come from station-metadata's resolver today; after this, the database's contexts match them or improve on them. The website ignores derived contexts and is unaffected.

Recognition. A derived context picks its place by distance minus 3 km of credit per tenfold of population over 1,000, within 40 km and in the station's own country. It used to take the nearest place, which was often a neighbourhood: "Chinatown, CA" for an Oakland gauge. Locality, region and region code stay on the nearest place, so no route moves. This is the rule station-metadata's resolver applies. US territories are named like states, "Carolina, PR" rather than "Carolina, Carolina", because GeoNames files them as countries whose regions are municipalities.

Place snapshot. metadata/places.json is now built by a committed script, packages/stations/fetch-places.ts. It keeps GeoNames' own names, accents included, where the old snapshot was ASCII-folded: "Mayagüez" rather than "Mayagueez", "Møre og Romsdal" rather than "More og Romsdal".

  • A section of a city (GeoNames feature code PPLX) is flagged and never labels a station. Examples are "Chinatown", "Waterfront Communities-The Island", and "South Boston", which GeoNames gives Boston's whole population.
  • Sections still count for locality and region. Dropping them outright moved the nearest place for 28 New York Harbor currents into New Jersey and changed their routes.
  • The builder also keeps each station's ten nearest non-section places, so a dense city's sections cannot crowd out the city itself.
  • Run with ASCII names and no flag, the builder reproduces 15,911 of the old snapshot's 15,947 places; the rest are two weeks of GeoNames edits. PROVENANCE.md records the new download checksums.

Restatements. The check that drops a label repeating the station's name folds accents first. Without that, "Limon" got "Limón, Limón Province" once the snapshot carried accents.

Against 1.0.0-beta.20260927:

  • 1,319 derived contexts, 436 localities and 11 regions change. Nothing else changes, and no station's own or curated context is touched.
  • metadata:lock: 0 added, 0 moved, 0 removed; no country or region code changes
  • validate:database clean; root npm test and lint pass

Measured against the labels Slackwater iOS ships from station-metadata, for the stations where the app shows a derived town:

Tides Currents
Same label 1,148 495
Database has the station's own water, which the app never shows 1,347 5
Database names a bay or strait 285 160
Canadian province spelled out ("Hamilton, Ontario") 24 0
Same town, database keeps it in the station's country 6 0
Different town 12 2
No context 26 5

Of the 12 different towns, 9 are the database keeping the label in the station's own country, for example "Port Huron, MI" for a Michigan gauge where the app says "Sarnia, ON". The rest are GeoNames' own names for a place, such as "Makakilo / Kapolei / Honokai Hale".

45 stations lose a label. 37 of those had a label naming their own city, like "Gamla Stan, Stockholm" on Stockholm, and the city now wins and restates the name. 16 gain one: ten Puerto Rico stations named for their town now read "PR", four Norwegian stations added since the last snapshot now have places in range, and two Omani stations gain their governorate.

🤖 Generated with Claude Code

A derived context picks its place by distance less 3 km of credit per tenfold of population over 1,000, within 40 km and in the station's own country, instead of taking the nearest place. The nearest place was often a neighbourhood: "Chinatown, CA" for an Oakland gauge, "Ala Moana, HI" in Honolulu. Locality, region and region code stay on the nearest place, so no route moves. It is the rule station-metadata's resolver applies, which Slackwater iOS shows today, and it takes the database one step from being the app's naming source.

US territories are named like states in a derived label, "Carolina, PR" rather than "Carolina, Carolina": GeoNames files them as countries whose regions are municipalities.

Against 1.0.0-beta.20260927: 960 derived contexts change and nothing else does; metadata:lock moves no route. 34 stations named for a city lose a neighbourhood label ("Gamla Stan, Stockholm" on Stockholm), because the city itself now wins and restates the name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@slackwater/database@209

commit: 71c04c3

clarkbw and others added 2 commits September 27, 2026 10:14
…ctions flagged

metadata/places.json is built by packages/stations/fetch-places.ts, committed alongside it: the ten nearest GeoNames cities500 places within 100 km of every station, as before, plus the ten nearest that are not a section of a city, so a dense city's sections cannot crowd the city itself out of the label candidates. Run with the ASCII names and without the flag, the builder reproduces 15,911 of the 15,947 places the previous snapshot held; the rest are two weeks of GeoNames edits.

Names are the ones GeoNames publishes, accents included: "Mayagüez" rather than "Mayagueez", "Hale‘iwa", "Côte-Saint-Luc", "Møre og Romsdal". A section of a city (feature code PPLX: "Chinatown", "South Boston", which GeoNames gives Boston's whole population) carries `section` and never labels a station. It still places one, because dropping sections outright moved the nearest place for 28 New York Harbor currents into New Jersey and changed their routes.

Against 1.0.0-beta.20260927, with the recognition rule: 1,361 derived contexts, 436 localities and 11 regions change, all accents, city sections, the Norwegian county reform and stations added since the last snapshot. No country, region code or route changes; metadata:lock moves nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A label that repeats the station's name is dropped, but the check compared accented text, so "Limon" kept "Limón, Limón Province" and "Mazatlan" kept "Mazatlán, Sinaloa". The check folds diacritics on both sides first, so an accented name is judged the way an unaccented one already was.

112 contexts change, each one a restatement of the station's name. The town gives way to its region ("Málaga, Andalusia" becomes "Andalusia"), or, where the region restates the name too, to no label. That includes water bodies OpenStreetMap names with accents: "Gulf of Cádiz" on Cadiz becomes "Andalusia", as an unaccented "Gulf of Cadiz" already would.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clarkbw clarkbw changed the title Label a derived context with the place a reader knows Name a derived context the way a reader knows the place Sep 27, 2026
@clarkbw
clarkbw requested a lite review from Copilot September 27, 2026 17:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Updates derived station contexts to use recognizable GeoNames places with population-aware selection, section filtering, accent handling, and territory-aware labels.

Changes:

  • Added scored derived-place selection and accent normalization.
  • Added GeoNames snapshot generation and provenance documentation.
  • Expanded tests for recognition and territory behavior.
File Description
packages/​stations/​test/​metadata.test.ts Tests derived-context recognition and edge cases.
packages/​stations/​package.json Adds the place snapshot-generation command.
packages/​stations/​metadata.ts Implements scored place selection and accent folding.
packages/​stations/​geocode.ts Adds city-section metadata support.
packages/​stations/​fetch-places.ts Builds the filtered GeoNames snapshot.
metadata/​PROVENANCE.md Documents snapshot generation and checksums.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@clarkbw
clarkbw merged commit 2e91b39 into main Sep 27, 2026
6 checks passed
@clarkbw
clarkbw deleted the derived-places branch September 27, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants