Can anyone think of a better way of doing this?

jlewis
11-10-2007, 12:28 PM
Hi All,

I have a map with shed-loads of shapes (polygons) - could be up to 1000.

I have one location.

I need to find which of the shapes (if any) my location is 'in'.

Currently, what I do is to add a pushpin (at my location) to the ActiveMap, then, using the DataSet, iterate through the shapes and see if the location is in each shape - using DataSet.QueryShape(Shape).

This can be quite time-consuming so can anyone think of a quicker way?

Many thanks...

Paul Larson
11-12-2007, 06:07 AM
As you're loading the shapes, keep track of the bounding-rectangle corners (ULC,LRC) for each shape. Then you can easily determine if a location falls within the bounding rectangle and limit your results to test for point-in-polygon only on those shapes.

Of note - If your shapes are coming from an ESRI .SHP file, the bounding corners are already computed for you.

-Paul

 
Web mp2kmag.com
mapforums.com