ThinkGeo.com    |     Blog    |     Wiki    |     Support

WmsRasterLayer / Error=The parameter you supplied may be null

Hi,

I have a problem with a WmsRasterLayer.
The name of the uri is https://services.sandre.eaufrance.fr/geo/zrpe?REQUEST=getCapabilities&service=WMS

You can see the result with this link http://www.sandre.eaufrance.fr/atlas/srv/fre/catalog.search#/map. (Osm is basemap and one layer Wms)
I’m trying to get this result in my project with thinkgeo but I have a system error.

Step 1 :
When I test the wms Sandre layer with this configuration, I visualize the map in my project (ie WmsLayerCrs4326.JPG)

MapWiuz.MapUnit = GeographyUnit.DecimalDegree;
MapWiuz.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColors.White);

var layerOverlay = new LayerOverlay();
var uri = new Uri("https://services.sandre.eaufrance.fr/geo/zrpe?REQUEST=getCapabilities&service=WMS");

var wmsRasterLayer = new WmsRasterLayer(uri);
wmsRasterLayer.ActiveLayerNames.Add("ZoneVuln_com_FXX");
wmsRasterLayer.Crs = "EPSG:4326";
wmsRasterLayer.OutputFormat = "image/png";
wmsRasterLayer.Parameters.Add("EXCEPTIONS", "xml");
wmsRasterLayer.Parameters.Add("TRANSPARENT", "TRUE");
wmsRasterLayer.ActiveStyleNames.Add("default");

layerOverlay.Layers.Add("ZoneVul", wmsRasterLayer);
MapWiuz.Overlays.Add(layerOverlay);        
wmsRasterLayer.Open();
MapWiuz.CurrentExtent = wmsRasterLayer.GetBoundingBox();
MapWiuz.Refresh();

Step 2: I add the OSM background.
It is at this stage that I have concerns.
Osm is in projection 3857 with meters and Sandre is in 4326 and DecimalDegree
The configuration of my map is as follows:

  MapWiuz.MapUnit = GeographyUnit.Meter;
MapWiuz.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColors.White);

var layerOverlay = new LayerOverlay();
var uri = new Uri("https://services.sandre.eaufrance.fr/geo/zrpe?REQUEST=getCapabilities&service=WMS");

var wmsRasterLayer = new WmsRasterLayer(uri);
wmsRasterLayer.ActiveLayerNames.Add("ZoneVuln_com_FXX");
wmsRasterLayer.Crs = "EPSG:3857";
wmsRasterLayer.OutputFormat = "image/png";
wmsRasterLayer.Parameters.Add("EXCEPTIONS", "xml");
wmsRasterLayer.Parameters.Add("TRANSPARENT", "TRUE");
wmsRasterLayer.ActiveStyleNames.Add("default");
		
var osm = new OpenStreetMapLayer();

layerOverlay.Layers.Add("osm", osm);
layerOverlay.Layers.Add("ZoneVul", wmsRasterLayer);
MapWiuz.Overlays.Add(layerOverlay);

try
{
	wmsRasterLayer.Open();
	 MapWiuz.CurrentExtent = wmsRasterLayer.GetBoundingBox();
	MapWiuz.Refresh();
}

And I have a following error:
System.ArgumentNullException
HResult=0x80004003
Message=The parameter you supplied may be null.
Nom du paramètre : targetShape
Source=ThinkGeo.MapSuite.Wpf
Arborescence des appels de procédure :
à ThinkGeo.MapSuite.Wpf.Tile.DrawException(GeoCanvas geoCanvas, Exception exception)
à ThinkGeo.MapSuite.Wpf.Tile.Draw(GeoCanvas geoCanvas)
à ThinkGeo.MapSuite.Wpf.Tile.WlY=(Object status)
à System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
à System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
à System.Threading.ThreadPoolWorkQueue.Dispatch()
à System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

I’m doing the test with Qgis and I can have an Osm basemap and the Wms Sandre layer on top. (see screen shot WmsLayer_Osm_Qgis.JPG)

When I retrieve the Qgis query with Fiddler, the sent crs is 3857 and I get the following query.

GET /geo/zrpe?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=-1755538.633639884414,4915264.179941010661,2092250.699577764841,7123412.148591595702&CRS=EPSG:3857&WIDTH=1577&HEIGHT=905&LAYERS=ZoneVuln_com&STYLES=&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT= TRUE HTTP / 1.1

Are you able to reproduce my problem ?
Have you ever encountered this kind of problem?

Thanks a lot for your help.

Regards.

Steph.

Hi Stephanie,

The reason is your capability file don’t have bounding box for other projection, so it throw exception after parse capability file.

The solution is you set that manual, please refer the sample as below:

9572.zip (101.7 KB)

Regards,

Ethan

Hi Ethan,

Thank you, it worked.

Regards.

Steph.

Hi Stephanie,

I am glad to hear that works.

Regards,

Ethan