new/update CZML entity position

Hello all,

I want to add and/or update entity positions (from czmlDataSource).

I have several czmlDataSources that are added to a dataSourceCollection ("Divisions", "Forts", etc which can be seen at www.geo-animate.com/CesiumScripts/battleForNormandy/animation.php).

I am using cartographicDegrees to control each entity via the position property.

1- If I want to add a new position to entity "123" of the "Divisions" czmlDataSource, do I simply process the new CZML position into the dataSourceCollection?

<<<<<<<<<
var newPosition =
  [ { "id" : "document", "version" : "1.0" },
  {
    "id" = "123",
    "position" : {
      "cartographicDegrees" : ["1944-06-06T06:00:00Z",5.000,5.000,0]
    }
  ];

var divisionsDataSource = new Cesium.CzmlDataSource.process(newPosition);
viewer.dataSources.add(dataSourceCollection.add(newPositionDataSource));

2- If I want to update an existing position to entity "123" of the "Divisions" czmlDataSource, must I remove the existing "123" entity and replace it entirely? Or can I process new positions with exactly the same timeStamp to overwrite the existing entity positions?

Best weekend, erik

Hello Erik,

Here is an example of how to get the entity from the CZML datasource and add a new position sample:

var czml = [{
“id” : “document”,
“name” : “box”,
“version” : “1.0”
}, {
“id” : “shape1”,
“name” : “Blue box”,
“availability”:“2012-08-04T16:00:00Z/2012-08-04T17:00:00Z”,
“position” : {
“cartographicDegrees” : [“2012-08-04T16:00:00Z”,-110.000, 35.000,0]
},
“box” : {
“dimensions” : {
“cartesian”: [400000.0, 300000.0, 500000.0]
},
“material” : {
“solidColor” : {
“color” : {
“rgba” : [0, 0, 255, 255]
}
}
}
}
}];

var viewer = new Cesium.Viewer(‘cesiumContainer’);
var dataSource = Cesium.CzmlDataSource.load(czml);
viewer.dataSources.add(dataSource);

dataSource.then(function(ds) {
var entity = ds.entities.getById(‘shape1’);
entity.position.addSample(Cesium.JulianDate.fromIso8601(‘2012-08-04T17:00:00Z’), Cesium.Cartesian3.fromDegrees(-117.000,20.000));
});

``

Best,

Hannah

Hey Hannah,

I am running some test with multiple aircraft coordinates and would like the air craft icons to position themselves in the direction they are heading.. The following snippet works for a single aircraft icon when I use the getById

  viewer.dataSources.add(Cesium.CzmlDataSource.load('../../data/simple.czml')).then(function(ds) {
        var entity = ds.entities.getById('Flight');
        //viewer.trackedEntity = entity;
        entity.orientation = new
Cesium.VelocityOrientationProperty(entity.position);
        entity.position.setInterpolationOptions({
        interpolationDegree : 5,
        interpolationAlgorithm : Cesium.HermitePolynomialApproximation
        });

where 'Flight' is the ID of a single aircraft in the CZML stream. I would like to do this for all/multiple flight icons, not just the specified getById.
  
Is this possible in either the JavaScript HTML or in the CZML data feed?

Thanks ahead for the support.

Shawn

You should be able to do this by looping through all the entities in your CZML and setting a velocity orientation property as you’ve done for that single entity. This Sandcastle has an example of looping through all the entities created from a dataSource and applying a color to them:

Thank you Omar, I will give this a try to see if it works.