function parseGeometry(geometry) { var feature = []; for (var i = 0, I = geometry.length; i < I; ++i) { var parts = geometry.getPaths(); var paths = []; for (var j = 0, J = parts.getLength(); j < J; ++j) { part = parts.getAt(j); path = []; for (var k = 0, K = part.getLength(); k < K; ++k) { var pnt = part.getAt(k); if (pnt) { path.push([pnt.lng(), pnt.lat()]); } else { console.log("Hole in geometry " + i + " at part " + j); } } paths.push(path); } feature.push(paths); } return feature; }
I am using it to read drive time coverage polygons BUT can't seem to get "hole" information.
Looked around a bit more and things look the same here as with holes on Google maps. I used a computeSignedArea function on the parts. Google maps has one for spherical geometry but one can roll their own simpler version for a flat surface if that will work.
If I wanted to examine/read the polygons from a multiple drive time request result then I would need to differentiate between parts that are not holes and two types of holes.
The two types of holes are either:
1. True holes that represent inaccessible areas within a drive time. 2. False holes created in a drive area to make space for enclosing/nesting a drive area of the next lesser time.
There doesn't seem to be a property or method associated with these parts that would determine whether it's a hole or not let alone a false or true hole. I'm dealing with these holes by using a simple computeSignedArea function for flat planes, length of parts arrays (vertices) and whether there are matches between an outer and it first nested inner drive time area based on these values.