[Mapserver-users] Re: Newb: How to retrieve data from the database???

pkishor_98 <pkishor at geoanalytics.com> pkishor at geoanalytics.com
Thu Dec 19 16:48:24 EST 2002


--- In mapserver-users at yahoogroups.com, "Andres Garcia"
<listamapserver at h...> wrote:
> 
..
> Basically i need to do 2 things (use cases):
> 
> 1) If you are browsing a map and need to retrieve the 
> information asociated 
> to an element, connect to the database and show that information.
> 
> 2) Query the database, retrieve the information of the 
> elements that matches 
> the query, and show them on a map.
> 
> Both use cases are similar but i dont have any idea of how to 
> do that!!
> 

Both are pretty standard use-cases, and there are ample examples on
the mapserver wiki. Depending on the server side language you are
using, you would do well to study the mapquakes.pl perl script (I
think you can find it on the wiki) or the gmap set of php scripts from
DM Solutions.

the basic thing you have to understand is the way the geographic
features in a shape file are indexed. In both perl and php there are
methods to grab the shapeindex of the shape. Once you have that, you
can go to the dbf and get the relevant record, or, if you other
database is so setup, retrieve the row from the database. Going the
other way, you should be able to get the shapeindex of the feature you
want from your database table, and then use the methods in the script
to zoom to the feature in your shape file.

I don't have any ready scripts to give you... but the examples should
be pretty easy to get. Start with the gmap demo. That will take you
places.

Puneet.




More information about the mapserver-users mailing list