ThinkGeo.com    |     Documentation    |     Premium Support

GetFeatureInfo request with WmsRasterLayer

Hi,


 


I am using your LoadAWmaImage.xaml.cs from How DoISamples (Satellite Image) to acces to my local WMS server and get features.


My code looks like:



private void MyLayer()
        {
            wpfMap1.Overlays.Clear();
            wpfMap1.CurrentExtent = new RectangleShape(-122.3425, 37.8233, -122.2537, 37.8011);
            WebProxy wP = new WebProxy("127.0.0.1", 8888);
            WmsRasterLayer wmsImageLayer = new WmsRasterLayer(new Uri("172.16.6.9:8080/geoserver/amazon/wms"), wP);
            wmsImageLayer.UpperThreshold = double.MaxValue;
            wmsImageLayer.LowerThreshold = 0;
            wmsImageLayer.Open();

            wmsImageLayer.ActiveLayerNames.Add("wgs_1984_PolylineCamera_1");
            wmsImageLayer.Exceptions = "application/vnd.ogc.se_xml";

            LayerOverlay staticOverlay = new LayerOverlay();
            staticOverlay.Layers.Add("wmsImageLayer", wmsImageLayer);
            wpfMap1.Overlays.Add(staticOverlay);
            wmsImageLayer.Close();

            wpfMap1.Refresh();
        }
private void wpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e)
        {
            try {
                LayerOverlay layerOverlay = (LayerOverlay)wpfMap1.Overlays[0];
                ScreenPointF sp = new ScreenPointF((float)e.ScreenX, (float)e.ScreenY);
                WmsRasterLayer wL = (WmsRasterLayer)layerOverlay.Layers[0];
                Dictionary<String, Collection<Feature>> ft = wL.GetFeatureInfo(sp, "text/html", 16);
                Debug.Write("vsm7wms: ft" + ft.Count);
            } catch(Exception ex) {
                Debug.Write("vsm7wms:" + ex.Message.ToString());
            }
        }

Howewer, when I click on map it send malformed WMS request:


GET 172.16.6.9:8080/geoserver/amazon/wms?&SERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=1.1.1&LAYERS=wgs_1984_PolylineCamera_1


&QUERY_LAYERS=wgs_1984_PolylineCamera_1&STYLES=


&BBOX=-122.313537597656,37.8025817871094,-122.312164306641,37.803955078125


&FEATURE_COUNT=16&WIDTH=256&HEIGHT=256&FORMAT=image/png


&INFO_FORMAT=text/html&SRS=EPSG:4326&X=268&Y=451 


As you can see: WIDTH=256&HEIGHT=256 but X=268&Y=451 


So, WMS server responce: <ServiceException code="InvalidPoint"> 268, 451 not in dimensions of image: 256, 256 


What I am doing wrong ?


Thank you,


MIchael


 


 


 




 


 


 



Hi Michael,  
  
 I am guessing that your map size is not 256x256. Perhaps set these values on the Properties of the Map and then pass a HEIGHT and WIDTH value that matches these values with your request. There is a Parameters collection off of the wmsRasterLayer that you can add in your own values with.

 Hi Ryan,


 


I am confused: I am working with WMS server that return tiles 256x256 and, of course, my map has more than 1 tiles. I am supplying screen coordinates which by definition could be beyound one tile and need to be modified to be relative of current tile.


Howewer, I did tryed your sugestion and set:



            wmsImageLayer.Parameters["WIDTH"] = "256"; wmsImageLayer.Parameters["HEIGHT"] = "256";


But nothing changed:



GET 172.16.6.9:8080/geoserver/amazon/wms?&SERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=1.1.1&LAYERS=wgs_1984_PolylineCamera_1&


QUERY_LAYERS=wgs_1984_PolylineCamera_1&STYLES=&


BBOX=-122.431640625,37.8369140625,-122.3876953125,37.880859375&FEATURE_COUNT=16&


WIDTH=256&HEIGHT=256&FORMAT=image/png&INFO_FORMAT=text/html&SRS=EPSG:4326&


X=507&Y=424 HTTP/1.1


 


BTW: I am found workaround - it works if I am using WFS server.


Thank you,


Michael


 




 



Hi Michael, 



Thanks for your feedback and I am glad to hear it is working for you. If you are connecting to a WFS server you might try our WFSFeatureLayer.