I am rendering the geometry of buildings through a WFS (geoJson).
Some of these buildings have a hole in them, some of them have multiple holes, some of them have no holes.
I am running over this geoJson file in a for-loop, making entities of each building.
For the moment, I can get all the buildings on the map, but I am only able to get one hole in buildings which actually have multiple holes (see code below).
This is because I do not know how to dynamically change the setup of making holes in the polygon, depending on the amount of holes…
I have over six million buildings in my database, and I have no idea what the maximum amount of holes in one single building is.
Of course, I could figure out what the maximum amount of holes is and provide enough lines to cover it, but maybe one day I will update the database and add a building that has one more hole and run into problems.
Um. I assume you have some sort of “holes” array per item, which may have an arbitrary number of items in it, varying per building? In that case, all you have to do is something like:
var holePositions = holes.map(function(hole) {
return {position : Cesium.Cartesian3.fromDegreesArray(hole)};
});
In other words, just loop over your original “holes” array, create a new array with a hole position object for each item in the original array, and pass that to the Entity.
You made a small typo: position --> positions makes a big difference
For those of you trying to do the same as me: do not forget to redefine var holePositions at the beginning of every loop, or you’ll get very strange results