Skip to content

Commit 1198ee2

Browse files
committed
Add the 3d tiles example
1 parent c0d4533 commit 1198ee2

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

_data/menu.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ items:
2121
url: /examples/serve-vector-tiles/
2222
- page: Extrusion of vector tiles from OSM data
2323
url: /examples/extrusion/
24+
- page: Create 3d tiles and visualize them with Cesium
25+
url: /examples/3d-tiles/
2426
- page: Create an IP to location web service
2527
url: /examples/ip-to-location/
2628
- page: Create a geocoding web service

examples/3d-tiles/index.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
layout: default
3+
title: Create 3d tiles and visualize them with Cesium
4+
permalink: /examples/3d-tiles/
5+
---
6+
7+
# Create 3d tiles and visualize them with Cesium
8+
9+
In this tutorial, we demonstrate how to import OSM data into PostGIS and then serve them as 3d tiles to view them in Cesium.
10+
11+
## Dataset
12+
13+
OpenStreetMap (OSM) is a free and editable map of the world.
14+
It is maintained by a community of passionate volunteers in a way which is similar to Wikipedia.
15+
Every week, OpenStreetMap publishes a [full dump](https://planet.openstreetmap.org/) of its data in two flavours: a large XML file of about 90GB and a more compact binary file of about 50GB in the [Protocol Buffer Format](https://developers.google.com/protocol-buffers) (PBF).
16+
As processing such large files can take several hours, [Geofabrik](http://www.geofabrik.de/data/download.html) regularly publishes smaller extracts of OSM for specific regions.
17+
In this example we will use a tiny extract of OSM for [Liechtenstein](https://en.wikipedia.org/wiki/Liechtenstein), which is suitable for fast experiments.
18+
19+
## Importing OpenStreetMap Data
20+
21+
A workflow is a directed acyclic graph of steps executed by Baremaps.
22+
To download and import the sample OSM data in Postgres, execute the following [workflow](https://raw.githubusercontent.com/apache/incubator-baremaps/main/examples/openstreetmap/workflow.json).
23+
24+
```
25+
baremaps workflow execute --file examples/tdtiles/workflow.json
26+
```
27+
28+
Depending on the size of the OpenStreetMap file, the execution of this command may take some time.
29+
Eventually, the output produced by the command should look as follows.
30+
31+
```
32+
[INFO ] 2023-01-04 16:06:53.098 [main] Execute - Executing the workflow workflow.json
33+
[INFO ] 2023-01-04 16:06:53.235 [pool-2-thread-1] DownloadUrl - Downloading https://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf to liechtenstein-latest.osm.pbf
34+
[INFO ] 2023-01-04 16:06:53.820 [pool-2-thread-1] DownloadUrl - Finished downloading https://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf to liechtenstein-latest.osm.pbf
35+
[INFO ] 2023-01-04 16:06:53.821 [pool-2-thread-2] ImportOpenStreetMap - Importing liechtenstein-latest.osm.pbf into jdbc:postgresql://localhost:5432/baremaps?&user=baremaps&password=baremaps
36+
[INFO ] 2023-01-04 16:06:53.825 [pool-2-thread-2] HikariDataSource - HikariPool-1 - Starting...
37+
[INFO ] 2023-01-04 16:06:53.898 [pool-2-thread-2] HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@6e426130
38+
[INFO ] 2023-01-04 16:06:53.899 [pool-2-thread-2] HikariDataSource - HikariPool-1 - Start completed.
39+
[INFO ] 2023-01-04 16:06:55.743 [pool-2-thread-2] ImportOpenStreetMap - Finished importing liechtenstein-latest.osm.pbf into jdbc:postgresql://localhost:5432/baremaps?&user=baremaps&password=baremaps
40+
[INFO ] 2023-01-04 16:06:55.743 [pool-2-thread-3] ExecuteSql - Executing indexes.sql
41+
[INFO ] 2023-01-04 16:06:56.623 [pool-2-thread-3] ExecuteSql - Finished executing indexes.sql
42+
[INFO ] 2023-01-04 16:06:56.623 [main] Execute - Finished executing the workflow workflow.json
43+
```
44+
45+
## Serve 3d tiles to a Cesium web application
46+
47+
In order to generate 3d tiles Baremaps uses [JTS Delaunay Triangulation](https://locationtech.github.io/jts/javadoc/org/locationtech/jts/triangulate/DelaunayTriangulationBuilder.html) to
48+
triangulate vector tiles into 3d meshes. Then it uses [jgltf](https://github.com/javagl/JglTF) to generate a GLB that can be embedded into a 3d tile.
49+
50+
To start the 3d tiles server, use the following command:
51+
52+
```
53+
baremaps tdtiles serve --database jdbc:postgresql://localhost:5432/baremaps?user=baremaps&password=baremaps
54+
```
55+
56+
Well done, a local http server should have started.
57+
You can now visualize the 3d tiles in your browser ([http://localhost:9000/](http://localhost:9000/))!
58+
Notice that the changes in the configuration files are automatically reloaded by the browser.
59+
60+
61+
## Conclusion
62+
63+
In this tutorial, we learnt how to import OpenStreetMap data in PostGIS and then serve 3d tiles with Apache Baremaps.

examples/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ For the creation of custom vector tiles you can follow these guides:
2222
- The [Contour](/examples/import-contour-into-postgis/) example shows how to produce contour lines from a digital elevation model.
2323
- The [Extrusion](/examples/extrusion/) example shows how to import OSM data into postgis and use the MVT specification to extrude the vectors into 3d.
2424

25+
For the creation of 3d tiles you can follow this guide:
26+
27+
- The [3d Tiles](/examples/3d-tiles/) example shows how to create 3d tiles from OSM data and serve them to a Cesium web application.
28+
2529
For the creation of an IP to location service follow this guide:
2630

2731
- The [IP to location](/examples/ip-to-location/) example shows how to create and serve an IP to location service in a simple web application.

0 commit comments

Comments
 (0)