OGR Source and Parameter Query

Frank Warmerdam warmerdam at POBOX.COM
Fri Sep 10 12:48:28 EDT 2004

Tim Pascoe wrote:
> I'm relatively new to MapServer, but I have so far developed a nice simple
> application for displaying data from a database of national sampling
> locations. The base information is coming from several WMS servers, while
> the sample point information is an OGR data source from my local MS-SQL
> Server instance.
> What I'd like to be able to do is pass a parameter to the query being used
> as the OGR data source, allowing a user to select a particular study from
> the database, and thus display the sampling locations for only that study.
> Does that make sense?
> I looked through the archives, and didn't find anything that seemed
> immediatly usefull, so I thought I'd see if anyone else had done something
> like this. I'm running PHP 4.3.8, Mapserver 4.2 (precompiled Win32
> binary), and IIS 6.0.


Are you using a virtual OGR dataset to access the MS-SQL database?  If so,
you can replace the <SrcLayer> element with a <SrcSQL> element with a custom
query selecting on some criteria.  If you want to make this dynamic (ie. the
key passed in by the user somehow) things will get substantially harder.
One approach would be to use mapscript, and alter your ovf definition on the
fly.  Another would be have the ovf definition embedded in the .map file and
parameter substitution to substitute in our extra criteria.  I have never
tried doing the parameter substitution myself.

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

More information about the mapserver-users mailing list