WMS problem

Topics: WinForms Controls
Mar 24 at 2:01 PM
Edited Mar 24 at 2:31 PM
Hi ! I'm trying to add a wms layer to my project and it doesn't work. I have modified the code in TiledWmsSample of sharpmap sample to :
string wmsUrl = "http://geo.weather.gc.ca/geomet/?lang=E&service=WMS&request=GetCapabilities"; 
WmsLayer layWms = new WmsLayer("WMS", wmsUrl);
layWms.AddLayer("RADAR_RRAI");
layWms.AddLayer("RADAR_RSNO");
layWms.Version = "1.3.0";
layWms.SetImageFormat(layWms.OutputFormats[0]);
layWms.ContinueOnError = true;
layWms.TimeOut = 50000; //Set timeout to 5 seconds
layWms.SRID = 4326;
map.Layers.Add(layWms);
map.ZoomToExtents();
return map;
In the console Windows, looks like I'm having a response but my map is blank.

[DEBUG] SharpMap.Layers.WmsLayer - Beginning request
[DEBUG] SharpMap.Layers.WmsLayer - Got response
[DEBUG] SharpMap.Forms.MapBox - 2016/03/24 09:53:19: 2 - Env[-180 : 180, -103.41013824884793 : 103.41013824884793]
[DEBUG] SharpMap.Forms.MapBox - 2016/03/24 09:53:19: 2 - Env[-180 : 180, -103.41013824884793 : 103.41013824884793]

All others WMS sample code I could find and try works fine. Any quick idea ???

PS. Just to mention, the WMS link works fine in arcMap

Thanks :-)
Coordinator
Mar 29 at 7:55 AM
The problem is that the server returns "IMAGE/PNG" as content type whereas SharpMap's WmsLayer expects the content type string being all lowercase.
Mar 29 at 1:00 PM
Oh.. And where did you noticed that ?? I ran the code step by step trying to find something... In case it happend again !!

I guess it is not in the URL because it returns

http://geo.weather.gc.ca/geomet/?REQUEST=GetMap&BBOX=-180,-103.410138248848,180,103.410138248848&WIDTH=651&Height=374&Layers=RADAR_RRAI,RADAR_RSNO&FORMAT=image/png&SRS=EPSG:4326&VERSION=1.1.1&Styles=&TRANSPARENT=True

And is it something I can fix in code to make it work ??

Thanks FObermaier...
Coordinator
Mar 29 at 1:17 PM
it is in this line:
https://github.com/SharpMap/SharpMap/blob/Branches/1.0/SharpMap/Layers/WmsLayer.cs#L626

You need to change it to
if (dataStream != null && myWebResponse.ContentType.ToLowerInvariant().StartsWith("image"))