Name a derived context the way a reader knows the place - #209
Merged
Merged
Conversation
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>
commit: |
…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
force-pushed
the
derived-places
branch
from
September 27, 2026 17:18
a359453 to
71c04c3
Compare
Contributor
There was a problem hiding this comment.
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.
This was referenced Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsonis 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".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:metadata:lock: 0 added, 0 moved, 0 removed; no country or region code changesvalidate:databaseclean; rootnpm testand lint passMeasured against the labels Slackwater iOS ships from station-metadata, for the stations where the app shows a derived town:
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