[mapserver-users] Variable-substitution cause WMS GetFeatureInfo error

Stephan Holl stephan.holl at intevation.de
Thu Aug 27 01:52:22 PDT 2009


Hello AlessioDL,

AlessioDL <alessio.dilorenzo at gmail.com>, [20090827 - 03:41:33]

> 
> I post the my code... hope this "helps to help" :-)
> 
> Mapfile layer:
> 
>           LAYER
>                 NAME 			"QueryAreas"
> 		TYPE 			POLYGON
> 		CONNECTIONTYPE 	postgis
> 		CONNECTION		"host=localhost
> user=***password=*** dbname=***"
> DATA			"the_geom FROM (SELECT * FROM areas)AS
> foo USING UNIQUE gid USING SRID=4326" FILTER
> 			"YEAR = %YEAR%" METADATA
> 			"wms_title"
> 					"Query Areas"
> "wms_include_items" 			"all"
> "wms_exclude_items"			"the_geom" END
> 		DUMP TRUE
> 		STATUS ON
> 		TRANSPARENCY ALPHA
> 		CLASS
> 			TEMPLATE
> 		"../TemplateMS/areas.html" NAME "Areas"
> 			STYLE
> 				SYMBOL 		 "simpleline"
> 				SIZE		 2
> 				OUTLINECOLOR 0 0 0
> 				COLOR		 255 127 36
> 			END #Style end
> 		END #Class end
> 	END #Layer end
> 
> OpenLayers code:
> 
> [code]
> var map, qAreas, year;
> var wmsURL =
> "http://correggiov3/cgi-bin/mapserv.exe?map=/ms4w/apps/caps_manager/Mapfiles/wms.map";
> var cgiURL = "http://correggiov3/cgi-bin/mapserv.exe?";
> var proj4326 = new OpenLayers.Projection("EPSG:4326");
> var proj900913 = new OpenLayers.Projection("EPSG:900913");
> 
> 
> function initMap(){
>     
> 	OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
> 	OpenLayers.Util.onImageLoadErrorColor = "transparent";
> 	
> 	startBounds = new
> OpenLayers.Bounds(1297594.634132,5197717.568058,2178149.1998195,5818997.7338486);
> 	
>     options = {
> 	    controls:[],
> 	    projection: new OpenLayers.Projection("EPSG:900913"),
> 	    displayProjection: new OpenLayers.Projection("EPSG:4326"),
> 	    units: "m",
> 	    numZoomLevels: 18,
> 	    maxResolution: 156543.0339,
> 	    maxExtent: new
> OpenLayers.Bounds(-20037508,-20037508,20037508,20037508.34)
>     };
>     
>     map = new OpenLayers.Map('map', options);
>     
>     // create Google Mercator Layers
>     var gphy = new OpenLayers.Layer.Google("Google Terrain",{type:
> G_PHYSICAL_MAP, 'sphericalMercator': true});
>     var gmap = new OpenLayers.Layer.Google("Google
> Streets",{'sphericalMercator': true});
>     var gsat = new OpenLayers.Layer.Google("Google Satellite",{type:
> G_SATELLITE_MAP, 'sphericalMercator': true});
>     var ghyb = new OpenLayers.Layer.Google("Google Hybrid",{type:
> G_HYBRID_MAP, 'sphericalMercator': true};
>     
>     
>     // add Layers array
>     map.addLayers([gphy,gmap,gsat,ghyb]);
>     
>     // add simple Controls
>     map.addControl(new OpenLayers.Control.LayerSwitcher());
>     map.addControl(new OpenLayers.Control.MousePosition(/*{div:
> $('coord')}*/));
>     map.zoomToExtent(startBounds);
>     
>    /*
>     * GetFeatureInfo - Pupup
>     * **********************
>     */
>     
>     var info = new OpenLayers.Control.WMSGetFeatureInfo({
>         url:
> "http://correggiov3/cgi-bin/mapserv.exe?map=/ms4w/apps/caps_manager/Mapfiles/wms.map", 
>         title: 'Identify features by clicking',
>         queryVisible: true,
>         eventListeners: {
>             getfeatureinfo: function(event) {
>                 map.addPopup(new OpenLayers.Popup.FramedCloud(
>                     "chicken", 
>                     map.getLonLatFromPixel(event.xy),
>                     null,
>                     event.text,
>                     null,
>                     true
>                 ));
>             }
>         }
>     });
>     map.addControl(info);
>     info.activate();
> 
> } //end initMap
> 
> /*
>  * Add the filtered layer
>  * **********************
>  */
> function addQueryLayers(){
> 	
> 	year = document.forms['queryForm'].elements["year"].value;
> 	areaType =
> document.forms['queryForm'].elements["areaType"].value;
> 
> 	qAreas = new OpenLayers.Layer.WMS("Selected areas", wmsURL, {
> 		map:"/ms4w/apps/caps_manager/Mapfiles/wms.map",year:year,
> 		layers: 'QueryAreas',
> 		format:'image/png',
> 		transparent:'true'
> 	}, {'isBaseLayer':false});
>     
> 	map.addLayer(qAreas);
> 
> }
> [/code]

I cannot see the Variable year passing to the getfeatureInfo-Request.

You should verify if the getfeatureinfo-request ist built correct by
openlayers. Using a handcraftet getfeatureinfo-request with the
filter-attribute should work.

HTH

	Stephan

-- 
Stephan Holl <stephan.holl at intevation.de> | Tel.: +49 (0)541-33 508 3663
Intevation GmbH, Neuer Graben 17, 49074 OS  |  AG Osnabrück - HR B 18998
Geschäftsführer:  Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20090827/f31f542e/attachment.sig>


More information about the MapServer-users mailing list