Cesium开发中,如果想要看到真实感,地形数据(DEM)不可或缺。
但是,地形数据只包含高程信息,只能看出高低起伏。所以,需要叠加其它的影像信息才能达到想要的效果。
cesium中有一个TerrainProvider函数可以加载地形图。。
var viewer = new Cesium.Viewer('cesiumContainer'); var terrainProvider = new Cesium.CesiumTerrainProvider({ url: 'http://localhost:8081/wzf_dem' }); viewer.terrainProvider = terrainProvider; viewer.camera.flyTo({ destination:Cesium.Cartesian3.fromDegrees(116, 40, 15000.0) });
参考:https://www.jianshu.com/p/44ed84b44e6c
Cesium地形系统
Cesium中的地形系统是一种由流式瓦片数据生成地形的技术。cesiumjs支持两种类型的地形,STK World Terrain和Small Terrain。
STK World Terrain是高分辨率,基于quantized mesh的地形。这是一种基于TIN三角网的地形,可充分利用GL中的Shader来渲染,效果相当逼真。STK World Terra使用了多种数据源,分别适应不同地区和不同精度时的情形。update:STK World Terrain has been depracated。
Small Terrain 是中等高分辨率,基于 heightmap 的地形,渲染出的地形效果不如 quantized mesh 的地形,但也基本能接受。网上已经有一些开源的生成工具可以由 DEM 数据生成这种规范的.terrain 文件,因此我们下面重点说明这种类型的地形生成。
![](https://img2020.cnblogs.com/blog/457232/202106/457232-20210623104818722-1552848051.png)
gdal2srtmtiles程序.py使用教程
1. 安装Python2.7。
2. reg
3. PIL安装
4. gdal core安装
5. numpy安装
6. gdal for python安装
7. T7-gdal2srtmtiles-demo.py
修改
修改 T7-gdal2srtmtiles-demo.py 的位置为你机器上的位置,修改 tif 的位置和输出文件的位置。-z 后面可以输入生成的级数如 0-8 或 0-15 等,级数越大越慢。
修改完成后保存。
gdal2srtmtiles-demo.py完整程序:
#!/usr/bin/env python #****************************************************************************** # $Id: gdal2tiles.py 19288 2010-04-02 18:36:17Z rouault $ # # Project: Google Summer of Code 2007, 2008 (http://code.google.com/soc/) # Support: BRGM (http://www.brgm.fr) # Purpose: Convert a raster into TMS (Tile Map Service) tiles in a directory. # - generate Google Earth metadata (KML SuperOverlay) # - generate simple HTML viewer based on Google Maps and OpenLayers # - support of global tiles (Spherical Mercator) for compatibility # with interactive web maps a la Google Maps # Author: Klokan Petr Pridal, klokan at klokan dot cz # Web: http://www.klokan.cz/projects/gdal2tiles/ # GUI: http://www.maptiler.org/ # ############################################################################### # Copyright (c) 2008, Klokan Petr Pridal # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
将上边的地形瓦片文件,发布到tomcat,IIS等服务器。发布完成后的访问地址为:http://localhost:8088/data/terrain_tiles
可以看到,有山的地方还是比较明显的。。其他地方就顶多是坑坑洼洼,没有太高的凸起
主要参考:https://www.jianshu.com/p/44ed84b44e6c