[GIS] GDAL TMS (WMS) mini driver

gdaltile-map-service

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.

Best Answer

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.

Related Question