8

I've a problem with GDALs TMS mini driver. I've created an XML file, which I can open in QGIS. I am using local tiles on my computer which I pre-rendered with Mapnik, the map covers entire country of Austria and the XML looks like this:

<GDAL_WMS>
    <Service name="TMS">
        <ServerUrl>file:///f:/austria/map/${z}/${x}/${y}.png</ServerUrl>
        <SRS>EPSG:3857</SRS>
        <ImageFormat>image/png</ImageFormat>
    </Service>
    <DataWindow>
        <UpperLeftX>-20037508.34</UpperLeftX>
        <UpperLeftY>20037508.34</UpperLeftY>
        <LowerRightX>20037508.34</LowerRightX>
        <LowerRightY>-20037508.34</LowerRightY>
        <TileLevel>17</TileLevel>
        <TileCountX>1</TileCountX>
        <TileCountY>1</TileCountY>
        <YOrigin>top</YOrigin>
    </DataWindow>
    <Projection>EPSG:3857</Projection>
    <BlockSizeX>256</BlockSizeX>
    <BlockSizeY>256</BlockSizeY>
    <BandsCount>3</BandsCount>
    <ZeroBlockHttpCodes>204,303,400,404,500,501</ZeroBlockHttpCodes>
    <ZeroBlockOnServerException>true</ZeroBlockOnServerException>
</GDAL_WMS>

The problem is: Whenever I zoom/pan into such window extents that is not completely covered with my tiles, the result is a scrambled image like this:

enter image description here

When I zoom/pan to an area covered with my tiles, the result is OK:

enter image description here

What I think is the issue: GDAL cannot merge and display the map correctly if there are missing tiles. If I was loading tiles from an http source, the server would probably return http request codes like 404 or 204. When configuring the TMS service in the XML, you have an option to define what to do when a tile is not returned/can't be found using these 2 tags:

<ZeroBlockHttpCodes>204,303,400,404,500,501</ZeroBlockHttpCodes>
<ZeroBlockOnServerException>true</ZeroBlockOnServerException>

The problem is, I don't know what is the response when accessing locally stored tiles and some are not found, or how do you specify what to do in such a case. I was also thinking of limiting the extent of the layer, but there are no options in the XML syntax for doing so.

2
  • I'm also having a similar problem. Have yo been able to load the TMS stored locally in QGis? In my case, I get a blank image with some random colored pixels on the top of the canvas
    – Daniel
    Nov 24, 2016 at 16:48
  • @Daniel same for me, I get a black screen if some tiles are missing. The TileLayerPlugin can deal with this problem.
    – AndreJ
    Nov 24, 2016 at 18:56

2 Answers 2

1

To avoid such problems with the file:// urls, I have set up a local apache server, so that I can access the tiles via http://localhost/.

This works for all use cases where online tiles are requested.

MS4W offers an apache installation, as well as OSGeo4W.

3
  • Yes, thats one solution, but i'd still like to know if anyone managed to bypass the problem and still use file:/// uris
    – U2ros
    Dec 20, 2013 at 16:43
  • Another is using .mbtiles format, which seems to be even more handy
    – U2ros
    Dec 21, 2013 at 11:28
  • The HTTP server included in Python's standard library is a convenient alternative to setting up Apache: python -m http.server --directory f:/austria/map/ Mar 28, 2019 at 9:53
0

I had a similar problem, but would describe the symptom as not about where you pan, but what zoomo level. Zooms near the native resolution are fine, its the smaller levels that fail, regardless of whether you are entirely within extents.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.