[GIS] Cesium load geometry as GeoJSON

3dcesiumgeojson

I am trying to add a building geometry as GeoJSON to Cesium virtual globe. But the 3d building geometry is seen 2D polygon. Here is a picture from GeoJSON file and Cesium. As can be seen GeoJSON file includes z coordinates.

enter image description here

GeoJSON file

Best Answer

The z value in GeoJSON refers to the Height above the ground, so it is not a 3D file, you can store the polygon heights as attributes so that your properties are:

"id", "gmlid", "parent_is", "root_id", "cityobject_id", "building_height"

Run this code "the heights are based on "parent_id". (should all have the same height)

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

     var promise = Cesium.GeoJsonDataSource.load('../../SampleData/bina.gejson');
     promise.then(function(dataSource) {
     viewer.dataSources.add(dataSource);
     var entities = dataSource.entities.values;
     for (var i = 0; i < entities.length; i++) {
        var entity = entities[i];                       
        //Extrude the polygon based on any attribute you desire         
        entity.polygon.extrudedHeight = entity.properties.parent_id;
    }


    });

    viewer.zoomTo(promise);