ThinkGeo.com    |     Blog    |     Wiki    |     Support

Some questions about WMTS

Hi

I would like to be able to access this url via a WMTS layer in a WPF application.

https://wxs.ign.fr/pratique/geoportail/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTHOIMAGERY.ORTHOPHOTOS&TILEMATRIXSET=PM&TILEMATRIX=14&TILECOL=8180&TILEROW=5905&STYLE=normal&FORMAT=image/jpeg

When I test this url in a web browser, I have an answer.
So I tested in a WMTS layer but I have a 404 response

Here is my code :

WmtsLayer wmtsLayer = new WmtsLayer();
wmtsLayer.ServerUris.Add(new Uri(“https://wxs.ign.fr/pratique/geoportail/”));
wmtsLayer.Parameters.Add(“SERVICE”, “GetTile”);
wmtsLayer.Parameters.Add(“VERSION”, “1.0.0”);
wmtsLayer.Parameters.Add(“LAYER”, “ORTHOIMAGERY.ORTHOPHOTOS”);
wmtsLayer.Parameters.Add(“TILEMATRIXSET”, “PM”);
wmtsLayer.Parameters.Add(“TILEMATRIX”, “14”);
wmtsLayer.Parameters.Add(“TILECOL”, “8180”);
wmtsLayer.Parameters.Add(“TILEROW”, “5905”);
wmtsLayer.Parameters.Add(“STYLE”, “normal”);
wmtsLayer.Parameters.Add(“FORMAT”, “image/jpeg”);

        wmtsLayer.Open();
        LayerOverlay layerOverlay = new LayerOverlay();
        layerOverlay.Layers.Add("wmtsLayer", wmtsLayer);
        MapToto.Overlays.Add(layerOverlay);
        MapToto.ZoomIntoCenter(10, new PointShape(48.845, 2.424));
        MapToto.Refresh();

Have I forgotten something?
And if I do not want to specify a tilecol or tilerow or tilematrix, what should I put in parameter?
This …
wmtsLayer.Parameters…Add (“tilecol”, “{x}”)
wmtsLayer.Parameters.Add (“tilerow”, “{y}”)
wmtsLayer.Parameters.Add (“tilematrix”, “{z}”)

Thank you for your help.

Regards.

Steph.

One more thing

a screen shot from postman

Hi Stephanie,

Our layer cannot parse the capability of it, https://wxs.ign.fr/pratique/geoportail/wmts?Service=WMTS&Request=GetCapabilities

You can see it contains this node:
<ows:SupportedCRS>IGNF:WGS84G</ows:SupportedCRS>

Our map throw exception when parse here, because follow the “Web Map Tile Service Standard” 1.0.0 version it should be a known URI format:

For example:
urn:ogc:def:crs:OGC:1.3:CRS84
urn:ogc:def:crs:EPSG:6.18:3:3857

And you should want to use the WMTS layer like this:

 wmtsLayer.ServerUris.Add(new Uri("https://wxs.ign.fr/pratique/geoportail/wmts"));

        wmtsLayer.ActiveStyleName = "normal";
        wmtsLayer.ActiveLayerName = "ORTHOIMAGERY.ORTHOPHOTOS";
        wmtsLayer.TileMatrixSetName = "PM";            
        wmtsLayer.OutputFormat = "image/jpeg";
        wmtsLayer.Parameters.Add("VERSION", "1.0.0");

BTW, if you found anything have problem in the parameters, you can modify it in our event like this:

wmtsLayer.SendingWebRequest += WmtsLayer_SendingWebRequest;

        private void WmtsLayer_SendingWebRequest(object sender, SendingWebRequestEventArgs e)
    {
        string sourceUrl = e.WebRequest.RequestUri.ToString();
        string newUrl = sourceUrl;  // Modify the url here
        e.WebRequest = HttpWebRequest.Create(newUrl);
    }

Wish that’s helpful.

Regards,

Ethan

Hi Ethan,

Thank you for your help.
I used the WmtsLayer_SendingWebRequest event and changed the call url.

private void WmtsLayer_SendingWebRequest(object sender, SendingWebRequestEventArgs e)
{
var rr = new Uri(“https://wxs.ign.fr/pratique/geoportail/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTHOIMAGERY.ORTHOPHOTOS&TILEMATRIXSET=PM&TILEMATRIX=14&TILECOL=8180&TILEROW=5905&STYLE=normal&FORMAT=image/jpeg”);
e.WebRequest = WebRequest.Create(rr);
}

I have a type error

System.Xml.XmlException
HResult=0x80131940
Message=Il existe un caractère non valide dans l’encodage donné. Ligne 1, position 1.
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.hFY=(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()

Have you ever encountered this kind of error?

Thanks.
Regards.

Hi Stephanie,

Your code have problem here.

If you view the sending url, you can see the first request url is: https://wxs.ign.fr/pratique/geoportail/wmts?Service=WMTS&Request=GetCapabilities

The process for render a WMTS layer is follow this steps:

  1. Get capability
  2. Parse capability, get the information from it
  3. Get tile image, some information comes from the capability

You directly modify all the url to the get tile request, it get the image instead of XML, so the layer cannot parse it.

And just like I mentioned, your capability XML have problem, our layer cannot parse it correct in the step2.

And it looks we cannot find a way to ignore this step.

Regards,

Ethan

Hi Ethan,

My message is related to your response from this post. (MAP IGN integrated to MAP SUITE)

I’m sorry, I do not see how to change anything with getcapability.
I understand that the GetCapability returned by IGN does not meet a standard and so the thinkgeo Wmts layer can not read it.
By putting a breakpoint in the code, in sourceurl I have “http://wxs.ign.fr/?Service=WMTS&Request=GetCapabilities
I can read it with xdocument but after that, how can I change <ows: SupportedCRS> EPSG: 3857 </ ow: SupportedCRS> by its equivalence that meets the standard …urn:ogc:def:crs:EPSG:6.18:3:3857?

But it’s mostly how to return a new uri that contains the GetCapabilities with this value there?

Thanks a lot for your help.

Regards

Steph.

Hi Steph,

If the server is provide by 3rd part, you can try something like this:

  1. Contact the service provider, and see whether they can fix that
  2. Download their capability and modify it, then put the file in one of your server, and in your sending request event, modify the capability request link to get the modified version
  3. If you find the cached capability file here: %Temp%\MapSuite\WfsLayer, you can just replace that with yours.

Do you think which one is suitable your scenario?

Regards,

Ethan