[ms4w-users] find my nearest?

Taylor, Adam ataylor at ilpcs.com
Thu Apr 27 12:42:22 EDT 2006

A postgis database would be your best bet for this.  
http://pgfoundry.org/projects/pginstaller has a nice version of Postgis
that works well with MS4W.  
If you aren't familiar with Relational databases I'd recommend looking
at a quick SQL tutorial first http://www.w3schools.com/sql/default.asp.
Then install Postgis.  
You can easily turn a shapefile with points for your locations (Coffee
Shops, Wifi HotSports, Cell Sites, etc.) into a postgis database by
using the shp2pgsql application (command line application that comes
with PostGis).  You can also use ogr2ogr and acheive the same results.  
shp2pgsql -d/-a -D will use a binary format to upload your shapefile to
the Database and is much faster and using just -d or -a.  just run the
shp2pgsql command with no arguments and it will give you an explanation
of what each command does.
To speed up your query, I'd recommend making a spatial index and doing
all the necessary steps mentioned on the Postgis website
Your query will look just like the SQL queries above but with some added
information.  If you do a select distance_sphere instead of a select
distance you will get very accurate results.
Your final query will look something like this:
select distance_sphere(SetSRID(the_geom,4326), GeomFromText(
'POINT($long $lat)', 4326)) as dist, * from on_air_sites order by dist
asc limit 5;
That query would return the five closets items to the $long and $lat you
have entered.  You could incorporate this query into mapscript plot a
map of the closet Widget Factories, or you could just use a display of
the data of the closest locations.  The 4326 is the projection you are
using for your data.  This is pulled from the PROJ installation and as
long as proj knows the projection you can query with postgis in that
Postgis is a very powerful analysis tool.  For other questions, I'd
refer you to the postgis mailing lists.
Adam Taylor     
iPCS Wireless Inc       
(616) 656-2970 *  |  (616) 706-7393 *


From: ms4w-users-bounces at lists.maptools.org
[mailto:ms4w-users-bounces at lists.maptools.org] On Behalf Of Mark Ford
Sent: Thursday, April 27, 2006 12:15 PM
To: ms4w-users at lists.maptools.org
Subject: [ms4w-users] find my nearest?

I have been asked to implement a GIS enabled system with "find my
nearest" functionality. Can MapServer achieve this or (as I suspect) is
it more of a postcode address finder type problem. if you know what i
I am thinking i may have to use PAF to do the find my nearest thing and
then plot the results on a map using map server?
Any andvice at all greatly appreciated,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/ms4w-users/attachments/20060427/755f7c62/attachment.html

More information about the ms4w-users mailing list