ThinkGeo.com    |     Documentation    |     Premium Support

Bounding Box Query

Hello,


I have two feature layers (State County and soccer fields).  Given a particular county in the countLayer, I would like to find all soccer fields (soccerLayer) that intersect.  Instead of looping through all the soccer fields and seeing if they intersect, is there a way to query soccerLayer using QueryTools(?) using the lower and upper points of the bounding box?


For example:


Collection<Feature> countyFeatures = countyLayer.QueryTools.GetFeaturesContaining(pointShape, ReturningColumnsType.AllColumns);


foreach(Feature features in countyFeatures)

{

 RectangleShape county = features.GetBoundingBox();

 double lowerLeftLatY = county.LowerLeftPoint.Y;

 double lowerLeftLngX = county.LowerLeftPoint.X;

 double upperRightLatY = county.UpperRightPoint.Y;

 double upperRightLngX = county.UpperRightPoint.X;

}





Collection<Feature> soccerFeatures = soccerLayer.QueryTools.something( 

(

  (All features whose LowerLeftPoint.Y is between lowerLeftLatY and upperRightLatY)

or

  (All features whose UpperRightPoint.Y is between lowerLeftLatY and upperRightLatY)

)



AND



(

  (All features whose LowerLeftPoint.X is between lowerLeftLngX and upperRightLngX)

or

  (All features whose UpperRightPoint.X is between lowerLeftLngX and upperRightLngX)

) 


Thanks, Steven



Hello Steven,



If there is no misunderstanding, the following code may satisfy your scenario.
soccerLayer.Open();
// if you want to find the features which inside a rectangle please use the following method.
Collection<Feature> soccerFeatures = soccerLayer.QueryTools.GetFeaturesInsideBoundingBox(countryExtent, ReturningColumnsType.AllColumns);

// Find features which intersecting with another shape.
// Collection<Feature> soccerFeatures = soccerLayer.QueryTools.GetFeaturesIntersecting(countryExtent, ReturningColumnsType.AllColumns);

// if you want to query the soccerFeatures intersect inregular whith a shape, please use this method.
// Collection<Feature> soccerFeatures = soccerLayer.QueryTools.GetFeaturesIntersecting(particularCounty, ReturningColumnsType.AllColumns);
soccerLayer.Close();

If you have any questions please let us know. Irregular 



Thanks,

Howard