changing DATA parameter in mapfile via URL

Ken Lord kenlord at GMAIL.COM
Thu Apr 21 17:32:08 PDT 2005


Hi Dylan, 

In addition to Steve's comments,  

If your data source is PostGIS, the DATA %thefile% system works great
for modifying query statements used in your DATA parameter on the fly
in CGI mapserver, allowing you to make tools where your user can
choose from a set of spatial analysis functions or settings whose
results are symbolized by that layer's settings.

For example a layer set to show all X's within 100m of Y could be
reset by the user to find all X's within some other distance of Y, or
another function could be used, such as all X's contained by Y where
attribute Z=foo.  ... or whatever type of spatial / attribute query
you need so long as it doesnt bog your server down in processing.

Using javascript or an ASP redirect (or whatever your choice of
method) to parse the appropriate string into your "&thefile=xxxxx"
variable in the URL. or the <input type='hidden' name='thefile'
value="xxxxx"> form submission.

It adds some real GIS abilities to mapserver without very much effort.

Cheers,
Ken Lord
Vancouver BC
 

On 4/21/05, Steve Lime <steve.lime at dnr.state.mn.us> wrote:
> For security reasons we don't allow that by default. You have to set the
> DATAPATTERN
> parameter in the mapfile first. The pattern is nothing more than a
> regular expression that
> will limit the values that DATA can take. For example:
> 
>  DATAPATTERN "xxx|yyy|zzz"
> 
> will allow ...&map_layername_data=xxx.shp but not
> ...&map_layername_data=sss.shp.
> 
> Another option is using runtime substitutions. In your layer definition
> you'd have something
> like:
> 
>  LAYER
>    DATA %thefile%
>    ....
>  END
> 
> and then you'd set a CGI variable called 'thefile' to hold the name of
> a shapefile. If you do the
> whole filename as just a single variable you have the hole that
> DATAPATTERN was put in place
> to plug. You'd probably want to use the %thefile% as part of a longer
> file name instead which
> would be moderately safe.
> 
> Steve
> 
> >>> Dylan Beaudette <dylan at IICI.NO-IP.ORG> 4/21/2005 4:48:44 PM >>>
> Is is possible to change the 'DATA' parameter via a URL-style variable
> such
> as:
> 
> ...&map_layername_data="xxx.shp"
> 
> i am able to change every other property of this layer, but not its
> data
> source.
> 
> if this is not possible, does anyone know of some kind of work-around?
> 
> i am trying to use a single map file for numerous different shape
> files...
> 
> thanks in advance!
> 
> --
> Dylan Beaudette
> Soils and Biogeochemistry Graduate Group
> University of California at Davis
> 530.754.7341
>



More information about the MapServer-users mailing list