如何将轨迹方向添加到 CZML 文件
How to add trajectory orientation to CZML file
我有一个 czml 文件,代表一架飞行指定路径的飞机。该文件是基于Cesiusm提供的Sancastle示例构建的(CZML模型+CZML路径)。
这是 CZML 变量:
var czml = [{
"id" : "document",
"name" : "CZML Path",
"version" : "1.0",
"clock": {
"interval": "2012-08-04T10:00:00Z/2012-08-04T15:00:00Z",
"currentTime": "2012-08-04T10:00:00Z",
"multiplier": 10
}
}, {
"id" : "path",
"name" : "path with GPS flight data",
"description" : "<p>Hang gliding flight log data from Daniel H. Friedman.<br>Icon created by Larisa Skosyrska from the Noun Project</p>",
"availability" : "2012-08-04T10:00:00Z/2012-08-04T15:00:00Z",
"path" : {
"material" : {
"polylineOutline" : {
"color" : {
"rgba" : [255, 0, 255, 255]
},
"outlineColor" : {
"rgba" : [0, 255, 255, 255]
},
"outlineWidth" : 5
}
},
"width" : 8,
"leadTime" : 10,
"trailTime" : 1000,
"resolution" : 5
},
"model": {
"gltf" : "../../SampleData/models/CesiumAir/Cesium_Air.glb",
"scale" : 2.0,
"minimumPixelSize": 128
},
"position" : {
"epoch" : "2012-08-04T10:00:00Z",
"cartographicDegrees" : [
0,-122.93797,39.50935,1776,
10,-122.93822,39.50918,1773,
20,-122.9385,39.50883,1772,
30,-122.93855,39.50842,1770,
40,-122.93868,39.50792,1770,
50,-122.93877,39.50743,1767,
60,-122.93862,39.50697,1771,
70,-122.93828,39.50648,1765,
80,-122.93818,39.50608,1770,
90,-122.93783,39.5057,1754,
100,-122.93777,39.50513,1732,
110,-122.93793,39.50458,1727,
120,-122.93815,39.50415,1717,
130,-122.9382,39.50362,1713,
140,-122.93818,39.5031,1703,
150,-122.93812,39.50258,1706,
160,-122.93792,39.5022,1707,
170,-122.93775,39.50177,1698,
180,-122.93745,39.50125,1693,
190,-122.93723,39.50073,1694,
200,-122.9373,39.50023,1702
]
}
}];
为了能够运行代码我还添加了以下几行:
var terrainProvider = new Cesium.CesiumTerrainProvider({
url : 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles',
requestVertexNormals : true
});
var viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider : terrainProvider,
baseLayerPicker : false
});
viewer.dataSources.add(Cesium.CzmlDataSource.load(czml)).then(function(ds) {
viewer.trackedEntity = ds.entities.getById('path');
});
如果你 运行 代码你可以看到飞机的中心点是如何跟随轨迹的,但是它的航向与它不对齐因此给出了错误的飞行应该是什么样子的说唱呈现:
您能否解释一下如何在不更改初始 czml 文件结构的情况下将飞机方向添加到代码中?
注意:我找到了 answer to this question 但我无法解决我的问题。
我想出了我的问题的答案。这里有几行代码,如果放在 Sandcastle 中将允许加载 czml 文件,然后通过某种类型的插值添加方向 属性:
//Sandcastle_Begin
var terrainProvider = new Cesium.CesiumTerrainProvider({
url : 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles',
requestVertexNormals : true
});
var viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider : terrainProvider,
baseLayerPicker : false
});
var options = {
camera : viewer.scene.camera,
canvas : viewer.scene.canvas
};
Sandcastle.addToolbarMenu([{
text : 'Lateral avoidance w. real Wx and waypoints (KJFK-LEBL)',
onselect : function() {
viewer.camera.flyHome(0);
viewer.dataSources.add(Cesium.CzmlDataSource.load('./SampleData/interp_turb_data_fromFede_avoid_realistic_w_waypoints.czml')).then(function(ds) {
var entity = ds.entities.getById('path');
// viewer.trackedEntity = entity;
entity.orientation = new Cesium.VelocityOrientationProperty(entity.position);
entity.position.setInterpolationOptions({
interpolationDegree : 1,
interpolationAlgorithm : Cesium.HermitePolynomialApproximation
});
});
}
}], 'toolbar');
Sandcastle.reset = function() {
viewer.dataSources.removeAll();
viewer.clock.clockRange = Cesium.ClockRange.UNBOUNDED;
viewer.clock.clockStep = Cesium.ClockStep.SYSTEM_CLOCK;
};
//Sandcastle_End
这样飞行器就和轨迹对齐了!
我有一个 czml 文件,代表一架飞行指定路径的飞机。该文件是基于Cesiusm提供的Sancastle示例构建的(CZML模型+CZML路径)。
这是 CZML 变量:
var czml = [{
"id" : "document",
"name" : "CZML Path",
"version" : "1.0",
"clock": {
"interval": "2012-08-04T10:00:00Z/2012-08-04T15:00:00Z",
"currentTime": "2012-08-04T10:00:00Z",
"multiplier": 10
}
}, {
"id" : "path",
"name" : "path with GPS flight data",
"description" : "<p>Hang gliding flight log data from Daniel H. Friedman.<br>Icon created by Larisa Skosyrska from the Noun Project</p>",
"availability" : "2012-08-04T10:00:00Z/2012-08-04T15:00:00Z",
"path" : {
"material" : {
"polylineOutline" : {
"color" : {
"rgba" : [255, 0, 255, 255]
},
"outlineColor" : {
"rgba" : [0, 255, 255, 255]
},
"outlineWidth" : 5
}
},
"width" : 8,
"leadTime" : 10,
"trailTime" : 1000,
"resolution" : 5
},
"model": {
"gltf" : "../../SampleData/models/CesiumAir/Cesium_Air.glb",
"scale" : 2.0,
"minimumPixelSize": 128
},
"position" : {
"epoch" : "2012-08-04T10:00:00Z",
"cartographicDegrees" : [
0,-122.93797,39.50935,1776,
10,-122.93822,39.50918,1773,
20,-122.9385,39.50883,1772,
30,-122.93855,39.50842,1770,
40,-122.93868,39.50792,1770,
50,-122.93877,39.50743,1767,
60,-122.93862,39.50697,1771,
70,-122.93828,39.50648,1765,
80,-122.93818,39.50608,1770,
90,-122.93783,39.5057,1754,
100,-122.93777,39.50513,1732,
110,-122.93793,39.50458,1727,
120,-122.93815,39.50415,1717,
130,-122.9382,39.50362,1713,
140,-122.93818,39.5031,1703,
150,-122.93812,39.50258,1706,
160,-122.93792,39.5022,1707,
170,-122.93775,39.50177,1698,
180,-122.93745,39.50125,1693,
190,-122.93723,39.50073,1694,
200,-122.9373,39.50023,1702
]
}
}];
为了能够运行代码我还添加了以下几行:
var terrainProvider = new Cesium.CesiumTerrainProvider({
url : 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles',
requestVertexNormals : true
});
var viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider : terrainProvider,
baseLayerPicker : false
});
viewer.dataSources.add(Cesium.CzmlDataSource.load(czml)).then(function(ds) {
viewer.trackedEntity = ds.entities.getById('path');
});
如果你 运行 代码你可以看到飞机的中心点是如何跟随轨迹的,但是它的航向与它不对齐因此给出了错误的飞行应该是什么样子的说唱呈现:
您能否解释一下如何在不更改初始 czml 文件结构的情况下将飞机方向添加到代码中?
注意:我找到了 answer to this question 但我无法解决我的问题。
我想出了我的问题的答案。这里有几行代码,如果放在 Sandcastle 中将允许加载 czml 文件,然后通过某种类型的插值添加方向 属性:
//Sandcastle_Begin
var terrainProvider = new Cesium.CesiumTerrainProvider({
url : 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles',
requestVertexNormals : true
});
var viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider : terrainProvider,
baseLayerPicker : false
});
var options = {
camera : viewer.scene.camera,
canvas : viewer.scene.canvas
};
Sandcastle.addToolbarMenu([{
text : 'Lateral avoidance w. real Wx and waypoints (KJFK-LEBL)',
onselect : function() {
viewer.camera.flyHome(0);
viewer.dataSources.add(Cesium.CzmlDataSource.load('./SampleData/interp_turb_data_fromFede_avoid_realistic_w_waypoints.czml')).then(function(ds) {
var entity = ds.entities.getById('path');
// viewer.trackedEntity = entity;
entity.orientation = new Cesium.VelocityOrientationProperty(entity.position);
entity.position.setInterpolationOptions({
interpolationDegree : 1,
interpolationAlgorithm : Cesium.HermitePolynomialApproximation
});
});
}
}], 'toolbar');
Sandcastle.reset = function() {
viewer.dataSources.removeAll();
viewer.clock.clockRange = Cesium.ClockRange.UNBOUNDED;
viewer.clock.clockStep = Cesium.ClockStep.SYSTEM_CLOCK;
};
//Sandcastle_End
这样飞行器就和轨迹对齐了!