Changing map file parameters

Stephen Lime steve.lime at dnr.state.mn.us
Wed Mar 22 16:09:57 EST 2000


Interesting problem. If all you want is the image then there is no need to
have another form. I assume you want some of the values in the expression
filed in and others left alone. (note: you don't have to provide a CLASSITEM
with logical expressions, it's ignored)

The problem is that MapServer sees the [DOWNSTREAM] and wants to 
replace it. One workaround might be to escape the []'s. Your page could
contain:

<img src="/cgi-bin/mapserv.exe?map=[map]&mapext=[mapext]&map_layer_0_class_expression=((&#91;DOWNSTREAM&#93;&#32;ge&#32; [FROM_DON_])&#32;and&#32;&#91;DOWNSTREAM&#93;&#32;le&#32;[TO_DON_]))&map_layer_0_class_color=255&#32;255&#32;255&mode=map">

In theory ;-) this should be the image you describe. It looks ugly but what I did is pretty
simple. Spaces and []'s  got replaced by their appropriate HTML escape sequences. [TO_DON_]
and [FROM_DON_] will be replaced by the MapServer but [DOWNSTREAM] won't since
it's not escaped. Note the mode=map at the end. It tells MapServer to only kick out the image
and nothing else.

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> <bfischer at usgs.gov> 03/22/00 10:09AM >>>
Hello mapserv users,

I am trying to change map file parameters on the fly.  I understand I have
to use form variables, but there is not much documentation on how to use
them.  Here is what I am trying to do.  I have a polygon coverage of
watersheds.  The user selects a watershed by a mouse click.  From this I am
able to acess all the attributes from that polygon.  Now I want to use this
polygon's attributes to form a class expression and query expression on the
same polygon shapefile.   The output I need is a map with all the polygons
highlighted that got selected in the class expression.  Here is the HTML
code I am using, am I doing something wrong?  All it returns is the image
from the previous point query.  One problem I noticed is the [DOWNSTREAM],
[FROM_DON_], and [TO_DON_] get turned into the values of the polygon's
attributes that got selected from the mouse click.


 <form name="query_map" method="GET" action="/cgi-bin/mapserv.exe">
   <input type="hidden" name="map" value="[map]">
   <input type="hidden" name="imgext" value="[mapext]">
   <input type="hidden" name="map_layer_0_classitem" value="DOWNSTREAM">
   <input type="hidden" name="map_layer_0_class_expression" value
=(([DOWNSTREAM] ge [FROM_DON_]) and [DOWNSTREAM] le [TO_DON_]))">
   <input type="hidden" name="map_layer_0_class_color" value="255 255 0">
   <imput type="image" name="img" src="../watershed/temp_mapserv/[img]"
border="0">
   </form>

Does any onw have any suggestions?  Would this also be possible to do with
a URL instead of form variables?

Thanks,

Brian Fischer
bfischer at usgs.gov 
USGS WRD
2280 Woodale Dr.
Mounds View, MN
(612) 783-3133






More information about the mapserver-users mailing list