dynamic update of polylines with the API (not czml)

Hi ,

I'm trying to connect two moving dynamic objects with a polyline like we can see in the sandcastle czml demo (geoeye1 to iss). I'm not using czml for this, but directly the API and I can manage to update my PolylineGeometry with good performances.

for now, I juste remove the primitive, update my PolylineGeometry points and re-create a primitive. It is slow.

Isn't there a way to 'sync' the primitive everytime I update my PolylineGeometry points ?

Thank you.

PolylineGeometry (and all other Geometry instances) are optimized for static data. If you wish to update a polyline every frame, you should use Polyline & PolylineCollection, which is much faster and has a “setPositions” method. This is what the DyanmicScene uses for object paths. We have plans to add features to better support dynamic geometry of all kinds, but that’s the best practice for now.

I’ll also add that even if you aren’t using CZML, you might want to look into implementing a custom DataSource. This is a layer of abstraction that allows you to specify data without actually managing primitives directly. When we make improvements to the underlying visualization system, a DataSource benefits from it immediately without any changes to its implementation. For example, GeoJsonDataSource, which as it’s name implies, handles GeoJSON data; will be literally over a 100x faster in the upcoming March 3rd release, and we didn’t need to change a line of code in GeoJsonDataSource itself.

Of course you are welcome to use primitives directly, it all depends on your specific use cases and what you are trying to accomplish.

I hope that helps.

Thanks that should help !

I'm going to try with PolylineCollection.

If I use a Datasource (custom or czml) will I be able to use a PolylineGlowType material ?

While we don’t support PolylineGlow material yet in DynamicPath objects, it should be a fairly easy change. I just opened https://github.com/AnalyticalGraphicsInc/cesium/pull/1500 which adds PolylineGlow mapping to DynamicScene, but I still need to make a few more changes to let paths use it. I expect both of these features to be available in our next release on March 3rd.

Hi guys,

I’m trying to update the Polyline positions but I appear to be getting an “undefined is not a function”

var scene = viewer.scene;

var primitives = scene.primitives;

var polylines = new Cesium.PolylineCollection();

var points = [-100.0, 40.0,-90.0, 40.0];

// Apply a polyline glow material

var coloredPolyline = polylines.add({

positions : Cesium.Cartesian3.fromDegreesArray(points),

material : Cesium.Material.fromType(Cesium.Material.PolylineGlowType, {

innerWidth : 3.0,

color : new Cesium.Color(1.0, 0.5, 0.0, 1.0)

}),

width : 10.0

});

primitives.add(polylines);

points.push(-101.0, 41.0);

coloredPolyline.setPositions(Cesium.Cartesian3.fromDegreesArray(points));

when I call coloredPolyline.setPositions().

Can anyone please show me how a valid version of the above? coloredPolyline is registering as an object, but somehow the setPositions is not registering as an available function. I have also tried the get() function as outlined in http://www.personal.psu.edu/users/k/y/kyn5050/Documentation/PolylineCollection.html#get however I get similar results.

“Uncaught TypeError: undefined is not a function”

If you’re using a relatively recent version of Cesium, all getters and setters have been turned into properties. In other words, change “.setPositions([array])” to “.positions = [array]”.

See the changelog for specifics.

You genius, thank you very much!

The current documentation is a little misleading but I understand that things are busy with the release for 1.0. I’m looking forward to more excellent work! Keep it up

Another Polyline / PolylineCollection question:

In our application we want to show the route of an object.

Part of the route is static ‘history’ (a few hundred points), so in my first trial I easily plotted this with a PolylineGraphics added to the viewer.entities. The viewer.flyTo(entity) is very useful in this case.

However, the seconds part is to update the route with new positions, about every second. Since it is not possible to add positions to a PolylineGraphics I suppose I’ll have to use a PolylineCollection that I can update dynamically.

What would be the best way to handle this? Put all data in the PolylineCollection (with e.g. 2 polylines for history and real-time), or use both the viewer.entities and the PolylineCollection. I would prefer to use the higher level entities.

Thanks, Willem

Have you looked at entity.path, which is a PathGraphics? It’s designed to do exactly what you describe. Put all of your samples into Entity.position and then it does the rest.

Hi Matthew,

Thanks for the suggestion.

I tried the entity.path and entity.position (using SampledPositionProperty) and it seems to work fine.

I had to modify the PathGraphics.resolution to something like 12 hours because otherwise the performance dropped with history data going back a year (most of the history data will have max two points per day anyway). It looks like this has no impact on the resolution of the ‘real-time’ data that is added to the history, but some more testing will be needed.

Willem

PS: the Description of options.resolution in the PathGraphics documentation is incorrect.

Path optimization is on the roadmap but not near term. If you want to try and get better performance and don’t care about animating to that part of the path, you can always use an entity polyline for the initial historic portion and then use path for the new positions that you are updating.