Passing Variable to a Map File

Damon Broglie brog at MAIL.UTEXAS.EDU
Mon Dec 5 16:42:50 EST 2005


I'm having a devil of a time working on this one.

My setup:
* Linux server ( Fedore Core 3, Apache, etc. )
* MapServer ( 4.2.5 )
* MapLab w/ gMap Factory ( 2.2.1 )
* PHP/MapScript ( 1.194.2.6 )
* PostGIS-enabled postgreSQL database

Things are running smoothly for simple map creation.  I can edit maps, add 
PostGIS layers, etc. easily.  But I'm just a bit stumped when it comes to 
making the map file's DATA attribute a variable and passing a SQL query 
string to it.

My ultimate goal is to take user input (in the form of dropdown lists - but 
for right now I'm using a simple text box), create a query string from this 
input, and then use it as the DATA attribute.

So far, I have made a form element in the file automatically created by 
gMap Factory ( <project_name>_contents.php ) which adds the string :

sqlstring="the_geom from postgis_table"

to the URL when a submit button is clicked.

How can I get this string to be the DATA attribute in my <project_name>.map 
file?

The "MapServer MapFile Reference" mentions the ability to use variable 
substitution in map files, which seems like the best route to 
take.  However, it also states that "if you are using MapScript, you will 
have to code the substitution logic in your application yourself (By 
writing your own pre-processor)."

I've found a few references here and there that touch on using percent 
signs to create a variable like %DATA% in the map file, but no concrete 
examples on how to actually pass the data to such a variable using 
something like MapScript.

Does anybody have some insight?

Thanks a ton.

--Damon
brog at mail dot utexas dot edu



More information about the mapserver-users mailing list