ThinkGeo.com    |     Documentation    |     Premium Support

WMS not loaded in V12

Hi,

we could not load WMS
http://www.gds-srv.hessen.de/cgi-bin/lika-services///ogc-free-maps.ows?language=ger&

format=image/png
active layer=adv_alk
epsg=25832

My code for loading in V10 looks like:

Public Function LoadWmsRasterLayer(uri As Uri, epsg As Integer) As WmsRasterLayer
        Try
            Dim wmsLayer As WmsRasterLayer = New WmsRasterLayer(uri)
            With wmsLayer

                .ActiveLayerNames.Add("adv_alk")
                
                .Parameters.Add("transparent", "true")
                .Crs = String.Format("EPSG:{0}", epsg)
                .OutputFormat = "image/png"

                .Exceptions = "INIMAGE"

                .ImageSource.ProjectionConverter = GetProjection4(epsg)
                .Open()

            End With
            Return wmsLayer
        Catch ex As Exception
            c_lastError = String.Format("Fehler beim Laden des Layer {0}. {1}", uri, ex.Message)
            Return Nothing
        End Try
    End Function

In V12 nothing is displayed.

Need help!

Regards
Hardy

Thanks Hartwig,
We need set the layerOverlay.TileType = TileType.SingleTile;

Here is the full code.

 private void Form1_Load(object sender, EventArgs e)
        {

            map.MapUnit = GeographyUnit.DecimalDegree;

            LayerOverlay layerOverlay = new LayerOverlay();
            WmsRasterLayer wmsLayer = new WmsRasterLayer(new Uri("http://www.gds-srv.hessen.de/cgi-bin/lika-services///ogc-free-maps.ows?language=ger&"));
            wmsLayer.ActiveLayerNames.Add("adv_alk");
            wmsLayer.Parameters.Add("transparent", "true");
            wmsLayer.Crs = String.Format("EPSG:{0}", 25832);
            wmsLayer.OutputFormat = "image/png";
            wmsLayer.Exceptions = "INIMAGE";
            //wmsLayer.ImageSource.ProjectionConverter = new UnmanagedProjectionConverter(25832, 3857);
            wmsLayer.SendingWebRequest += WmsLayer_SendingWebRequest;
            layerOverlay.Layers.Add(wmsLayer);
            layerOverlay.TileType = TileType.SingleTile;
            map.Overlays.Add(layerOverlay);

            wmsLayer.Open();
            map.CurrentExtent = wmsLayer.GetBoundingBox();
            map.Refresh();
        }

Thanks

Frank

Sorry Frank,

it’s not working.
When using your code (without Projection) the WMS will be displayed, but at wrong location.

We have to use projection because we are handling several Layers in different epsg.
Using Projection (.ImageSource.ProjectionConverter = GetProjection4(25832,3857)) will raise an inner exception : NotImplementedException: This function relies on ThinkGeo.UnmanagedProj.nupkg. Please install this package first. Or this function is not support on current platform.

The package is installed.
It seems to me like a bug in projecting a WMS.

Regards Hardy

Thanks Hartwig,
I attached you the sample code show you how it get work.
Demo.zip (12.9 KB)
For your case you could use 3857 directly because the WMS provider support the 3857 directly

I also add the code to get 25832 and convert to 3857. You can uncommnet the code after
// --------------following code will get the 25832 and covert to 3857 ----------------
Also you need install the unmanaged Proj library

Because the adv_alk not exist everywhere. I don’t recommend use map.CurrentExtent = wmsLayer.GetBoundingBox(); so you need find the place which has the data for the adv_alk layer.

I would recommend use the QGIS to analysis your wms layer which will give you some idea what your data looks like, where you have the data etc. I created a small video to show you how to do it. It is a little hard to find the area which the adv_alk layer has some data. I have to use openstreetmap as an reference.

Thanks

Frank