Thursday, 30 March 2017

Converting Entity to GeoJSON with Cesium


I know there is a way to load entities from a GeoJSON using GeoJsonDataSource but is there any way to do the opposite: get any entity as a GeoJSON representation?


My goal is to use Turf.JS with Cesium.JS geometries.



Answer




Here you have a solution to export to json and for export it to kml.


Everything is obtained from this official thread of Cesium.


Update:


They are links that talk about the question and there isn't method to do that native in Cesium, such as exportKml. To implement exportJson (for example), it should be done using pure js or Turf as you did.


You can use the exportKml code to help create the result you are looking for.


Another way you can try is to export to KML and convert the result xml to json. For example using togeojson



Cesium.exportKml({
entities: entityCollection
})
.then(function(result) {
// The XML string is in result.kml
// Convert Kml to GeoJSON (It's just an idea)
json = toGeoJSON.kml(result)
});

Note: If it is considered to be not a valid response, you can simply delete it or not accept it.



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...