Hi all,
am using GeoJsonDataSource with Viewer widget to render vector lines and facing two issues:
-
When dragging map, terrain and base layer are dragged faster then vector features (this is issue is also present at cesium sandcastlehttp://cesium.agi.com/Cesium/Apps/Sandcastle/?src=Polylines.html)
-
when zooming in, at bigger zoom levels, lines disappear (can partially disappear) then appear again. (seems like lines do not honour terrain model)
Are these bugs? I didn’t find such issues described on github or here.
Thanks,
Alex.
Hi Alex,
I think these are both the same problem. Because lines do not follow terrain, they can appear to move relative to the surface when you drag the globe. Fixing this is challenging, but it’s on the roadmap:
https://github.com/AnalyticalGraphicsInc/cesium/issues/526
In the meantime, you can manually place lines on terrain by setting the height of each point. The sampleTerrain function in Cesium may help. By default, lines are not depth-test against (in other words, they’re not obscured by) terrain. See this item on stackoverflow for information about how to change that and the caveats with doing so:
http://stackoverflow.com/questions/18768992/cesium-stop-shapes-showing-when-underneath-globe
Kevin
Hi Kevin,
thank you for the response I will try lines with height of each point.
HI Kevin,
getting height through sampleTerrain provides height, but only when terrain data is loaded. Is there kinda event which is fired when tile is loaded so that positions covered by this tile could be processed?
Thanks,
Alex.
Hi Alex,
sampleTerrain should work no matter whether the tiles are already loaded or not. It executes asynchronously, though, returning a promise that resolves once the necessary tiles are loaded and the heights are updated. Tell me more about what you’re seeing.
Kevin
Hi Kevin,
here how the code looks loke:
var dataSource = new Cesium.GeoJsonDataSource();
dataSource.getChangedEvent().addEventListener(function(source){
var lines = [];
source.getDynamicObjectCollection().getObjects().forEach(function(item) {
var c = []
item.geoJson.geometry.coordinates.forEach(function(coord){
c.push(Cesium.Cartographic.fromDegrees(coord[0], coord[1]));
});
lines.push(c);
});
setTimeout(function(){
var promise = Cesium.sampleTerrain(terrainProvider, 5, lines[0]);
Cesium.when(promise, function(updatedPositions) {
console.log(updatedPositions);
});
}, 10000);
}, self);
cesiumWidget.dataSources.add(dataSource);
This code logs correct updated positions, with height, in 10 seconds. If I remove the setTimout it logs nothing.
Thank you,
Alex.