[mapserver-users] Dynamic shapepaths

Steve Lime Steve.Lime at dnr.state.mn.us
Mon Aug 17 22:09:53 PDT 2009


5.4+ does not allow changing the shapepath via URL. That ability was removed for
securities sake. It could be restored relatively easily, let me know if you need a patch.

An alternative is to use a runtime variable and validation for the DATA parameter. For
example:

LAYER
  DATA '%base%/myShapefile'
  METADATA
    base_validation_pattern 'some regex to limit the value of base'
  END
  ...
END

In this case you'd set &base=some path...& in your URLs.

Steve

>>> Ethan Gruber <ewg4xuva at gmail.com> 08/17/09 11:00 AM >>>
Hi,

I'm working on migrating a ten year old mapserver project to the current
version of mapserver on a new system.  It involves a lot of changes in
scripts and querying parameters to synchronize with mapserver 5.4.2.  I've
run into an issue where the shapepath is generated dynamically with a perl
script.  A call to mapserver (it was version 4.x at the time) passes a
parameter called map_shapepath, and map_shapepath is equal to the
dynamically generated path.

In the .map file for the project, the SHAPEPATH variable in MAP is commented
out.  I read that in the current version, if SHAPEPATH is not defined, the
default is the folder that the .map file currently resides in.  Indeed,
mapserver is unable to find the .shp file within the same folder as the .map
file.  Here is my error:

"msDrawMap(): Image handling error. Failed to draw layer named 'theme'.
msShapefileOpen(): Unable to access file.
(/var/www/html/mapservr/HUSCO/histcen.shp) msShapefileOpen(): Unable to
access file. (/var/www/html/mapservr/HUSCO/histcen.shp)"

If I uncomment SHAPEPATH and define path that actually contains a proper
shapefile, the script presumably works (because it moves to the next error,
which is related to the template.html).

So my question is: how can I define the shapepath dynamically with a
parameter passed through the browser?  Has the "map_shapepath" param simply
changed names to something else?  I can't find any documentation on this.

Thanks!

Ethan Gruber
University of Virginia Library




More information about the MapServer-users mailing list