pg2b3dm takes as input triangulated PolyhedralSurfaceZ geometries in PostGIS. In this document a sample workflow is described for processing CityGML files using FME, GDAL and PostGIS.
Sample input files: https://www.opengeodata.nrw.de/produkte/geobasis/3dg/lod2_gml/
For example, download https://www.opengeodata.nrw.de/produkte/geobasis/3dg/lod2_gml/lod2_gml/LoD2_280_5657_1_NW.gml
In FME the CityGML file is imported and the buildings are exported as triangulated shapefiles using the following steps:
A sample workbench is included, see dataprocessing/dataprocessing_citygml.fmw
The model can run from command line:
$ "D:\Program Files\FME\fme.exe" citygml2esrishape.fmw --DestDataset_ESRISHAPE "multipatch.shp" --SourceDataset_CITYGML_3 "LoD2_280_5657_1_NW.gml" --FEATURE_TYPES ""
Reading.......200....400.....600....800.....1000....1200...
Emptying factory pipeline...
Translation was SUCCESSFUL
Output is multipatch.shp
-dim 3
makes sure to use the x, y and z information
-nlt POLYHEDRALSURFACEZ
sets the correct geometry
$ ogr2ogr -f "PostgreSQL" "PG:host=server user=username dbname=database" multipatch.shp -nln schema.tablename -dim 3 -nlt POLYHEDRALSURFACEZ
psql> DELETE FROM schema.tablename WHERE (ST_Npoints(wkb_geometry)::float/ST_NumGeometries(wkb_geometry)::float) != 4;
psql> ALTER TABLE schema.tablename ADD COLUMN id text;
psql> ALTER TABLE schema.tablename ADD COLUMN color text;
psql> UPDATE schema.tablename SET id = ogc_fid;
psql> UPDATE schema.tablename SET color = '#f5f5f5';
Now it’s possible to run pg2b3dm!
Result looks like:
Live demo: https://geodan.github.io/pg2b3dm/sample_data/duisburg/mapbox/#15.62/51.430166/6.782675/0/45