Draw a line on earth surface

Hi!

I need to draw a line that follows the the curvature of the earth, like when I draw a Polygon.

//draw on earth surface:

var polygon = new Cesium.Polygon();

polygon.setPositions(ellipsoid.cartographicArrayToCartesianArray([

Cesium.Cartographic.fromDegrees(10.0, 0.0),

Cesium.Cartographic.fromDegrees(-70.0, 35.0),

Cesium.Cartographic.fromDegrees(-75.0, 30.0),

Cesium.Cartographic.fromDegrees(10.0, 0.0)

]));

primitives.add(polygon);

//it’s straight:

var polylines = new Cesium.PolylineCollection();

primitives.add(polylines);

polylines.add({

positions : ellipsoid.cartographicArrayToCartesianArray([

Cesium.Cartographic.fromDegrees(10.0, 0.0),

Cesium.Cartographic.fromDegrees(-70.0, 35.0),

Cesium.Cartographic.fromDegrees(-75.0, 30.0),

Cesium.Cartographic.fromDegrees(10.0, 0.0)

]),

color : new Cesium.Color(1, 0, 0, 1)

});

Is there a way to do it?

Thanks!

Tamy,

You are correct. Polylines do not draw on the surface in the way Polygons do. We will eventually have a separate primitive which will do what you want. This is actually a pretty hard problem once terrain is involved. If you’re curious, @pjcozzi had a SIGGRAPH poster on it last year that you can read all about here: http://blogs.agi.com/agi/2011/04/25/a-screen-space-approach-to-rendering-polylines-on-terrain/

For now, you simply need to walk the line yourself to interpolate points along the surface of the Earth. I’m not sure if we have any helper functions to do this in Cesium yet (someone please correct me if I’m wrong), but it should be fairly straightforward. If you have problems getting it to work, just let us know.

Matt

Tamy,

To do the interpolation that Matt suggests, it should be easy to port a C# function I wrote awhile back. Here is the discussion - https://groups.google.com/forum/#!searchin/cesium-dev/openglobe/cesium-dev/Hgd2LvDnIME/xT5qwT-XywUJ

Regards,

Patrick

Thanks for help, Matt and Patrick.