Skip to content

Use the last known position of a deleted node in a way's geometry - #53

Open
cldellow wants to merge 1 commit into
history-visible-falsefrom
history-deleted-node-geometry
Open

cldellow wants to merge 1 commit into
history-visible-falsefrom
history-deleted-node-geometry

Conversation

@cldellow

Copy link
Copy Markdown
Owner

Depends on #52; targets its branch.

Fixes #46.

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

Change

History data has way versions that refer to nodes deleted before them; in the PEI extract, the nodes of a way were deleted ten seconds before the way. compute_idx_and_geometry skipped such nodes, so the stored way had fewer coordinates than nodes. Overpass stores older way versions as deltas from newer ones, so expanding any older version through that state failed with "Bad geometry for way", and [date:] queries lost the way for every earlier date.

Now the node's last known position is used, keeping one coordinate per node. The relation index computation does the same for node and way members. Two files, 14 lines.

Impact

  • Benchmark queries and the prompting query: none; osm3s_query is unchanged. Not re-timed.
  • Import: not timed separately; the change adds one comparison per node that has expired.

Testing

World-box query as in #51, PEI extract, compared with osmium:

Date Ways, osmium Missing without this PR Missing with it
2008-06-01 1,020 2 0
2010-01-01 2,094 2 0
2013-01-29T20:30 54,359 3 3
2016-01-01 68,760 11 11

The remaining 3 and 11 ways all refer, at that date, to a node that the extract shows as deleted: the extract lacks the way versions that removed those nodes. The stored versions are complete, but at query time a small way's coordinates are looked up from the nodes valid at the date, so they can't be shown. That is a gap in the source data, not an import error.

Limitations

  • A way that really referred to a deleted node now shows that node at its last position for that time span, instead of failing.

Generated by Claude Code

History data has way versions that refer to nodes deleted before them. In
the extract this was found with, a way's nodes were deleted ten seconds before
the way itself. compute_idx_and_geometry then skipped those nodes, so the
stored way had fewer coordinates than nds. Overpass stores older way versions
as deltas from the newer ones, so expanding any older version through that
state fails with "Bad geometry for way", and [date:] queries lose the way for
every date before it, not only for the ten seconds.

Use the node's last known position instead, keeping one coordinate per nd. Do
the same for node and way members when computing a relation's index.

Before deletions in history files were honoured, such nodes stayed alive at the
placeholder position, which hid this.

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
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.

2 participants