I am using OpenLayers 3 and Cesium (via ol3-cesium).

I have created a few rectangles (using a MultiPolygon) stacked on top of each other. Whereas in OpenLayers the rendering (left) is as expected, the output in Cesium (right) is not.

enter image description here

I understand that a rectangle in one projection will not be a rectangle in the other. However, I would expect the software to appropriately project the rectangle.

In this case, what I was expecting is for the Cesium output not to have any gaps between rectangles. On the other hand, the vertices seem to be in the right coordinates, so these polygons are just following the shortest lines between vertices.

What defines which projection is a polygon based upon, and therefore which projection should apply to it? For these vertices, are the right polygons the left or the right ones?

And moreover, how do I get Cesium / ol3-cesium to render the polygons covering the same area as the equivalent polygons in the 2D map?

JSFiddle: https://jsfiddle.net/adlerhn/o1j1fv9x/4/


What defines which projection is a polygon based upon, and therefore which projection should apply to it? For these vertices, are the right polygons the left or the right ones?

That depends on what purpose the polygons are going to used for.

If their areas matter, then you should build them in an equal area projection like Albers. If 90 degree angles matter, then a conformal projection like Lambert conformal conic or transverse Mercator would work.

Regardless, if you're going to be projecting linear or polygonal features between different projected and geographic coordinate reference systems (CRS), densify the lines.

Many software packages will not densify lines on-the-fly as part of a reprojection for performance reasons or a desire to not change the original feature too much.

In your case, the polygons on the left were build from latitude-longitude coordinates or possibly in a cylindrical projection where latitude lines are straight lines. To get similar-looking features in Cesium, you'll have to densify the features first.

  • Thanks for your informative response. I understand that by "densify the lines" you mean to subdivide the polygons in smaller spans, so that intermediate vertices will preserve the right location, right? I was trying to avoid that for performance reasons, since I already have a lot of polygons and rendering is on the slow side. I want this to perform reasonably on mobile devices. – Jose Gómez May 2 '16 at 17:22

In addition to mkennedy's response, for achieving this effect in Cesium (from https://groups.google.com/d/msg/cesium-dev/BT5z9ztSnvk/4Fpjaxh5BQAJ):

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. Here is an example: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Rectangle.html&label=Geometries

Flat rendering:

    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-30, 70,  0, 70,  0, 69, -30, 69, -30, 70]),
        material : Cesium.Color.RED

Projected rendering:

    rectangle : {
        coordinates : Cesium.Rectangle.fromDegrees(-30, 69,  0, 70),
        material : Cesium.Color.RED

Live sample: http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=9a7dcab4afa92575d9d99b6887bb78b1

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.