Skip to content

feat: WGS84 geometry and lookup by object_id - #208

Merged
jravani merged 2 commits into
mainfrom
feat/geometry-wgs84
Oct 20, 2026
Merged

jravani merged 2 commits into
mainfrom
feat/geometry-wgs84

Conversation

@jravani

@jravani jravani commented Oct 20, 2026

Copy link
Copy Markdown
Member

Two additions to the read endpoints, for a caller that works on the 3D buildings themselves rather than their OSM counterparts.

Change

  • GET /api/v1/geometry?srid=4326 reprojects the footprint and any surfaces to WGS84 in the query (ST_Transform before ST_AsGeoJSON). The GeoJSON then has longitude and latitude and no crs member, as RFC 7946 expects. The footprint stays 2D and surfaces keep their height. Without the parameter the output is unchanged (storage CRS, named in crs). Any other srid value is a 400 naming the value, returned before any database lookup.

  • GET /api/v1/buildings?object_ids= is a third mode next to osm_ids and the bbox. It returns the named 3D buildings, linked to PyLovo or not, each once, with the fields of the other modes (surfaces, function_code, number_of_storeys):

    Building osm_id osm_ids match_type
    linked best way every way, best first 1
    no OSM match empty [] 2
    no link row yet empty [] 0

    Unknown ids return nothing. When several modes are given, osm_ids wins, then object_ids, then the bbox.

  • Docs: docs/api.md, the OpenAPI getBuildings and getGeometry operations, and CHANGELOG.md.

The two features are separate commits.

Tests

  • TestServe_GeometryInWGS84: with WGS84, the footprint is 2D longitude/latitude in Bavaria with no crs member, and every surface position has a height. The default stays in EPSG:25832 with a crs member.
  • TestGeometry_RejectsUnsupportedSRID: srid values 3857, 25832 and wgs84 give a 400 naming the value. On main the request goes on to the database lookup.
  • TestServe_BuildingsByObjectIDs: a building linked to two ways, one without an OSM match, one with no link row and an unknown id give the rows in the table above. Each known building carries its surfaces and function code.

go vet ./..., go test -race ./... and the integration tests for process, db, importer, api and onrequest pass locally. A local server against the German and Dutch demo databases returned WGS84 footprints and surfaces for both countries, and the object_ids rows above for a linked and an unmatched building.

GET /api/v1/geometry returned footprints and surfaces only in the
dataset's storage CRS (EPSG:25832 in Germany, EPSG:28992 in the
Netherlands). A caller passing them to an EPSG:4326 API without
PostGIS of its own had no way to reproject them.

srid=4326 now reprojects the footprint and any surfaces in the query
with ST_Transform before ST_AsGeoJSON, so the GeoJSON has WGS84
longitude and latitude and no crs member, as RFC 7946 expects. The
footprint stays 2D and surfaces keep their height. Without the
parameter nothing changes; any other srid value is a 400 naming the
value, before any database lookup.
GET /api/v1/buildings found buildings only by PyLovo OSM id or by
bbox. A caller that keys buildings by their 3D object id, including
buildings with no OSM way, had to fetch a bbox and filter it.

object_ids is a third mode, after osm_ids and before the bbox in
precedence. It returns the named buildings, linked or not, each once
and with the fields of the other modes: a linked building carries its
best way, osm_ids and match_type 1, one without an OSM match empty
ways and match_type 2, and one with no building_link row yet empty
ways and match_type 0. Unknown ids return nothing.
@jravani jravani added this to the v0.11.4 milestone Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.33333% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/onrequest/query.go 77.08% 5 Missing and 6 partials ⚠️
internal/api/handler/handler.go 58.33% 4 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@jravani
jravani merged commit 57523f8 into main Oct 20, 2026
7 of 8 checks passed
@jravani
jravani deleted the feat/geometry-wgs84 branch October 20, 2026 11:20
@jravani jravani mentioned this pull request Oct 20, 2026
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.

1 participant