Skip to content

fix: let -link-pylovo re-link and report already-linked buildings - #155

Merged
jravani merged 1 commit into
mainfrom
fix/link-pylovo-relink
Oct 1, 2026
Merged

jravani merged 1 commit into
mainfrom
fix/link-pylovo-relink

Conversation

@jravani

@jravani jravani commented Oct 1, 2026

Copy link
Copy Markdown
Member

Closes #154.

What

  • -link-pylovo reports correctly when every building is already linked.
  • The new -link-pylovo -relink re-links buildings that already have a building_link row, for example after the PyLovo data changed.

Why

-link-pylovo batches only buildings without a building_link row. That is deliberate, and it is kept: a run after a small import links just the new buildings. But:

  • with every building linked, the run logged No LOD2 or LOD3 buildings with footprints found, although the buildings and their footprints exist;
  • nothing could re-link after PyLovo changed. The link script deletes and re-inserts its batch's rows, but the Go batching never handed it a linked building, so the only route was truncating building_link by hand.

How

  • GetGridBatches takes includeLinked. When it is set, the anti-join on building_link is dropped.
  • RunPyLovoRelink runs the link with includeLinked. RunPyLovoLinkBuild is unchanged for its callers: the CLI without -relink, and the on-request server.
  • When nothing was batched, the run counts linkable buildings. If there are some, it logs All N buildings with footprints already have a building_link row. Nothing to link; run -link-pylovo -relink to re-link them.
  • -relink without -link-pylovo exits with an error.
  • The script header, docs/code/pylovo-link/index.md and the README flag table say which run re-links.

Tests

  • TestRunPyLovoLinkBuild_ReportsAlreadyLinked: the second run's warning names already-linked buildings. Fails on main with the footprint message; passes here.
  • TestRunPyLovoRelink_UpdatesExistingLinks: after the PyLovo row a building matched is replaced, a plain run keeps the old link, and RunPyLovoRelink switches it to the new one. It fails if RunPyLovoRelink keeps the anti-join (checked by wiring it to includeLinked=false).
  • TestGetGridBatches_ExcludesAlreadyLinkedBuildings also covers includeLinked: the linked building is back in the batches.
  • go vet, the unit suites and the integration suites pass.

Real data (Vienna, Josefstadt; a copy linked over postgres_fdw)

  • Plain -link-pylovo on the fully linked copy: logs All 1318 buildings … already have a building_link row; all 1,318 rows keep their created_at.
  • -link-pylovo -relink: all 1,318 rows rewritten, identical result: 1,219 matched, 1,198 distinct OSM ids, 15 OSM ids linked to more than one building, 0 changed.

-link-pylovo batches only buildings without a building_link row, so a
run after a small import touches just the new buildings. Two things
were wrong with that. When every building was already linked, the run
logged "No LOD2 or LOD3 buildings with footprints found", although the
buildings and footprints exist. And nothing could re-link after the
PyLovo data changed: the link script deletes and re-inserts the rows
of its batch, but the Go batching never gave it a linked building, so
the only route was truncating building_link by hand.

A run that finds every building linked now says so, with the count,
and points at the new -relink flag. `-link-pylovo -relink` batches
every building, linked or not (RunPyLovoRelink, GetGridBatches with
includeLinked), so the script's delete-and-re-insert recomputes the
links against the current PyLovo data. -relink on its own is
rejected. The script header and the link docs now say which run
re-links.

Closes #154
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.76744% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/process/feature_extraction.go 80.55% 4 Missing and 3 partials ⚠️
cmd/c2t/main.go 0.00% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jravani
jravani merged commit f6df4be into main Oct 1, 2026
7 of 8 checks passed
@jravani
jravani deleted the fix/link-pylovo-relink branch October 1, 2026 19:00
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.

-link-pylovo silently skips already-linked buildings and blames missing footprints

1 participant