Repository navigation
feat: serve the Netherlands use type from BAG units - #217
Merged
Merged
Conversation
use_type and residential were Germany only: they map a source function code, and Dutch 3D data carries none. BAG records the use and floor area of every unit (verblijfsobject) of a building, which gives the building's use, including mixed use. Building attributes the 3D data lacks are staged under data/attributes/<country>/<dataset>/ as an attribution.json, validated and credited like a 3D dataset's, plus building_use.csv with one row per building and use code: object_id, use_code, floor_area. The import (-create-db, -import-data, on-request runs) replaces each dataset's rows in city2tabula.building_use, a table it creates if missing, so a database built earlier gains it on its next import. A malformed file stops the import with file and line. Where a building's function code gives no use, the buildings queries read its rows: the use type covering the most floor area wins, equal areas going to the first by name; residential is true when any row is a dwelling; the dataset joins the response's attributions. The Dutch code list maps the 11 BAG gebruiksdoelen, plus "geen verblijfsobject", which the extract gives a building without units (a shed, garage or barn), to ancillary. On Loenen and Heeten (10,947 buildings) the API serves a use type for 98.8%: ancillary 40.9%, residential 36.7%, hospitality 16.1%. The 131 without one have left BAG since the 3DBAG snapshot. The server needs data/attributes mounted next to data/lod2.
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.
Part of #210: the Netherlands, after Germany in #211.
use_typeandresidentialwere Germany only: they map a source function code, and Dutch 3D data carries none. BAG records the use (gebruiksdoel) and floor area (oppervlakte) of every unit (verblijfsobject) of a building, which gives the building's use, including mixed use.Change
Attribute datasets:
data/attributes/<country>/<dataset>/holds anattribution.json(validated and credited like a 3D dataset's) andbuilding_use.csv:object_iduse_codefloor_areaImport (
-create-db,-import-data, on-request runs): each dataset's rows incity2tabula.building_useare replaced viaCopyFromin one transaction. The table is created if missing, so a database built earlier gains it on its next import. A malformed file stops the import with file and line; every file is parsed before any row is written.dataset_idmust be unique across 3D and attribute datasets.Serving: where a building's function code gives no use, the buildings queries read its rows as one JSON column. The use type covering the most floor area wins, with equal areas going to the first by name.
residentialis true when any row is a dwelling. The dataset is added toattributions. A database without the table returnsnull, as before.Mapping
internal/onrequest/usetype/netherlands.csv:geen verblijfsobject, which the extract gives a building without units (a shed, garage or barn):ancillary;bijeenkomstfunctie,celfunctieandsportfunctie:public;logiesfunctie:hospitality.Deployment:
environment/http/docker-compose.ymlmountsdata/attributes, and.gitignoreexcludes it.Docs:
data/README.md, the attribution page, OpenAPI (use_type,attributions),CHANGELOG.md.The response shape is unchanged; Dutch buildings now carry values.
Tests
Unit:
TestUseTypeFromUnits: largest floor area, codes of one use type adding up, ties, unmapped codes, building without units.TestParseBuildingUse,TestDiscoverAttributeDatasets: header, joined codes, bad area, missing file or folder.Integration:
TestServe_UseTypeFromBuildingUnitson the real Dutch seed covers the import, the served use type,residential, credits and restaging. With the fallback removed it fails (use_type null, residential <nil>, want retail and true).go vet ./...andgo test ./...pass. The integration suites for importer, process, onrequest, db and api pass.End to end on the Loenen and Heeten BAG extract (20,039 rows) and 3DBAG tiles, through create-db, extract and the API:
The 131 without a use type have left BAG since the 3DBAG snapshot. 177 buildings hold dwellings under another main use. All 10,947 buildings come back in one bbox request in 0.75 s.