I'm currently having a few issues with loading GeoJson point data and then updating those points with the current TerrainProvider using sampleTerrain. I'm hoping I'm just not using things optimally and there is another suggested method for updating the GeoJson items.
basic code for what i'm doing (some steps trimmed for brevity):
var dataSource = new Cesium.GeoJsonDataSource();
dataSource.loadUrl(geoJson).then(function() {
var entities = dataSource.entities.entities;
updateCollectionHeightForTerrain(entities);
}
function updateCollectionHeightForTerrain(collection){
var positions = ;
for(index = 0; index < collection.length; ++index){
var item = collection[index];
var position = item.position.getValue(Cesium.JulianDate.fromDate(new Date()));
position = _viewer.scene.globe.ellipsoid.cartesianToCartographic(position);
positions.push(position);
}
var promise = Cesium.sampleTerrain(terrainProvider, 11, positions);
Cesium.when(promise, function(updatedPositions) {
for(var i = 0; i < updatedPositions.length; i++){
var newPos = _viewer.scene.globe.ellipsoid.cartographicToCartesian(updatedPositions[i]);
collection[i].position = new Cesium.ConstantPositionProperty(newPos);
}
});
First problem: If my array of positions is larger than 1 or 2 points, the terrain sampling appears to time out and when function never gets hit. Is there a way to adjust the sampleTerrain timeout? Or is there some other workaround here?
Second problem: If I instead do this point by point, since it is an asynchronous call, when it returns I have no idea what object/item the updatedPosition is actually for. Any suggestions?
Third problem: even after adjusting the height, I still see some z-fighting and the symbol being partially covered by the terrain at far zoom levels despite the symbol being above the terrain and depthTestAgainstTerrain being set to false. Any idea what's going on here? (i also see this problem with models and polylines that are well above the terrain.. like airplane cruise altitudes)