new/update CZML entity position

863 views
Skip to first unread message

ehell...@gmail.com

unread,
Jul 8, 2016, 6:33:57 AM7/8/16
to cesium-dev
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

Hannah Pinkos

unread,
Jul 8, 2016, 10:20:37 AM7/8/16
to cesium-dev, ehell...@gmail.com
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

shawn...@gmail.com

unread,
Jan 22, 2019, 12:54:53 PM1/22/19
to cesium-dev
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

Omar Shehata

unread,
Jan 25, 2019, 10:37:02 AM1/25/19
to cesium-dev
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:

Shawn Torti

unread,
Jan 25, 2019, 10:48:54 AM1/25/19
to cesiu...@googlegroups.com
Thank you Omar,  I will give this a try to see if it works.

--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/5WaK5vgNaSI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages