[mapserver-users] Layer Object Parameter Substitution fromURLusing GIS

Steve Lime Steve.Lime at dnr.state.mn.us
Tue Apr 7 06:52:10 PDT 2009


Hi Heiko: Two things:

1) There's an error in your URL. The syntax should be something like:

  map.layer[psc]=FILTER+'orbitnr=6758'

but you'd need to escape the ' and = characters in the URL.

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 }
  );

You can then modify the content of the 'somevar' variable. With code
like:

  myLayer.params.somevar = 'somenewvalue';

This will tag somevar=somenewvalue onto the URL passed to MapServer.

Steve

>>> Heiko Schröter <schroete at iup.physik.uni-bremen.de> 04/07/09 5:26 AM
>>>
On Montag, 6. April 2009 19:57:19 you wrote:

Hello,

the error seems to remain in mapserver 5.4:

/usr/lib/cgi-bin/mapserv -v
MapServer version 5.4.0-beta4 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG
OUTPUT=WBMP 
OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=ICONV
SUPPORTS=WMS_SERVER 
INPUT=TIFF INPUT=EPPL7 INPUT=JPEG INPUT=POSTGIS INPUT=SHAPEFILE

http://localhost/cgi-bin/mapserv?
MAP=/home/schroete/sciadaten/MapServer/country98/heiko1.map&
LAYERS=karte,grid,psc&SERVICE=WMS&VERSION=1.1.1&
REQUEST=GetMap&STYLES=&
FORMAT=image/png&SRS=epsg:4326&BBOX=-180,-90,180,90&
WIDTH=600&HEIGHT=300&
map.layer[psc].filter='orbitnr=6758'

loadLayer(): Unknown identifier. Parsing error near (orbitnr=6758):(line
1) 


Mapfile as below. The map is ok without the 'map.layer[]...'  stuff.

Does a kind soul knows howto do the runtime substitution from within
OpenLayer 
(i know it is not the 100% correct list, but maybe someone has hit this 
before).

Regards
Heiko


> You'll need to use 5.4 to get this functionality. That version add
> support to allow you to define
> validation strings to lock down what values can be passed for the
> variable. Another solution is
> to consider using runtime substitution to do something similar. That
> works well if the SQL is
> pretty much fixed:
>
>  FILTER 'wert=%myval%'
>
> It's also easier to secure.
>
> Steve
>
> >>> On 4/6/2009 at 4:01 AM, in message
>
> <200904061101.54781.schroete at iup.physik.uni-bremen.de>, Heiko Schröter
>
> <schroete at iup.physik.uni-bremen.de> wrote:
> > Hello,
> >
> > when passing a 'FILTER' parameter to be changed with the URL to use
>
> GIS
>
> > requests, mapserv(5.0.3) fails with:
> > loadLayer(): Unknown identifier. Parsing error near (FILTER):(line
>
> 1)
>
> > The call is:
> >
> >
http://localhost/cgi-bin/mapserv?MAP=/MapServer/country98/heiko1.map&
> >
> > LAYERS=karte,grid,psc&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&
> > STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&
> > FORMAT=image/png&
> > SRS=epsg:4326&BBOX=-180,7.91,-82.08,105.83&
> > WIDTH=256&HEIGHT=256&
> > MAP.LAYER[psc].FILTER='wert=0'
> > (Linebreaks included for readability)
> >
> > When omitting this part: " MAP.LAYER[psc].FILTER='wert=0'  "  the
map
>
> is
>
> > generated fine (without the proper GIS data of course).
> >
> > I did read several comments in the archive and the net about this
>
> issue but
>
> > haven't found a solution to this problem.
> > What do i miss here ?
> >
> > Thanks and Regards
> > Heiko
> >
> >
> > The Mapfile:
> > MAP
> > 	NAME WELT
> >         DEBUG ON
> > 	STATUS ON
> > 	#SIZE 647 320
> >         SIZE 800 400
> > 	IMAGETYPE PNG24
> > 	IMAGECOLOR 240 240 240
> > 	SHAPEPATH "data"
> >         EXTENT -180 -90 180 90
> > 	UNITS DD
> > 	WEB
> > 		IMAGEPATH "images"
> > 		IMAGEURL "images"
> > 		MINSCALE 50000
> > 		MAXSCALE 400000000
> > 		METADATA
> > 			"wms_title" "Example WMS Server"
> > 			"wms_onlineresource"
>
> "http://localhost/cgi-bin/mapserv?map=heiko.map&"
>
> > 			"wms_srs" "epsg:4326 epsg:32661 epsg:32761"
> > 		END
> > 	END
> > 	SYMBOL
> > 		NAME 'circle'
> > 		TYPE ELLIPSE
> > 		POINTS 1 1 END
> > 		FILLED TRUE
> > 	END
> > 	SYMBOL
> > 		NAME 'star'
> > 		TYPE VECTOR
> > 		FILLED TRUE
> > 		POINTS
> > 		      0 .375
> > 		      .35 .375
> > 		      .5 0
> > 		      .65 .375
> > 		      1 .375
> > 		      .75 .625
> > 		      .875 1
> > 		      .5 .75
> > 		      .125 1
> > 		      .25 .625
> > 		END
> > 	END
> > 	PROJECTION
> > 		"init=epsg:4326"
> > 	END
> > 	LAYER
> > 		NAME "karte"
> > 		TYPE POLYGON
> > 		STATUS ON
> >                 OPACITY 50
> > 		DATA "cntry98"
> >                 METADATA
> >                   "wms_title" "karte layer"
> >                   "DESCRIPTION" "Grid"
> >                 END
> > 		PROJECTION
> > 		    "init=epsg:4326"
> > 		END
> > 		CLASS
> > 			NAME "karte_color"
> > 			OUTLINECOLOR 60 60 60
> > 			COLOR 100 100 100
> > 			SYMBOL 0
> > 		END
> > 	END
> > 	LAYER
> > 	   NAME "grid"
> > 	   OPACITY 60
> > 	   METADATA
> > 		"wms_title" "grid layer"
> > 		"DESCRIPTION" "Grid"
> > 	   END
> > 	   TYPE LINE
> > 	   STATUS ON
> > 	   PROJECTION
> > 		"init=epsg:4326"
> > 	   END
> > 	   CLASS
> > 		NAME "Graticule"
> > 		COLOR 0 0 0
> > # Labels comented out for readabilty in the moment
> > #		LABEL
> > #			COLOR 0 0 0
> > #			#FONT "fritqat"
> > #			#TYPE truetype
> > #                        MINDISTANCE 1000
> > #			SIZE SMALL
> > #			POSITION LR
> > #			PARTIALS FALSE
> > #			BUFFER 5
> > #			OUTLINECOLOR 200 200 200
> > #		END
> > 	   END
> > 	   GRID
> > 		LABELFORMAT "DD"
> > 		# LABELFORMAT '%g°' # dec degrees with symbol
> >                 # MINARCS 1
> > 		MAXARCS 1
> >                 MININTERVAL 30
> > 		MAXINTERVAL 60
> > 		# MINSUBDIVIDE 100
> > 		MAXSUBDIVIDE 300
> > 		# LABELFORMAT ’%7.0f m’ # nice if a projected SRS
>
> used
>
> > 		# MININTERVAL 20000
> > 		# MAXSUBDIVIDE 2
> > 	   END
> >  	END # Layer
> >
> > 	LAYER
> > 		NAME "psc"
> > 		CONNECTIONTYPE POSTGIS
> > 		OPACITY 80
> > 		STATUS ON
> > 		METADATA
> > 			"wms_title" "psc layer"
> > 		END
> > 		PROJECTION
> > 			"init=epsg:4326"
> > 		END
> > 		CONNECTION "user=fum password=xyz dbname=foo
>
> host=localhost"
>
> > 		DATA "geocenter from scia_psc"
> > 		FILTER "wert=1"
> > 		TYPE POINT
> > 		CLASS
> > 			COLOR 250 10 10
> > 			SYMBOL "circle"
> > 			SIZE 7
> > 		END
> >         END
> > 	LAYER
> > 		CONNECTIONTYPE POSTGIS
> > 		NAME "nlc"
> > 		OPACITY 80
> > 		STATUS ON
> > 		METADATA
> > 			"wms_title" "nlc layer"
> > 		END
> > 		PROJECTION
> > 			"init=epsg:4326"
> > 		END
> > 		CONNECTION "user=fum password=xyz dbname=foo
>
> host=localhost"
>
> > 		DATA "geocenter from scia_nlc"
> > 		FILTER "wert=1"
> > 		TYPE POINT
> > 		CLASS
> > 			COLOR 10 250 10
> > 			SYMBOL "star"
> > 			SIZE 7
> > 		END
> > 	END
> > 	LAYER
> > 		CONNECTIONTYPE POSTGIS
> > 		NAME "stro3"
> > 		OPACITY 80
> > 		STATUS ON
> > 		METADATA
> > 			"wms_title" "stro3 layer"
> > 		END
> > 		PROJECTION
> > 			"init=epsg:4326"
> > 		END
> > 		CONNECTION "user=fum password=xyz dbname=foo
>
> host=localhost"
>
> > 		DATA "geocenter from scia_stro3"
> > 		FILTER "wert=1"
> > 		TYPE POINT
> > 		CLASS
> > 			COLOR 10 10 250
> > 			SYMBOL "circle"
> > 			SIZE 7
> > 		END
> > 	END
> > END # Ende Map
> >
> > _______________________________________________
> > mapserver-users mailing list
> > mapserver-users at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users




More information about the MapServer-users mailing list