PinnGIS

Does extent.intersect check the extent of a polygon before it's geometry?

Discussion created by PinnGIS on Jun 9, 2014
Latest reply on Jun 15, 2014 by PinnGIS
More of a best practice question.  If I am testing to see whether a polygon is intersecting with an extent, should I first test if the polygon's extent intersects and then test the geometry?  Or is it just as efficient to simply test the polygon's geometry?  Here is some code to illustrate.

Which is better? This:
var userExtent; //an extent the user has selected
var featExtent = new Extent(feature.geometry._extent); //an extent from a Feature Layer graphic
if (userExtent.intersects(featExtent){
   console.log("The two Extents Intersect");
   var polygon = new Polygon(feature.geometry);
   if (userExtent.intersects(polygon){
      console.log("Polygon intersects with user defined Extent");
   }
}


Or this:
var userExtent; //an extent the user has selected
var polygon = new Polygon(feature.geometry); //geometry from a Feature Layer graphic
if (userExtent.intersects(polygon){
   console.log("Polygon intersects with user defined Extent");
}

Outcomes