How to draw lines of constant latitude (e.g. Tropic of Cancer)?

547 views
Skip to first unread message

David Whipps

unread,
May 2, 2016, 10:55:41 AM5/2/16
to cesium-dev
I'm trying to draw the tropics of Cancer and Capricorn (lines of constant latitude at about 23.5 and -23.5 degrees) using Polyline Entities like this:

      var TROPIC_OF_CANCER_LAT = 23.43717;

      // Create a single line around the equator and show it.
      var polyline = myCesiumViewer.entities.add({
        name : 'Tropic Of Cancer',
        show: true,
        polyline: {
          loop: true,
          positions : Cesium.Cartesian3.fromDegreesArray([-180, TROPIC_OF_CANCER_LAT,
                                                          -90, TROPIC_OF_CANCER_LAT,
                                                           0, TROPIC_OF_CANCER_LAT,
                                                           90, TROPIC_OF_CANCER_LAT,
                                                           180, TROPIC_OF_CANCER_LAT]),
          width : 3,
          material : Cesium.Color.GREEN
        }
      });


... but because the line segments follow great circle arcs, they don't show as proper lines of latitude, but "scalloped" lines going from each of the line points provided in the array.

So, what's the preferred method to draw a single line at a constant latitude? (I realize there are "image" layers that draw the grids, but that's not what I'm looking for here.)

Thanks!

- Dave


Hannah Pinkos

unread,
May 2, 2016, 11:24:39 AM5/2/16
to cesium-dev
Hello,

Cesium currently only has support for great arcs.  If you want to follow the latitude lines, you will need to compute your own line.  You can do this by adding many points to your polyline, and setting followSurface: false.
Here is an example:

var viewer = new Cesium.Viewer('cesiumContainer');

var lon = -180;
var lat = 23.43717;
var pos = [];
for (var i = 0; i < 360; i++) {
    pos
.push(Cesium.Cartesian3.fromDegrees(lon, lat));
    lon
++;
}

viewer
.entities.add({
    polyline
: {
        followSurface
: false,
        width
: 3,
        material
: Cesium.Color.GREEN,
        positions
: pos
   
}
});

Best,

Hannah

David Whipps

unread,
May 2, 2016, 11:36:16 AM5/2/16
to cesiu...@googlegroups.com
Hmm. Ok. This seems terribly inefficient, and breaks down when the Camera gets close to the Earth.

I supposed this falls under “feature suggestion” at this point.

Thanks,

Dave



--
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/Abryjt_-czw/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.

Hannah Pinkos

unread,
May 3, 2016, 11:18:03 AM5/3/16
to cesium-dev
Hmm, what do you mean when you say it breaks down then the camera gets close to the earth?  I didn't see any problems on my machine.  Do you have depthTestAgainstTerrain turned on?
It's actually not that inefficient.  This is similar to the kind of subdivision Cesium does behind the scenes when computing the great arc between two points.

Best,

Hannah

David Whipps

unread,
May 3, 2016, 11:18:52 AM5/3/16
to cesiu...@googlegroups.com
Hannah,

My mistake. Looks good. 

Thanks!

- Dave
Reply all
Reply to author
Forward
0 new messages