How to handle roads on a 3D map with terrain?

Hello!

Imagine, I have a Cesium viewer, showing

a) a portion of a city
b) with terrain,
c) buildigns and
d) roads.

I noticed that as soon as I add terrain, some buildings aren't properly displayed. I suppose that it's because the city has lot of elevation changes. Therefore, when I put a building model into the viewer, I need to take into account the elevation at that particular place.

But I also have roads, which are polylines from OpenStreetMaps. Each of them consists of several points, and for each point I can calculate the elevation.

Is it possible to render a polyline in Cesium such that individual points of it are located at varying heights?

Thanks in advance

Dmitri Pisarenko

Hello Dmitri,

Yes, if the positions given to a Polyline have height, then the polyline will be drawn at those heights. Here is an example:

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

var purpleArrow = viewer.entities.add({
    polyline : {
        positions : Cesium.Cartesian3.fromDegreesArrayHeights([-75, 43, 500000,
                                                               -80, 43, 0,
                                                               -85, 43, 500000]),
        width : 10,
        followSurface : false,
        material : Cesium.Color.PURPLE
    }
});

viewer.zoomTo(viewer.entities);

Best Regards,

Hannah