Skip to content

Remove off-course overshoot in osmium extract (#32)#48

Open
zaheerm wants to merge 2 commits into
HuggeK:mainfrom
zaheerm:chore/look-at-github-issue-32
Open

Remove off-course overshoot in osmium extract (#32)#48
zaheerm wants to merge 2 commits into
HuggeK:mainfrom
zaheerm:chore/look-at-github-issue-32

Conversation

@zaheerm

@zaheerm zaheerm commented Jul 4, 2026

Copy link
Copy Markdown

Fixes #32.

Problem

The geographic extract in run_all.sh used --strategy=smart -S types=multipolygon,route. On its own, smart reference-completes every multipolygon/route relation that merely touches a leisure=golf_course boundary, dragging all of their far-away members into the tiles — bus/bike/hiking routes, large landuse/natural=water multipolygons, public roads. That is the "features stretching outside the facility" overshoot visible in the PMTiles inspector.

Fix

  1. Restrict reference-completion to golf-relevant relations by adding -S tags=leisure=golf_course,route=golf,golf. The smart option semantics are "(types OR complete-partial-relations) AND tags", so only (multipolygon|route) relations tagged as golf features stay complete; every other relation keeps just the members that actually fall inside the polygon. This preserves the route=golf multi-course schema while removing the off-course overshoot.

  2. Add a reference-completeness step before tilemaker. osmium extract can emit a relation-member way (e.g. a big landuse=forest multipolygon clipped by a course) without copying every node it references, which makes tilemaker abort with SortedNodeStore: node <id> missing, no node. The new step re-adds only the missing nodes via osmium check-refs -iosmium getid (without -r) → osmium merge, so no extra ways/relations — and therefore no overshoot — are reintroduced. It is a no-op on already-complete extracts.

Verification

Built tilemaker (from the submodule) and ran the full pipeline end-to-end on the Luxembourg extract:

Metric before after
extract nodes 27,723 24,246 (−12.5%)
extract ways 1,646 1,179 (−28%)
golf feature ways 697 697 — none lost
off-course overshoot ways 467 removed (tracks, paths, steps, residential/secondary/primary roads, water…)

bash run_all.sh completes and writes golfTiles.pmtiles without crashing.

Note (separate build gotcha, not fixed here)

A plain make in the tilemaker submodule auto-selects LuaJIT (Lua 5.1), but custom-tilemaker/process.lua uses math.tointeger, which requires Lua 5.3+ (as the README states). Building with make LUA_CMD=lua (Lua 5.3+) is required or the pipeline crashes on golf holes/tees. Worth documenting in the README/INSTALL; happy to add in a follow-up.

🤖 Generated with Claude Code

The geographic extract used `--strategy=smart -S types=multipolygon,route`,
which reference-completes EVERY multipolygon/route relation that merely
touches a golf_course boundary. That drags all their far-away members
(bus/bike/hiking routes, large landuse/water multipolygons, public roads)
into the tiles, producing the "features stretching outside the facility"
overshoot reported in issue HuggeK#32.

- Restrict reference-completion to golf-relevant relations by adding
  `-S tags=leisure=golf_course,route=golf,golf`. The smart option semantics
  are "(types OR complete-partial-relations) AND tags", so only
  (multipolygon|route) relations tagged as golf features stay complete;
  everything else keeps just the members inside the polygon. This preserves
  the route=golf multi-course schema while removing the off-course overshoot.

- Add a reference-completeness step before tilemaker. osmium extract can emit
  a relation-member way without copying every node it references, which makes
  tilemaker abort ("SortedNodeStore: node <id> missing, no node"). We re-add
  only the missing nodes via `osmium check-refs -i` + `osmium getid` (without
  -r) + `osmium merge`, so no extra ways/relations (and no overshoot) return.

Verified end-to-end on the Luxembourg extract: 467 off-course ways removed,
all 697 golf feature ways preserved, tilemaker renders golfTiles.pmtiles
without crashing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@HuggeK

HuggeK commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Tested this end-to-end on the full Sweden extract — the overshoot fix from #32 works, and the effect is dramatic. Findings first, then a direction note.

Findings

Direction (maintainability)

The -S tags=leisure=golf_course,route=golf,golf allowlist solves the overshoot by enumerating golf-specific features, but we do not want to limit ourselves to naming the specific features that can be found at a golf club — that list has to be kept in lockstep with the schema, and it becomes hard to maintain as the style explodes in the amount of layers. It is fine as the stopgap that this PR is.

The end goal should instead be cutouts of features at the facility borders: clip geometries to the leisure=golf_course polygons, closing areas along the border where they leave and re-enter. That is not something the osmium/tilemaker pipeline can express (osmium includes or excludes whole objects; it never creates the boundary-intersection nodes clipping requires) — it belongs in the PostGIS-based dynamic tile server future tracked in #21, where it is an ST_Intersection away. A cheap intermediate until then: tile-level clipping after tilemaker with pmtiles extract --region=<courses.geojson> (the region can be generated from the pipeline's own golf-course mask via osmium export).

Test setup and numbers
  • Input: sweden-latest.osm.pbf (808 MB, Geofabrik, 2026-07-05), run in the repo's Docker image (Add Dockerfile to run the tile pipeline without local dependencies #46) with this branch's run_all.sh bind-mounted.
  • Pipeline exit 0; the check-refs guard took the "Extract is already reference-complete" path (no missing nodes needed re-adding on this input).
  • Output: valid PMTiles v3 archive, all 7 schema layers, 8,579 addressed tiles / 9.8 MB — vs 40,582 tiles / 20.8 MB without this fix on the same input.
  • Emmaboda GK z14 tile (14/8901/5058): present, 17,284 bytes (vs 17,873 without the fix — near-identical on-course content).

In regards to #32.

🤖 Generated with Claude Code

…HuggeK#47)

Pipeline order after the merge: tags-restricted extract -> node-reference
completion -> osmium renumber (now reading extract.complete.osm.pbf) ->
tilemaker --compact reading renumbered.osm.pbf.

Co-authored-by: HuggeK <48095810+HuggeK@users.noreply.github.com>
@HuggeK

HuggeK commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Gets this:
bug when cliping
Which does not seem right.

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.

Remove unnecessary features which stretches outside of a leisure=golf_course facility

3 participants