Hi,
i’m new on this forum. I don’t know if this is the correct area where to ask a question.
I would like to know if is possible to extract the coordinates of a polygon (added through a KML). Especially after entering the data on cesium I want to change the boundaries by acting on individual points.
Thank you,
Gianmaria
I’ll give you some more information to be more clear.
I have attached an example of a KML file that we can load and display correctly.
In Cesium this will produce a polygon entity (am i right?), from which i can get some information like: id, name etc…, stored in the file.
My problem is that i don’t know how to get the coordinates of this polygon entity, i would like to change them dynamically, maybe with a drag and drop function.
Thank you.
Gianmaria
Afghanistan (1).kml (27.1 KB)
Once you get the polygon entity, you will have a polygon property inside it.
Check out the entity API: http://cesiumjs.org/Cesium/Build/Documentation/Entity.html
In the document, look at the entity’s polygon property, and click on the PolygonGraphics link to see what are the properties of the polygon graphics (http://cesiumjs.org/Cesium/Build/Documentation/PolygonGraphics.html). In short, you are looking for is the hierarchy property.
EUREKA!
Cesium.knockout.getObservable(viewer, ‘_selectedEntity’).subscribe(function(entity) {
if (!Cesium.defined(entity)) {
console.log(‘De-selected entity.’);
selectedEntity = null;
} else {
console.log('Selected entity ’ + entity.id);
selectedEntity = entity.name;
console.log(entity.polygon.hierarchy._value.positions); /// Display correctly in the console the cordinates!
}
});
Thanks!