Repository navigation
feat: serve roof and wall surfaces for a bbox, paged - #219
Merged
Merged
Conversation
Rendering the LoD2 roofs and walls of an area meant calling GET /api/v1/geometry?include=surfaces once per building, as that endpoint allows one object_id per request. A building carries a handful to over 500 faces, so a building count does not bound the response size, and clients with a response cap (10 MiB, for example) can be overrun. GET /api/v1/surfaces takes a country and a WGS84 bbox and returns every building whose footprint intersects it: its object_id, its OSM ways best first, and each roof and wall surface with the same id as /geometry's, its type and a GeoJSON Polygon in EPSG:4326 with height to 7 decimals. Ground surfaces are left out; party-wall pieces are in, so attached buildings render closed. Pages hold whole buildings in object_id order up to 75,000 surface vertices, about 4 MB at the measured 52 bytes per vertex, and at least one building. One query picks the page by a running sum of vertices, so geometry is encoded only for the page's buildings. next_cursor, an encoded object_id, is null on the last page. On Deggendorf and Koeln (27,420 buildings) the whole area came in 28 pages of at most 4.06 MB, 0.06 to 0.90 s each, every building once.
GET /api/v1/surfaces returns absolute WGS84 coordinates with no origin subtracted. A float32 latitude near 49 degrees resolves to about 0.4 m, so a renderer working in 32-bit floats subtracts its own origin first; the OpenAPI geometry description now says so. The endpoint description also states that its surfaces are those of /geometry?include=surfaces without ground surfaces.
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.
Rendering the LoD2 roofs and walls of an area meant calling
GET /api/v1/geometry?include=surfacesonce per building: that endpoint allows oneobject_idper request, because a building carries a handful to over 500 faces and a building count does not bound the response size.Change
GET /api/v1/surfaces?country=..&xmin=..&ymin=..&xmax=..&ymax=..[&cursor=..]{ "buildings": [ {"object_id": "DEBY_LOD2_7672144", "osm_ids": ["223728275"], "surfaces": [ {"id": "014336c5-…", "type": "RoofSurface", "geometry": {"type": "Polygon", "coordinates": [[[12.9512345, 48.8312345, 321.42], …]]}}]}], "attributions": [ … ], "next_cursor": "REVCWV9MT0QyXzc2NzM3MDM" }[]when unlinked).idas/geometry, its type, and a GeoJSON Polygon in EPSG:4326 with height, 7 decimals. Ground surfaces are left out; party-wall pieces are included, so attached buildings render closed.object_idorder, up to 75,000 surface vertices per page, which is about 4 MB at the measured 52 bytes per vertex. Every page holds at least one building. One query picks the page by a running sum of vertices, so geometry is encoded only for the page's buildings.next_cursor(an encodedobject_id) is null on the last page./geometryis unchanged.SurfacesResponse,BuildingSurfaces,RenderSurface),CHANGELOG.md.Tests
Unit: cursor round trip and rejection; the handler's 400s, decided before any database lookup.
Integration,
TestSurfacesInBBox_PagesCoverEveryBuildingOnceon the real Bavarian seed with a 300-vertex budget:/geometry's.With the cursor made inclusive it fails:
still paging after 261 pages for 259 buildings.go vet ./...andgo test ./...pass.End to end on Deggendorf and Koeln (27,420 buildings):
next_cursorfor the rest.