Selecting the projection for a polygon

83 views
Skip to first unread message

Jose Gómez

unread,
May 4, 2016, 1:02:01 PM5/4/16
to cesium-dev
I have created a series of stacked polygons, right next to each other, as per their latitude and longitude. I would expect these to have their edges touching each other. However, they are separate.

As discussed in http://gis.stackexchange.com/questions/191984/openlayers-3-cesium-polygon-projection-issue , the issue is that vertices are defined using latitude and longitude, whereas polygons are drawn in a different projection.

Is there a way to tell Cesium the projection to use for rendering a polygon? Otherwise, is this something that could be added in the future? (which we could document in a GitHub artefact).

Code used in the sandcastle:

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

viewer.entities.add({
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-30, 70,  0, 70,  0, 69, -30, 69, -30, 70]),
        material : Cesium.Color.RED
    }
});
viewer.entities.add({
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-40, 71, 10, 71, 10, 70, -40, 70, -40, 71]),
        material : Cesium.Color.RED
    }
});
viewer.entities.add({
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-50, 72, 20, 72, 20, 71, -50, 71, -50, 72]),
        material : Cesium.Color.RED
    }
});
viewer.entities.add({
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-60, 73, 30, 73, 30, 72, -60, 72, -60, 73]),
        material : Cesium.Color.RED
    }
});
viewer.entities.add({
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-70, 74, 40, 74, 40, 73, -70, 73, -70, 74]),
        material : Cesium.Color.RED
    }
});

viewer.zoomTo(viewer.entities);
Polygon.png

Hannah Pinkos

unread,
May 5, 2016, 10:33:41 AM5/5/16
to cesium-dev
Hello,

Points of a polygon are connected by finding the shortest distance between those two points. Most of the time, the shortest distance will not be following the longitude and latitude lines.
However, for drawing rectangles that do follow lon/lat lines, we have a separate primitive type.  Using a rectangle instead of a polygon should work for you.

Best,

Hannah

Jose Gómez

unread,
May 5, 2016, 10:53:10 AM5/5/16
to cesium-dev

That works great, thanks a lot!


Reply all
Reply to author
Forward
0 new messages