CZML文件是Ceisum支持显示动态变化的过程,并且官网提供了很好的例子。
对于点的路径变化,直接建好模版,下次替换数据便可以,但是对于面的话,虽然官网也提供了例子(CZML Polygon - Interpolating References),但是过于简单,只是一个三角形面变化的过程。

所以,当考虑实际情况的话,如想要从一个县区域变为省区域,那么如何实现?
面临这个问题,第一步自然是考虑CZML面文件的结构。
还是回到例子,例子中提供的CZML的内容是:
[{
"id" : "document",
"name" : "CZML Polygon - Interpolating References",
"version" : "1.0"
}, {
"id" : "dynamicPolygon",
"name": "Dynamic Polygon with Reference Properties",
"availability":"2012-08-04T16:00:00Z/2012-08-04T17:00:00Z",
"polygon": {
"positions": {
"references": [
"v1#position",
"v2#position",
"v3#position"
]
},
"perPositionHeight" : true,
"material": {
"solidColor": {
"color": [{
"interval" : "2012-08-04T16:00:00Z/2012-08-04T16:25:00Z",
"rgbaf" : [1, 0, 1, 1]
}, {
"interval" : "2012-08-04T16:30:00Z/2012-08-04T17:00:00Z",
"rgbaf" : [0, 1, 1, 1]
}]
}
}
}
}, {
"id": "v1",
"position": {
"interpolationAlgorithm": "LINEAR",
"interpolationDegree": 1,
"interval" : "2012-08-04T16:00:00Z/2012-08-04T17:00:00Z",
"epoch" : "2012-08-04T16:00:00Z",
"cartographicDegrees": [
0, -60, 35, 30000,
160, -65, 35, 5000000,
400, -70, 40, 20000,
800, -62, 45, 200000,
1800, -65, 40, 650000,
3600, -60, 35, 3000
]
}
}, {
"id": "v2",
"position": {
"interval" : "2012-08-04T16:00:00Z/2012-08-04T17:00:00Z",
"cartographicDegrees": [
-45.0, 20, 4000000
]
}
}, {
"id": "v3",
"position": {
"interpolationAlgorithm": "LINEAR",
"interpolationDegree": 1,
"interval" : "2012-08-04T16:00:00Z/2012-08-04T17:00:00Z",
"epoch" : "2012-08-04T16:00:00Z",
"cartographicDegrees": [
0, -45, 60, 4000,
400, -40, 70, 2000000,
1000, -35, 75, 100000,
3600, -45, 65, 3000
]
}
}];
这是一个JSON数组,所以找出其中的不同,找出其中决定面变化的内容,首先需要理解CZML文件的结构(CZML-Structure)数据中有packet组成,而决定面变化情况便是在几个packet之中。
仔细观察,后面“id”分别为v1,v2,v3的则是决定图形三个角坐标变化的情况,因此决定了整个图形变化的过程。
除此之外,在第二个packet之中,有一个属性与与其对应:
"polygon": {
"positions": {
"references": [
"v1#position",
"v2#position",
"v3#position"
]
},
因此,确定了一个动态面所需要的基本代码,对变化过程增删,最终完成一个五边形的图形

[{
"id" : "document",
"name" : "面动态变化",
"version" : "1.0"
}, {
"id" : "dynamicPolygon",
"name": "Dynamic Polygon with Reference Properties",
"availability":"2012-08-04T16:00:00Z/2012-08-04T17:00:00Z",
"polygon": {
"positions": {
"references": [
"v1#position",
"v2#position",
"v3#position",
"v4#position",
"v5#position"
]
},
"perPositionHeight" : true,
"material": {
"solidColor": {
"color": [{
"interval" : "2012-08-04T16:00:00Z/2012-08-04T16:25:00Z",
"rgbaf" : [1, 0, 1, 1]
}, {
"interval" : "2012-08-04T16:30:00Z/2012-08-04T17:00:00Z",
"rgbaf" : [0, 1, 1, 1]
}]
}
}
}
}, {
"id": "v1",
"position": {
"interpolationAlgorithm": "LINEAR",
"interpolationDegree": 1,
"interval" : "2012-08-04T16:00:00Z/2012-08-04T17:00:00Z",
"epoch" : "2012-08-04T16:00:00Z",
"cartographicDegrees": [
0, 98.26171, 38.16911, 0,
600,97.954101,40.21244,0
]
}
}, {
"id": "v2",
"position": {
"interpolationAlgorithm": "LINEAR",
"interpolationDegree": 1,
"interval" : "2012-08-04T16:00:00Z/2012-08-04T17:00:00Z",
"epoch" : "2012-08-04T16:00:00Z",
"cartographicDegrees": [
0, 95.66894, 35.53222, 0,
800,91.53808,37.40507,0
]
}
}, {
"id": "v3",
"position": {
"interpolationAlgorithm": "LINEAR",
"interpolationDegree": 1,
"interval" : "2012-08-04T16:00:00Z/2012-08-04T17:00:00Z",
"epoch" : "2012-08-04T16:00:00Z",
"cartographicDegrees": [
0, 97.51464, 31.50362, 0,
750,90.08789,32.54681,0
]
}
},{
"id": "v4",
"position": {
"interpolationAlgorithm": "LINEAR",
"interpolationDegree": 1,
"interval" : "2012-08-04T16:00:00Z/2012-08-04T17:00:00Z",
"epoch" : "2012-08-04T16:00:00Z",
"cartographicDegrees": [
0, 101.82128, 34.56085, 0,
900,93.95507,28.99853,0
]
}
},{
"id": "v5",
"position": {
"interpolationAlgorithm": "LINEAR",
"interpolationDegree": 1,
"interval" : "2012-08-04T16:00:00Z/2012-08-04T17:00:00Z",
"epoch" : "2012-08-04T16:00:00Z",
"cartographicDegrees": [
0, 101.42578, 37.64903, 0,
720,105.11718,32.138408,0
]
}
}]
第一步完成,确定了决定面变化的因素,当然如果想纯粹人工操作,构造一个比较精确的面是比较麻烦的,但已经明白其中重复变化的过程,所以接下来,进行的便是用程序代替人工工作了。
本文探讨了如何使用CZML文件动态展示一个面区域从小(县)到大(省)的变化过程。通过分析CZML结构,特别是packet中的坐标变化,了解到决定面变化的关键在于顶点坐标。通过理解CZML中的id和属性,作者揭示了构建动态面的基础代码,并指出虽然手动构造精确面较繁琐,但可以通过程序自动化这一过程。
(1)确定动态面结构&spm=1001.2101.3001.5002&articleId=80112363&d=1&t=3&u=923e5cbc61194c6f9e1c61d2f86f510d)
799

被折叠的 条评论
为什么被折叠?



