[mapserver-users] Layer Object Parameter Substitution fromURLusing GIS
Steve Lime
Steve.Lime at dnr.state.mn.us
Wed Apr 8 07:17:34 PDT 2009
This one answers your previous question about escaping characters. ;-)
You need to
use the ascii escape sequences in a URL.
Anyway, you're running up against the security controls in place in 5.4.
Basically you
don't want someone setting a filter to just anything. So, you *must*
define a validation
pattern before MapServer will allow the change. This is done via a
VALIDATION block.
In your case you'd do something like this in the psc layer:
LAYER
NAME 'psc'
...
VALIDATION
filter '^orbitnr=[0-9]{1,5}$'
END
...
END
This says that filter can be set via a URL but only if it matches the
pattern above. Guessing
based on your sample this says the filter must be of the form
"orbitnr=an integer (1 to 5 digits)"
so "orbitnr=12345" will work "orbitnr=abcd" will not.
You can set a far more general pattern (e.g. '.' matches anything) but I
recommend against it.
Steve
>>> Heiko Schröter <schroete at iup.physik.uni-bremen.de> 04/08/09 4:04 AM
>>>
On Dienstag, 7. April 2009 15:52:10 you wrote:
Hello Steve,
this seem to fail as well. Funny enough i needed to change the
Layernames to
uppercase in OpenLayer. But anyway:
<snip>
var kartenstring = "karte,grid,psc";
var somevalue = "FILTER+'orbitnr=4567' ";
layer = new OpenLayers.Layer.WMS( "IUP WMS",
"http://kahlo1/cgi-bin/mapserv",
{map:'/home/schroete/sciadaten/MapServer/country98/heiko1.map',
layers: kartenstring,
"map.layer[PSC]": somevalue},
{singleTile:true});
<snap>
The relevant part of the generated URL:
...&LAYERS=karte%2Cgrid%2CPSC&MAP.LAYER%5BPSC%5D=FILTER%2B%27orbitnr%3D4567%27&...
I've tried various \' inside somevalue, but that won't change a thing.
Backslashing the + sign won't change thing as well.
And mapserver fails. The output from DEBUG 5 is as follows:
[Wed Apr 8 10:52:31 2009].104328 getSymbol(): Symbol definition error.
Parsing
error near (+):(line 1)
or
[Wed Apr 8 10:51:24 2009].324130 loadLayer(): General error message.
URL-
based FILTER configuration failed pattern validation.
Depending on what you have changed in someval.
Regards
Heiko
> 2) Setting extra vars in OpenLayers is easy. Something like this would
> work:
>
> myLayer = new OpenLayers.Layer.MapServer(
> 'stuff',
> 'http://some.site.com/cgi-bin/mapserv?map=/some/mapfile.map',
> { layers:'stuff', map_transparent: 'true',
> somevar: 'somevalue',
> },
> { ratio:1, singleTile:true, transitionEffect:'resize',
> isBaseLayer:false }
> );
More information about the MapServer-users
mailing list