cesium支持多种地形瓦片数据(GoogleEarthEnterpriseTerrainData、QuantizedMeshTerrainData、HeightmapTerrainData)

一、quantized-mesh-1.0(量化网格-1.0格式)

quantized-mesh-1.0是简单多分辨率四叉树金字塔的高度图。

1.1、切片规则

quantized-mesh的切片规则和Tile Map Service (TMS) 的global-geodetic规则相似。

  1. 所有图块都具有后缀名.terrain
  2. 图块大小为65x65像素。每个图块都是经过特殊编码的三角形网格,顶点在图块边缘处与相邻顶点重叠。
  3. 图块获取URL示例如下:

金字塔的两个ROOT文件:

  • (-180度,-90度)-(0度,90度)-http://example.com/tiles/0/0/0.terrain
  • (0度,-90度)-(180度,90度)-http://example.com/tiles/0/1/0.terrain

在ROOT URL可以找到下一级的八个图块:

  • (-180度,-90度)-(-90度,0度)-http://example.com/tiles/1/0/0.terrain
  • ( -90度,-90度)-(0度,0度)-http://example.com/tiles/1/1/0.terrain
  • (0度,-90度)-(90度,0度)-http://example.com/tiles/1/2/0.terrain
  • (90度,-90度)-(180度,0度)-http://example.com/tiles/1/3/0.terrain
  • (-180度,0度)-(-90度,90度)-http://example.com/tiles/1/0/1.terrain
  • (-90度,0度)-(0度,90度)-http://example.com/tiles/1/1/1.terrain
  • (0度,0度)-(90度,90度)-http://example.com/tiles/1/2/1.terrain
  • (90度,0度)-(180度,90度)-http://example.com/tiles/1/3/1.terrain

请求图块时,请确保在请求中包含以下HTTP标头:

Accept: application/vnd.quantized-mesh,application/octet-stream;q=0.9

1.2、根据指定坐标计算瓦片索引

# 根据WGS-84的经纬度获取量化网格的瓦片坐标
def wgs84_to_tile(lon, lat, zoom):isnum = lambda x: isinstance(x, int) or isinstance(x, float)if not (isnum(lon) and isnum(lat)):raise TypeError("lon and lat must be int or float!")if not isinstance(zoom, int) or zoom < 0 or zoom > 22:raise TypeError("zoom must be int and between 0 to 22.")lon = 180 + lonlon = lon / 360  # make lon to (0,1)lat = 90 + latlat = lat / 180  # make lat to (0,1)num = 2 ** zoomx = floor(lon * num * 2)y = floor(lat * num)return x, y

二、quantized-mesh-1.0文件格式

2.1、数据头部

该文件的第一部分是具有以下格式的数据头。double是64位浮点数,float是32位浮点数。

struct QuantizedMeshHeader
{// 瓦片中心在地心坐标系下的坐标double CenterX;double CenterY;double CenterZ;// 该瓦片覆盖区域的最小和最大高度值// 最小值可以低于所有顶点,最大值也可以高于任何顶点// 因为在网格简化(simplificatipn)的过程中可能会有移除最小或最大顶点的情况// 但是这些是适用于用于分析或可视化的的值float MinimumHeight;float MaximumHeight;// 瓦片的球面边界. // X,Y,Z 坐标是地心坐标系下的坐标, 半径的单位为米double BoundingSphereCenterX;double BoundingSphereCenterY;double BoundingSphereCenterZ;double BoundingSphereRadius;// 地平线遮挡点,以椭球体缩放的地心坐标系表示// 如果此点低于地平线,则整个图块位于地平线下方。// 有关更多信息,请参见http://cesiumjs.org/2013/04/25/Horizon-culling/。double HorizonOcclusionPointX;double HorizonOcclusionPointY;double HorizonOcclusionPointZ;
};
struct  QuantizedMeshHeade

2.2、顶点数据(vertex data)

头部数据后面紧跟着顶点数据,unsigned int是32位无符号整数,unsigned short是16位无符号整数。

struct VertexData
{unsigned int vertexCount;           // 顶点个数unsigned short u[vertexCount];      // 顶点横坐标unsigned short v[vertexCount];      // 顶点纵坐标unsigned short height[vertexCount]; // 顶点高程值
};

vertexCount字段指示后面三个数组的大小。 这三个数组包含来自前一个值的增量,然后进行zig-zag编码,以便使小整数(无论其符号如何)使用较少比特位。

解码值的过程很简单:

var u = 0;
var v = 0;
var height = 0;// zig-zag 编码
function zigZagEncode (value) {return (value >> 31) ^ (value << 1);
}
// zig-zag 解码
function zigZagDecode(value) {return (value >> 1) ^ (-(value & 1));
}for (i = 0; i < vertexCount; ++i) {u += zigZagDecode(uBuffer[i]);v += zigZagDecode(vBuffer[i]);height += zigZagDecode(heightBuffer[i]);uBuffer[i] = u;vBuffer[i] = v;heightBuffer[i] = height;
}

2.3、三角形索引

紧跟在顶点数据之后的是索引数据。用来指示顶点如何链接在一起成三角形。如果tile具有超过65536个顶点,则tile使用IndexData32结构对索引进行编码。否则,它使用IndexData16结构。

为了对索引数据强制进行字节对齐,在IndexData之前添加填充字节,以确保IndexData16为2字节对齐和IndexData32为4字节对齐。

struct IndexData16
{unsigned int triangleCount;                // 三角形个数unsigned short indices[triangleCount * 3]; // 三角形顶点索引
}struct IndexData32
{unsigned int triangleCount;unsigned int indices[triangleCount * 3];
}

索引使用来自 webgl-loader 的 高水位标记(high water mark)编码进行编码。

索引解码如下:

var highest = 0;
for (var i = 0; i < indices.length; ++i) {var code = indices[i];indices[i] = highest - code;if (code === 0) {++highest;}
}

索引的每个三元组以逆时针顺序,渲染一个三角形。

2.4、边缘索引

三角索引之后还有四个边缘索引列表,保存了tile边缘上的顶点。
知道哪些顶点在边缘上以添加裙边以隐藏相邻细节层之间的裂缝是有帮助的。

struct EdgeIndices16
{unsigned int westVertexCount;unsigned short westIndices[westVertexCount];unsigned int southVertexCount;unsigned short southIndices[southVertexCount];unsigned int eastVertexCount;unsigned short eastIndices[eastVertexCount];unsigned int northVertexCount;unsigned short northIndices[northVertexCount];
}struct EdgeIndices32
{unsigned int westVertexCount;unsigned int westIndices[westVertexCount];unsigned int southVertexCount;unsigned int southIndices[southVertexCount];unsigned int eastVertexCount;unsigned int eastIndices[eastVertexCount];unsigned int northVertexCount;unsigned int northIndices[northVertexCount];
}

更多信息,请参考文档。

2.5、Cesium的解析代码

var data = new Cesium.QuantizedMeshTerrainData({minimumHeight : -100,maximumHeight : 2101,quantizedVertices : new Uint16Array([// order is SW NW SE NE// longitude0, 0, 32767, 32767,// latitude0, 32767, 0, 32767,// heights16384, 0, 32767, 16384]),indices : new Uint16Array([0, 3, 1,0, 2, 3]),boundingSphere : new Cesium.BoundingSphere(new Cesium.Cartesian3(1.0, 2.0, 3.0), 10000),orientedBoundingBox : new Cesium.OrientedBoundingBox(new Cesium.Cartesian3(1.0, 2.0, 3.0), Cesium.Matrix3.fromRotationX(Cesium.Math.PI, new Cesium.Matrix3())),horizonOcclusionPoint : new Cesium.Cartesian3(3.0, 2.0, 1.0),westIndices : [0, 1],southIndices : [0, 1],eastIndices : [2, 3],northIndices : [1, 3],westSkirtHeight : 1.0,southSkirtHeight : 1.0,eastSkirtHeight : 1.0,northSkirtHeight : 1.0
});

Cesium - 地形瓦片(Quantized-mesh)相关推荐

  1. osgEarth的Rex引擎原理分析(二十五)地形瓦片大小尺寸和LOD的关系

    目标:(十八)中的问题55 osgEarth::TerrainOption中_tileSize默认大小为17,LOD的默认范围为0-23,这两个值的关系是什么? 还有瓦片的像素尺寸_tilePixel ...

  2. 使用太乐地图下载器下载cesium适用瓦片

    使用太乐地图下载器下载cesium适用瓦片

  3. cesium 切换瓦片地图的加载方式

    cesium 切换瓦片地图的加载方式 如果你熟悉 cesium,那么你或多或少应该用过或者了解如何用 cesium 加载瓦片地图. 熟悉加载瓦片地图这本身不是一个太难的工作,一般来说,只要你照着官方的 ...

  4. 14 Cesium—地形服务

    文章中所有操作均是在 Cesium 1.91 版本下进行的,其它版本差异请自行适配 地形服务 一些应用场景中我们需要操作地形数据,为此 Cesium 还提供方便的地形服务 TerrainProvide ...

  5. cesium 3dtiles 加载本地数据_记一次Cesium地形数据生成过程

    问题描述 有一小块带高程值的点状数据,需要根据该数据生成Cesium支持的3dtiles数据,在Cesium中显示.经过一周多时间的摸索,终于能够在Cesium中加载成功.现将数据处理流程做个记录,以 ...

  6. [cesium] | 地形挖方分析

    效果 github上看到一个挖方的插件,准备改造完善填挖方功能,引入即可使用. 本地示例代码 /*** 创建方量分析* @param {*} options */createCutVolumeAnal ...

  7. cesium地形裁剪与模型裁剪的使用

    ​ 首先需要建立裁剪面,裁剪面可以是面也可以是面构成的体.可以根据你要裁剪的形状,自己组合ClippingPlaneCollection. 其次将裁剪面作用到地形或者模型或者地球上,可以达到裁切模型, ...

  8. cesium 显示线框模式

    cesium 地形瓦片 使用线框模式显示 在cesium源码GlobeSurfaceTileProvider.js 文件内,找到wireframe,然后将他设置成true. 结果如下图所示: 想要单独 ...

  9. Cesium之地形(1)

    更新于2017/5/31 Cesium地形简介 Cesium支持多种地形格式和服务,Cesium的母公司AGI提供了两份免费使用的地形数据,一个叫"STK World Terrain&quo ...

  10. cesium获取模型高度_Cesium中地形数据的加载

    Cesium开发中,如果想要看到真实感,地形数据(DEM)不可或缺.但是很多非GIS专业的人,对地形数据的定位不清晰,不明白地形数据如何展示. 最近很多人问我这个问题,综合看下来,主要问题就集中在地形 ...

最新文章

  1. HA: InfinityStones靶机渗透测试
  2. 不连续子网掩码的魅力
  3. Yii框架控制台报错: The id configuration for the Application is required
  4. python 图片旋转角度_OpenCV获取图像的旋转角度
  5. 华为交换机-端口由trunk改为access
  6. TCP握手/挥手的过程分析
  7. [蓝桥杯2016决赛]一步之遥-枚举
  8. 某Q娱乐网emlog程序整站源码
  9. Hadoop源码分析16: IPC流程(11) 整体流程
  10. livedata mvvm_Android MVVM LiveData数据绑定
  11. unity改变物体轴心
  12. !/usr/bin/env python和!/usr/bin/python的区别
  13. DPDK- flow Metering
  14. Codejock Xtreme ToolkitPro MFC 使用
  15. 【Axure】实例:微信登录
  16. mysql分区表 缓存_Mysql 分区表-分区操作
  17. 腾讯云购买服务器操作步骤
  18. 一个设想:什么是真正的云,及利用树莓派和cloudwall打造你的真正云中心
  19. MacOS下iterm,Dracula主题配置
  20. 在debian系统下安装R以及Rstudio的经历

热门文章

  1. struts2的package和result的标签的属性
  2. Html5 dataset--自定义属性
  3. 如何定时备份远程mysql数据库
  4. 从PCI上读取数据 线程和定时器效率
  5. 我的权限系统设计实现MVC4 + WebAPI + EasyUI + Knockout(二)菜单导航
  6. [python]python 动态调用模块类方法
  7. 3.企业安全建设入门(基于开源软件打造企业网络安全) --- 业务网安全加固
  8. 11.PHP核心技术与最佳实践 --- 高性能网站架构方案
  9. 58. 网络驱动器设备: iSCSI 服务器
  10. 17. meta http-equiv 属性