Finding distances

Camden Daily cdaily at GMAIL.COM
Thu Jan 13 08:59:54 PST 2005


I'm working on an app in php/mapscript in which I'll need to do some
calculations of the distances between a given point (address) and
various shapefiles, such as parks, or schools.  Basically, I'll be
showing what the nearest school is, or nearest lake.

I know that mapscript has some useful functions, such as
distanceToShape().   I can check a point against every shape in a
shapefile and see which is smallest, but it seems to me that this
might take a very long time, especially if the shapefiles are really
large.

Alternately, it seems I could load the shapefile into a database and
use some 'where' clauses to my SQL statements to reduce the number of
points I need to check.  Does anyone have any examples of how to make
this run efficiently?



More information about the MapServer-users mailing list