下载数据
从地理空间数据云 可以下载DEM数据,但是要注意
- 将坐标系转为WGS84的
- 需要将格式转换为tif
DEM 瓦片生成
使用Cesium地形生成工具 ,部署和使用方法,里面很详细,这里不再详细介绍。
注意点:
- 在工具安装的过程中,如果你的电脑安装过ArcGIS的桌面程序,它会在C盘生成一个python的文件夹,我们就不必要安装Python了。
部署发布瓦片
将生成的瓦片的整个文件夹使用nginx或者IIS等进行发布,这里我使用的是nginx,这里需要设置允许跨域
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
if ($request_method = OPTIONS){
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE';
add_header 'Access-Control-Allow-Headers' 'reqid, nid, host, x-real-ip, x-forwarded-ip, event-type, event-id, accept, content-type';
}
}
在Cesium里加载使用
let terrainLayer = new Cesium.CesiumTerrainProvider({
url: "http://localhost/terrain_tiles", // 到文件夹
});
const viewer = new Cesium.Viewer('map3d', {
terrainProvider:terrainLayer,
// imageryProvider:image_provider_item,
baseLayerPicker:false,
homeButton:false,
infoBox:false,
timeline:false,
navigationHelpButton:false,
geocoder:false,
sceneModePicker:false,
animation:false,
fullscreenButton:false
});
测试效果
在Cesium 查看如下图