Repository navigation
fix: link every OSM way that covers a 3D building - #204
Merged
Merged
Conversation
The link step kept one OSM way per 3D building (DISTINCT ON object_id, UNIQUE (object_id, country_code)). Where OSM maps one building as several ways, the others got no building_link row although each cleared the 0.5 threshold, so a caller asking for them found no 3D data. On the Mainkofen campus DEBY_LOD2_7595822 has five such ways and only one was linked. 01_build_pylovo_link.sql now ranks every way at 0.5 or more per 3D building: res before oth, then the confidence to two decimals (exact copies differ only by reprojection noise), then the larger overlap, then osm_id. The best way keeps match_type 1, every further way gets the new match_type 4 with the same object_id. building_link is unique per (object_id, osm_id, country_code). A table from an earlier release is brought to that shape once per link run, under an advisory lock because parallel runs would race on the DDL. The link batches use NOT EXISTS instead of a join, since a building can now have several rows. GET /api/v1/buildings?osm_ids= returns each 3D building once however many of its ways are asked for, with osm_id as the best way and a new osm_ids listing every linked way, best first, then by confidence. It is [] in bbox mode. Re-linking the German demo data adds 63 further ways on 49 buildings and changes no building's best way. Closes #203
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Merged
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.
The link step kept one OSM way per 3D building (
DISTINCT ON (b.object_id),UNIQUE (object_id, country_code)). Where OSM maps one building as several ways, the others got nobuilding_linkrow although each cleared the 0.5 threshold, so a caller asking for them found no 3D data.Closes #203
Change
sql/scripts/link/pylovo/01_build_pylovo_link.sqllinks every way with confidence ≥ 0.5, fromresandoth. Ranking per 3D building:resbeforeoth, confidence to two decimals (exact copies differ only by reprojection noise), larger overlap,osm_id. Rank 1 keepsmatch_type1; every further way gets the newmatch_type4 with the sameobject_id.building_linkis unique per(object_id, osm_id, country_code)and allowsmatch_type4.internal/process/link_table.gobrings a table from an earlier release to that shape once per link run, under an advisory lock.GetGridBatchesexcludes linked buildings withNOT EXISTSinstead of a join, since a building can now have several rows.GET /api/v1/buildings?osm_ids=returns each 3D building once, however many of its ways are asked for.osm_idstays the best way; the newosm_idslists every linked way, best first, then by confidence. It is always present and[]in bbox mode.docs/code/pylovo-link/index.md, the OpenAPIBuildingschema andgetBuildingsdescription,CHANGELOG.md.Example,
DEBY_LOD2_7595822: asking for1265475272returns that building once, withosm_id223728275andosm_ids[223728275, 1265475272, 1414567368, 1414567366, 1414567367].Effect on existing data
Re-linking a copy of the German demo database (
-link-pylovo -relink) adds 63 further-way rows on 49 buildings. No building's best way changes. 1,173 distinct OSM ways have 3D data afterwards, against 1,120 before. Existing databases need-link-pylovo -relinkto fill in further ways for buildings that are already linked.Tests
TestRunPyLovoLinkBuild_LinksEveryWayAboveThreshold: one 3D building with four ways of known confidence. It requires one primary, two further ways ordered by confidence, nothing for the way below 0.5, and the building returned once with all three ways whichever of them is asked for. Onmainit fails with a single link row.TestRunPyLovoLinkBuild_UpdatesOldLinkTable: a table in the old shape is updated by the link step and then holds both ways of one building.readBuildingLinkin the existing link tests now reads a building's primary row, since a building can have more than one.go vet ./...,go test -race ./...and the integration tests for process, db, importer, api and onrequest pass locally, onrequest against citydb-tool 1.3.2.