Cesium-terrain-builder编译入坑详解

本以为编译cesium-terrian-tools编译应该没那么难,不想问题重重,不想后人重蹈覆辙,也记录下点点滴滴。

编译geo-data版本

链接编译,无法link GDALCreateOverviewDataset,gdal版本不对,可以暂行注释掉,应该是个扩展功能可以不管

复制代码
      //poSrcOvrDS = GDALCreateOverviewDataset( poSrcDS, iOvr, FALSE);
          poSrcOvrDS = nullptr;// GDALCreateOverviewDataset(poSrcDS, iOvr, FALSE, FALSE);
        }

ahuarte47 版本

  • git clone 后,记得要切换到最新代码,默认没有切换到最新代码,【坑】

  • gdal 307 或gdal204 使用时,可能出现部分重载函数声明不一致,需要改ctb源码即可解决

  • 网上其他设置:

    • 中文支持: GDALAllRegister后添加CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
  • cesium 发布地形,默认需要关闭gzip,才可以被cesium加载

  • 发布命令:

    cmd 复制代码
    ctb-tile.exe  --output-dir  H:/ctb_output   H:/shenzhen_dem/L15/shenzhen_dem.tif  -f Mesh
    • 生成layer
    cmd 复制代码
    ctb-tile.exe --gzip --output-dir  H:/ctb_output   H:/shenzhen_dem/L15/shenzhen_dem.tif  -f Mesh -l

上图为证:

Cesium-1.106版本加载terrian

cesium测试代码:

html 复制代码
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        html,
        body,
        #cesiumContainer {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }
    </style>
    <!-- Include the CesiumJS JavaScript and CSS files -->
    <script src="../Build/CesiumUnminified/Cesium.js"></script>
    <style>
        @import url(../Build/CesiumUnminified/Widgets/widgets.css);

        html,
        body,
        #cesiumContainer {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }
    </style>
</head>
 
<body>
    <div id="cesiumContainer"></div>
    <script>
        Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0NzkzYjFkNi1mODZhLTRkNjAtYWE1YS1jYzE5NzBjNjhkNjciLCJpZCI6MTQyMjI1LCJpYXQiOjE2ODYyMzUxODl9.l8y5SN0ALIwPZh9eM8Al14DBpfMjHdeG7uqb69tH6nU';
        <!-- const viewer = new Cesium.Viewer('cesiumContainer'); -->
		
		const viewer = new Cesium.Viewer('cesiumContainer', {
        terrainProvider: new Cesium.EllipsoidTerrainProvider({}),//移除自带地形
        baseLayerPicker:false,
        homeButton:false,
        infoBox:false,
        timeline:false,
        navigationHelpButton:false,
        geocoder:false,
        sceneModePicker:false,
        animation:false,
        fullscreenButton:false
      });

		 //viewer.imageryLayers.removeAll();
        var terrainProvider = new Cesium.CesiumTerrainProvider({
  
			url: './ctb_shenzhen_nogzip/'

        });

        viewer.scene.terrainProvider = terrainProvider;
        viewer.camera.flyTo({
            //destination: Cesium.Cartesian3.fromDegrees(121.8040466308, 29.9597, 2500)
			// 深圳
            destination: Cesium.Cartesian3.fromDegrees(114.1040466308, 22.5, 2500)
        });  
    </script>
</body>
 
</html>
## 参考:

[基于Docker使用CTB生成地形切片并加载 - 当时明月在曾照彩云归 - 博客园 (cnblogs.com)](https://www.cnblogs.com/jiujiubashiyi/p/17104115.html)

非压缩:[Cesium地形切片--CTB(cesium-terrain-builder)填坑指南 - 知乎 (zhihu.com)](
相关推荐
李剑一5 天前
拿来就用!Vue3+Cesium 飞入效果封装,3D大屏多场景直接复用
前端·vue.js·cesium
曲折6 天前
Cesium-气象要素PNG色斑图叠加
前端·cesium
GIS开发特训营20 天前
Cesium Shader 实战:三维 GIS 可视化进阶教程
gis·cesium·gis开发·webgis
GDAL25 天前
viewer.camera.flyTo 全面教程
cesium·camera·flyto
GIS学姐嘉欣1 个月前
Cesium进阶教程(2)线性高度雾
javascript·cesium·gis开发·webgis
GISBox1 个月前
一站式体验GISBox 2.1.3:矢量样式扩展与3DTiles位置优化
gis·cesium·倾斜摄影·ifc·osgb·gisbox·切片转换
那年那棵树1 个月前
【WebGis】基于WebGis的系统设计与开发
gis·openlayers·cesium·地理信息系统
duansamve1 个月前
Cesium中设置背景图片(不是天空盒)
cesium
地狱为王1 个月前
Cesium for Unity叠加行政区划线
unity·gis·cesium
白嫖叫上我1 个月前
Cesium切换视角中心点不变
cesium