Integrating Cesium Map with VueJS: Generating and rendering 3D terrain in Cesium – Part 2

In the realm of geospatial visualization, CesiumJS stands out as a leading library, offering powerful tools for 3D mapping and terrain rendering. Its capabilities are further enhanced when combined with modern frontend frameworks like VueJS, which provides a reactive and component-based architecture. This synergy allows developers to create immersive and interactive 3D map applications with ease.

The Cesium Terrain Builder (CTB) is an essential tool in this process. It enables the generation of terrain tiles tailored for use in CesiumJS. For those who prefer a hassle-free setup, the Docker version of CTB, often referred to as cesium-terrain-builder-docker, comes to the rescue. This containerized version ensures that users can run CTB seamlessly, without getting entangled in dependencies and system configurations.

In this tutorial, we’ll delve deep into the integration process, guiding you step-by-step on how to use the Cesium Terrain Builder with Docker, and subsequently, how to render the generated 3D terrain in a VueJS application using Cesium.

To get full source code for this tutorial, click here.

To check the live demo for this tutorial, click here.

1. Install Docker:

If you haven’t already, install Docker on your system. You can download it from the official Docker website.
For installation in linux, you can follow this link: https://docs.docker.com/desktop/install/linux-install/
For installation in windows, you can follow this link: https://docs.docker.com/desktop/install/windows-install/

2. Pull the CTB Docker Image:

Fetch the latest version of the CTB Docker image

3. Prepare Your Heightmap Data:

Ensure you have DEM(Digital Elevation Model) data in a format supported by CTB, such as GeoTIFF. For this tutorial, you can find the DEM data inside dem_data directory in main project

4. Generate Terrain Tiles:

Run the CTB tool inside a Docker container to generate terrain tiles from your DEM data

The command sudo docker run -it --name ctb -v /home/geoknight/data/:/data tumgis/ctb-quantized-mesh runs a Docker container interactively (-it) from the tumgis/ctb-quantized-mesh image, naming the container ctb (--name ctb). It maps the local directory /home/geoknight/data/ on the host system to the /data directory inside the container (-v /home/geoknight/data/:/data), ensuring any changes in one reflect in the other. The sudo prefix ensures the command runs with superuser privileges.
command ctb-tile -f Mesh -C -N -o terrain dem.tif creates terrain files
comman ctb-tile -f Mesh -C -N -l -o terrain dem.tif creates layer description

After generation, Your terrain folder, should like this

5. Copy generated 3d terrain in vue-cesium project

Transfer the generated 3D terrain to the public directory within your Vue-Cesium project, as illustrated in the public/static directory structure. This ensures the server can readily access and render the 3D terrain tiles within the Vue-Cesium application.

6. Integrate with CesiumJS:

In your CesiumJS application, use the generated terrain tiles by setting the terrain provider to the URL where your tiles are being served.

By using the Docker version of Cesium Terrain Builder, you can ensure a consistent environment for generating terrain tiles, regardless of the host system. This makes the process of generating and serving terrain tiles for CesiumJS more streamlined and reproducible.

I hope this tutorial will create a good foundation for you. If you want tutorials on another GIS topic or you have any queries, please send an email at contact@spatial-dev.guru.

We also offer freelancing services. Please email us at contact@spatial-dev.guru for any query.

Leave a ReplyCancel reply