Skip to content

Commit c5253f9

Browse files
committed
Add chapter on generating 3D tiles
1 parent 09f69ea commit c5253f9

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

src/topics/View3D.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ To enable the 3D view, you need to configure the plugin in `config.json`. A typi
4646
```
4747
*NOTE*:
4848

49-
* The `menuItems` and `toolbarItems` can contain both 3D tools as well as generic tools (which are not specifically 2D map tools). If you run the 3D View in split-screen 3D+2D mode, only 3D tools will be displayed in the 3D window toolbar and menu. If you run the 3D View in fullscreen, all configured entries will be displayed.
49+
* The `menuItems` and `toolbarItems` can contain both 3D tools as well as generic tools (which are not specifically 2D map tools). If you run the 3D View in split-screen 3D+2D mode, only 3D tools will be displayed in the 3D window toolbar and menu. If you run the 3D View in fullscreen, all configured entries will be displayed.
5050
* Consult the [View3D plugin reference](../references/qwc2_plugins.md#view3d) as well as well as the [3D tool plugins reference](../references/qwc2_plugins.md#3d-plugins) for additional configuation options.
5151

5252
Next, to add a 3D View to a theme, add a `map3d` configuration to the desired theme item in [`themesConfig.json`](../configuration/ThemesConfiguration.md#manual-theme-configuration):
@@ -222,3 +222,61 @@ a possible `tileinfo` configuration in `tenantConfig.json` may look as follows:
222222
### Import
223223
224224
To import scene objects in formats other than GLTF, a `ogcProcessesUrl` in `config.json` needs to point to a BBOX OGC processes server.
225+
226+
227+
### Generating 3D tiles
228+
229+
QWC is specialized on 3D tiles in local coordinate reference systems. The following workflow shows all steps to a import CityGML model
230+
in EPSG:25832 into a 3DCity PostgreSQL database and generating 3D tiles with attributes.
231+
232+
Create docker network:
233+
```
234+
docker network create citydb-net
235+
```
236+
237+
Set PostgreSQL password:
238+
```
239+
export CITYDB_PASSWORD="citydb"
240+
```
241+
242+
Start PostgreSQL database container:
243+
```
244+
docker run -t -d --rm --name citydb --network=citydb-net \
245+
-e POSTGRES_USER=citydb -e POSTGRES_DB=citydb -e POSTGRES_PASSWORD=$CITYDB_PASSWORD \
246+
-e SRID=25832 -e SRS_NAME="urn:ogc:def:crs,crs:EPSG::25832,crs:EPSG::5783" \
247+
-p 127.0.0.1:5439:5432 -v $PWD/db:/var/lib/postgresql/data \
248+
3dcitydb/3dcitydb-pg:15-3.4-5
249+
```
250+
251+
Import CityGML file (`./data/LoD2_Flughafen.gml`) into 3DCityDB:
252+
```
253+
docker run -t --rm --user=$UID --network=citydb-net -v $PWD/data:/data:ro \
254+
3dcitydb/citydb-tool:1.0 import citygml LoD2_Flughafen.gml -H citydb -d citydb -u citydb -p $CITYDB_PASSWORD
255+
```
256+
257+
Create a view with a filter on PolyhedralSurface geometries and joined attributes:
258+
```
259+
docker exec -it citydb psql -U citydb -d citydb -c "CREATE VIEW geometry_data_ext AS
260+
SELECT g.*, coalesce(p1.feature_id, g.feature_id) AS parent_feature_id, p2.val_uri AS gml_id, split_part(p3.val_string, '_', 2)::integer AS function, p4.val_string::integer AS roof_type
261+
FROM geometry_data g
262+
LEFT JOIN property p1 ON (p1.name = 'buildingPart' and p1.val_feature_id = g.feature_id)
263+
LEFT JOIN property p2 ON (p2.name = 'externalReference' and p2.feature_id IN (p1.feature_id, g.feature_id))
264+
LEFT JOIN property p3 ON (p3.name = 'function' and p3.feature_id IN (p1.feature_id, g.feature_id))
265+
LEFT JOIN property p4 ON (p4.name = 'roofType' and p4.feature_id = g.feature_id)
266+
WHERE ST_GeometryType(geometry) = 'ST_PolyhedralSurface'
267+
"
268+
```
269+
270+
Create a spatial index:
271+
```
272+
docker exec -it citydb psql -U citydb -d citydb -c "CREATE INDEX ON geometry_data USING gist(st_centroid(st_envelope(geometry)))"
273+
```
274+
275+
Generate 3D tiles with pg2b3dm:
276+
```
277+
docker run -t --rm --user $(id -u):$(id -g) -v $PWD/dataout:/app/output --network=citydb-net -e PGPASSWORD=$DB_PASSWORD geodan/pg2b3dm:2.20.2 -h citydb -U citydb -d citydb -t geometry_data_ext -c geometry --keep_projection true --attributecolumns feature_id,gml_id,function,roof_type
278+
```
279+
280+
For an overview of 3D tile generation see this [talk from FOSS4G Europe 2025](https://blog.sourcepole.ch/assets/2025/creating-3d-tiles.pdf).
281+
282+
More tools and information can be found in the [Awesome 3D Tiles](https://github.com/pka/awesome-3d-tiles) collection.

0 commit comments

Comments
 (0)