Skip to content

Keep one coordinate per nd when a way's node has no known position - #56

Open
cldellow wants to merge 1 commit into
history-import-flush-at-object-boundaryfrom
history-unknown-node-geometry
Open

cldellow wants to merge 1 commit into
history-import-flush-at-object-boundaryfrom
history-unknown-node-geometry

Conversation

@cldellow

Copy link
Copy Markdown
Owner

Depends on #55; targets its branch.

Fixes #49.

Collected with the other import changes on better-imports, which is kept apart from all-changes.

Change

compute_idx_and_geometry skipped a node it found neither in the attic nor in the current data. In a regional history extract that happens to nodes whose only version in the extract is their deletion. The stored way version then had fewer coordinates than nodes, so every older version failed to expand with "Bad geometry for way". Now, as compute_geometry already does for current versions, a zero Quad_Coord is pushed for such a node, and the index is computed only from the nodes with a known position. Queries print the node as <nd ref="N"/> without coordinates. One function, a few lines.

Impact

  • Benchmark queries and the prompting query: none; osm3s_query is unchanged. Not re-timed.
  • Import time: PEI 2:52 (single run), unchanged.

Testing

  • Minimal reproduction: the affected PEI way with all versions of its nodes (osmium getid --with-history -r; 12 way versions, 512 node versions): before, [date:"2011-01-01T00:00:00Z"];way(<id>);out geom; failed with "Bad geometry"; after, it prints the way with its bounds, and the two unknown nodes as references without coordinates.
  • PEI, world-box query (as in Keep new attic skeletons when importing into an empty database with attic #51) at 2008-06-01, 2010-01-01, 2013-01-29T20:30 and 2016-01-01: no query errors at all; the only missing ways are the 3 and 11 that refer to a node absent at that date in the source.
  • Differential fuzzing against the PEI database of the previous PR (fuzz.py --db-b, --features history,users,complete --seed 2 --count 1500): 1,490 same, 3 skipped, 7 different; in all 7, the previous database printed "Bad geometry" errors for two ways and this one doesn't.
  • Nova Scotia (licensed full-history extract, 20.3 M node, 2.1 M way and 131 k relation versions): the world-box query at 2010-01-01 wrote 318 lines to stderr before (not classified line by line; the PEI equivalents were "Bad geometry" errors) and 4 after, all routine remarks and progress reports; missing ways went from 14 to 13, all referring to a node absent at that date in the source.

Limitations

  • The zero coordinate is a placeholder, as in compute_geometry. Code that reads stored geometry without checking for it would see a point at the origin of the quad-tile scheme; query output doesn't.

Generated by Claude Code

compute_idx_and_geometry skipped nodes it found neither in the attic nor in
the current data. In a regional history extract that happens to nodes whose
only version in the extract is their deletion, e.g. because they were
outside the region while visible. The stored way version then had fewer
coordinates than nds, and since older versions are stored as deltas from
newer ones, expanding any older version through it failed with "Bad geometry
for way", so [date:] queries lost the way for every earlier date.

Do as compute_geometry already does for current versions: push a zero
Quad_Coord for the unknown node, keeping the geometry aligned with the nds,
and compute the index only from the nodes with a known position. Queries
print such a node as a reference without coordinates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01736kJV9ygtU1g57EBR2Ufo
@cldellow cldellow added the query-perf Query performance change; collected on all-changes label Nov 21, 2026 — with Claude
@cldellow cldellow added the import-fix Fixes to update_database / history imports; collected on better-imports, not all-changes label Nov 21, 2026 — with Claude
@cldellow cldellow removed the query-perf Query performance change; collected on all-changes label Nov 21, 2026
@cldellow cldellow added the bug Fixes wrong results (in addition to the kind label) label Nov 21, 2026 — with Claude
@mmd-osm

mmd-osm commented Nov 29, 2026 •

Copy link
Copy Markdown

I’m not sure if 0, 0 is really a good choice. Elsewhere there’s 200, 100 in use for invalid geometry. This needs some more thought about potential side effects.

@cldellow

Copy link
Copy Markdown
Owner Author

Thanks, good catch.

I'm going to leave it as is for the moment -- for now, I'm not expecting/intending to offer the better-imports series of commits upstream, they were just so I could bootstrap a database locally to have something to do performance analysis against.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Fixes wrong results (in addition to the kind label) import-fix Fixes to update_database / history imports; collected on better-imports, not all-changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants