openlayerscesiumjs

Change in rectangles after ol-cesium 2.15.0


I am using polygons in my website, built with Openlayers and ol-cesium.

These polygons used to be correct when in 3D (i.e. lines are not supposed to be straight in the 3D view).

Screenshot with proper lines, straight in world-space

This used to work fine until ol-cesium 2.14.0. Now I have tried to upgrade, and with 2.15.x onwards, polygon lines appear straight (i.e. screen-straight and not world-straight). I have also tried updating Openlayers and Cesium; nothing makes any difference.

Screenshot with incorrect lines, straight in screen space

var geometry = new MultiPolygon(this.paths[i]);
if (JMap.projection != 'EPSG:4326') {
    geometry.transform('EPSG:4326', JMap.projection);
}
geometry.set('olcs.polygon_kind', 'rectangle');
newpolygons.push(new Feature({
    geometry: geometry,
    colour: i
}));

Is a behaviour change which I can revert with some flag? I have created a ticket in case it is a regression: https://github.com/openlayers/ol-cesium/issues/1214


Solution

  • By looking at the diff in github, we can see 2 breaking changes:

    So the fixed code would be as follows:

    var geometry = new MultiPolygon(this.paths[i]);
    if (JMap.projection != 'EPSG:4326') {
        geometry.transform('EPSG:4326', JMap.projection);
    }
    var feature = new Feature({
        geometry: geometry,
        colour: i
    });
    feature.set('olcs_polygon_kind', 'rectangle');
    newpolygons.push(feature);