WMTS failed to load imagery

Hi, Cesium Team,
I apply the latest Cesium for Unreal Plugin (version 2.3.0)with Unreal 5.3.2. I am tring to set the CesiumWebMapTileServiceRasterOverlay to load imagery from a WMTS server. The WMTS server specify the following and I am sure my token has the right:
http://t0.tianditu.gov.cn/img_c/wmts?
SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=your token .
The following screenshot shows the details in my project to set the CesiumWebMapTileServiceRasterOverlay .


Yet it fails to load the imagery map. And there is no any error in Output log in Unreal. I think the problem is the tk in the Url. Which variable is to specify the tk in CesiumWebMapTileServiceRasterOverlay ?
Can anyone help?

It’s hard to say what’s wrong since I don’t have access to your server, but a couple of things look suspicious:

  1. FORMAT=tiles? That’s supposed to be the format of the returned image, so I don’t know what “tiles” means. Usually it’s image/png or image/jpeg.
  2. The root tile is specified to only cover the western hemisphere. Are you sure that’s correct?

I’d suggest you start by manually building a working URL to get the root tile in your web browser. Once you have that, I believe you should be able to supply that entire URL in the Url field, using {x}, {y}, and {z} placeholders in the appropriate place. You’ll also need to make sure the tiling scheme and root tile extents are correct (if they’re wrong, the layer will be displayed, but in the wrong place).

It may also be helpful to look at the GetCapabilities service returned by your server. If it’s implemented correctly, it should describe, in XML, all the required/expected values for the various parameters.

Hi, Kevin,
Thanks for the reply.
The ‘GetCapabilities’ service returned by the server as follows.

And I put in the such url in my browser as"http://t0.tianditu.gov.cn/img_c/wmts?tk=mytoken&request=GetTile&version=1.0.0&service=WMTS&format=tiles&layer=img&style=default&tilematrixset=c&tilematrix=1&tilerow=0&tilecol=0", I get the result.

why CesiumWebMapTileServiceRasterOverlay can not load the RasterOverlay? I still think the problem is the tk. My server requires the url to be " http://t0.tianditu.gov.cn/img_c/wmts?tk=mytoken". Yet the CesiumWebMapTileServiceRasterOverlay has no place to hold the tk. The CesiumWebMapTileServiceRasterOverlay just adds another ‘’?" behind the url,and it might cause the problem. Would it be reasonable to add a variable member such as “tk” to wmtsOptions in the source code?

I believe that using this URL should do what you want:
http://t0.tianditu.gov.cn/img_c/wmts?tk=mytoken&request=GetTile&version=1.0.0&service=WMTS&format=tiles&layer=img&style=default&tilematrixset=c&tilematrix={TileMatrix}&tilerow={TileRow}&tilecol={TileCol}

Since you’re specifying them all in the URL, the Layer, Style, Format, and Tile Matrix Set ID properties in the UI won’t matter. I’m not familiar with EPSG:4490, so I don’t know if you’ll need to check “Use Web Mercator Projection”, but I suspect not. However, if that projection isn’t similar to EPSG:4326, then your data will be misaligned. I don’t think you’ll need to check “Specify Tiling Scheme”.

have you solved the problem? how to set CesiumWebMapTileServiceRasterOverlay

Sorry for the delay. Yes, I have already solved it. The problem is specific to TianDiTu Map service. I think somehow the TianDiTu Server needs to confirm the request is from browser. I made some changes on the files CesiumWebMapTileServiceRasterOverlay.h and CesiumWebMapTileServiceRasterOverlay.cpp to add Header to the request. Then I made some settings in Cesium for Unreal WMTS RasterOverlay. And it worked. See the details below.

  1. The change to CesiumWebMapTileServiceRasterOverlay.h

  1. The change to CesiumWebMapTileServiceRasterOverlay.cpp

  1. The settings in Cesium for Unreal depend on which url is filled. The following is just an example for Longitude and latitude projection. The WebMercatorProjection is different and simple.

For more details ,Please visit
Cesium for Unreal 加载天地图P2-修改和编译源代码_哔哩哔哩_bilibili
I am the UP.

1 Like

There is a problem with version 2.7 of this method