[Tilecache] Tilecache seed "Zero length data"

Marco Nijdam marco at west.nl
Fri May 21 10:59:34 EDT 2010


Dear developers,

Sorry if you see this twice, I accendently sent it to the old mailing list
(which is still linked on http://tilecache.org/).

First of all, thanks for developing Tilecache.

Like others I've experience the "Zero length data" error when seeding the
tilecache. I've investigated the problem and see several issues that cause
this problem.

Attached is a patch against 2.10.

Below is a description of the issues and reasons:

1. SVN Changeset 357 http://trac.osgeo.org/tilecache/changeset/357
introduced a padding in TileCache/Client.py, but I think this is not
completely correct. Now it unconditionally adds metaSize to
topright. Since topright is already the farthest cell, it means that an
unnecessary extra metatile row and column is always requested outside the
bbox (with padding = 0).

I guess the intention was to only do this if "padding" is set.

In the latest code:

107:            startX = bottomleft[0] - (1 * padding)
            #MN: suggest "endX = topright[0] + (1 * padding)"
108:            endX = topright[0] + metaSize[0] + (1 * padding)
109:            stepX = metaSize[0]
110:            startY = bottomleft[1] - (1 * padding)
            #MN: suggest "endY = topright[1] + (1 * padding)"
111:            endY = topright[1] + metaSize[1] + (1 * padding)
112:            stepY = metaSize[1]


2. In TileCache/Layer.py, class MetaLayer, method getMetaTile,
the metatile is constructed based on the (fixed) self.metaSize
(which is default 5).

In combination with the above issue, consider what happens on
zoomlevel 1. In my situation, zoomlevel 0 is 2x2 tiles, level 1 the 4x4
tiles.

Method MetaLayer.getMetaSize returns (4,4,1). Client.py seed()
will use this to loop at x and y on 0 and 4.

Method MetaLayer.render however creates a metatile using
self.getMetaTile. At tile.x = 4, getMetaTile returns an x=0,
instead of x=1 for the metatile, because self.metaSize[0] is 5.

In MetaLayer.renderMetaTile, line 415, x ranges between 0 and 3 (since
metatile.x = 0). Since tile.x = 4, it will never set tile.data (in line
422), resulting in the error "Zero length data" further on.

My suggested fix is thus to fix MetaLayer.getMetaTile to consider the
smaller metatile size at levels 0 and 1, by getting the
metaSize through the method getMetaSize.


3. An issue, which may be the reason why some have, and others don't have
the issue.

MetaLayer.getMetaSize adds 1 to maxcol and maxrow. At level 1, with 4x4
tiles (in my case), this would normally result in 5x5 getMetaSize. In that
case no problem surfaces.

However, in my case maxcol is 3.99992, so adding 1 and truncating to int
results in 4.

It is unclear to me what the addition of 1 is intended to do (not
documented in the code. I could imagine you want to ceil it.

Kind regards,
--
-- Marco Nijdam
--

-------------- next part --------------
A non-text attachment was scrubbed...
Name: tilecache-metatile.patch
Type: application/octet-stream
Size: 3683 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/tilecache/attachments/20100521/63dcac43/tilecache-metatile.obj


More information about the Tilecache mailing list