Reading Polygon Geometries. Help with Javascript search cursor on  polygon  features

720
5
05-11-2013 08:09 AM
MarkSzlazak
New Contributor
I am having a problem detecting holes with my Javascript search cursor that I based on the info found here:

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Reading_geometries/002z0000001t000000/...

My script is:

   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.
0 Kudos
5 Replies
MarkSzlazak
New Contributor
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.
0 Kudos
derekswingley1
Frequent Contributor
Take a look at what I posted on the GIS StackExchange a while back:  http://gis.stackexchange.com/a/2750/124
0 Kudos
MarkSzlazak
New Contributor
Take a look at what I posted on the GIS StackExchange a while back:  http://gis.stackexchange.com/a/2750/124


Thanks.

I probably needed to be more specific.


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.

I hope that makes sense.
0 Kudos
derekswingley1
Frequent Contributor
Is the end goal to see if a point falls within a drive-time polygon?
0 Kudos
MarkSzlazak
New Contributor
Is the end goal to see if a point falls within a drive-time polygon?


That is one goal but it has to be done locally from the PC.
I need to filter out those false holes because they cause unneeded processing.
0 Kudos