pg2b3dm

Getting started

Convert 3D Building data (Multipolygon Z) to 3D Tiles

Prerequisites

Optional check PostGIS:

$ postgresql> select ST_AsText(ST_Transform(ST_GeomFromText('POINT(121302 487371 2.68)', 7415), 4979));
POINT Z (4.892367035931109 52.37317920269912 45.66258579945144)

In this query a transformation from epsg:7415 to espg:4979 is performed. When the projection grids are installed the vertikal value = 2.68 is converted to 45.66258579945144.

When the projection grids are not installed the vertikal value stays at 2.68. In this case the projection grids should be installed, using tool projsync –all (https://proj.org/en/9.3/apps/projsync.html)

Download data

Result: 8-688-40.gpkg (12 MB) - data has projection EPSG:7415 (EPSG:28992 horizontal reference + EPSG:5709 vertical reference (NAP))

Data processing

Note: in the Cesium client viewer the terrain should be added to see the buildings on the correct height.

$ ogr2ogr -f PostgreSQL pg:"host=localhost user=postgres" 8-688-40.gpkg lod22_3d -nln sibbe
postgresql> CREATE INDEX ON sibbe USING gist(st_centroid(st_envelope(geom)))
$ pg2b3dm -h localhost -U postgres -c geom -d postgres -t sibbe -a identificatie

Visualize

   const tileset = await Cesium.Cesium3DTileset.fromUrl(
      "tileset.json"
    );  
    viewer.scene.primitives.add(tileset);
var terrainProvider = await Cesium.CesiumTerrainProvider.fromUrl('https://api.pdok.nl/kadaster/3d-basisvoorziening/ogc/v1_0/collections/digitaalterreinmodel/quantized-mesh');
viewer.scene.terrainProvider = terrainProvider;
viewer.scene.globe.depthTestAgainstTerrain=true;