Cesium offline terrain loading

table of Contents

Preface

1. Tools

Second, the terrain data source

2.1 Elevation data acquisition

2.2 Consolidation of elevation data

2.3 Terrain data slice

Three, terrain service loading

3.1 Publish terrain data

3.2 Load terrain data to revisit our Guangdong chicken drumstick


​​​​​​​

Preface

In view of the fact that the offline map was loaded before, but if there is no terrain data, our cesium earth does not look perfect. In order to build offline terrain, I searched for a round of information and finally concluded how to build offline terrain. After all, there are still a lot of hits, and it is finally solved anyway. The result is good.

Computer environment: win10

The tools used are as follows:

GlobalMapper 14.1 is used for tif data merging

cesiumlab2 is used for data format conversion

nginx proxy server

PS: Here, by default, your computer will use nginx if you have nginx. Here nginx is only used as a static file server. You can also use tomcat. If it doesn't, you can use the httpserver command of npm to start the local server.

1. Tools

To do well, we must first sharpen our tools. First of all, we must have tools in hand.

The download link of GlobalMapper 14.1 is as follows:

Link: https://pan.baidu.com/s/1fXK0ICUpy1iXcP8T0ry1vg Extraction code: 91uj

After downloading, install it directly, just click the next step. After installation, there will be two shortcuts in the start menu. After opening with Chinese, it will be the Chinese interface.

 

 

For cesiumlab2, go directly to the official website to download, install it and use it

http://www.cesiumlab.com

I am not here to advertise for others, just because my GIS novice found that their data format conversion is still very friendly.

 

Second, the terrain data source

A clever woman can't afford to cook without rice, we have the tools, the next step is the data source, we have to have our own data source.

2.1 Elevation data acquisition

To download the elevation data dem, I downloaded it through the geospatial data cloud. Here you can download DEM 90M data for free by registering an account

Geospatial Data Cloud

[Official Website]->[Data Resources]->[SRTMDEM 90M Resolution Elevation Raw Data]

You can download the elevation data we want in [Data Resources]

 

However, it may not be clear where you want to download.

【Official Website】->【Advanced Search】->【SRTMDEM 90M Resolution Elevation Raw Data】

For the administrative area, you choose the download location you want

 

Here I take Guangdong Province as an example. Download the data of Guangdong Province. There are only four pieces of elevation data covering Guangdong, and we download them directly.

 

2.2 Merge elevation data

After downloading the file, drag it directly into globalmapper

 

 

Then we can see the corresponding terrain elevation data in globalmapper. The merged pictures are in the same order as the four pictures we saw in the web page preview.

 

Export the merged image, [File] -> [Output] -> [Output Raster/Image Format (R)] -> [GeoTIFF Format]

 

 

 

 

Waiting for export

 

2.3 Terrain data slice

After step 2.2, we output a tif file.

 

This tif file, we use cesiumlab2 to perform [terrain slicing]

 

Select the tif file that we have merged, select the data storage type [hash file], and select the output path. It is recommended that the path in pure English is used later. The output path here is G:\soft\SRTM3- 90m\jw\guangdong

 

 

After the conversion is completed, the files in the G:\soft\SRTM3-90m\jw\guangdong path are as follows

 

Three, terrain service loading

3.1 Publish terrain data

Modify our nginx.conf as follows:

    server {
        listen 666;

        location / {
            alias G:/soft/geoserver/map/guangdong/cesiumDemo/;
            index  index.html index.htm;
        }

        location /map {
            alias G:/soft/geoserver/map/guangdong/new10;
            autoindex on;
            autoindex_localtime on;
        }

        location /terrain {
            alias G:/soft/SRTM3-90m/jw/guangdong;
            autoindex on;
            autoindex_localtime on;
        }
    }

 

3.2 Load terrain data to revisit our Guangdong chicken drumstick

        var viewer = new Cesium.Viewer('cesiumContainer', {
            animation: false,//是否显示动画控件
            baseLayerPicker: true,//是否显示图层选择控件
            geocoder: true,
            timeline: false,
            sceneModePicker: true,
            navigationHelpButton: false,
            infoBox: true,
            imageryProvider: new Cesium.UrlTemplateImageryProvider({
                url: '/map/{z}/{x}/{y}.png',
                fileExtension: 'png'
            })
        });       

        // 加载离线地形
        var terrainLayer = new Cesium.CesiumTerrainProvider({
            url: '/terrain',
            requestVertexNormals: true, // 请求照明
            requestWaterMask: true // 请求水波纹效果
        });
        viewer.terrainProvider = terrainLayer;
        viewer.terrainExaggeration = 1;

If you look closer, you can see our big chicken (guang) leg (dong) chicken (di) skin (xing) bump (shu) 瘩 (ju)

 

 

 

 

 

Guess you like

Origin blog.csdn.net/zhh763984017/article/details/114776917