[Tilecache] FW: Fix/workaround for a seeding problem in 1.8.1 on python for windows

Michael Schenck Michael.Schenck at EnvistaSoftware.com
Wed Sep 12 12:36:38 EDT 2007


I have been working with TileCache for a bit putting it in front of an
ArcGIS server setup.  I ran into some issues with the seeding program.
I think they are related to rounding issues and getting the z value off
by 1 when trying to rematch the z value from the resolution on the Layer
getCell() call from the Layer getClosestCell().  I found a previous post
that was helpful:

http://openlayers.org/pipermail/tilecache/2007-May/000231.html 

and I also modified the Layer getLevel().  We are using a projection in
meters so it appears there is a precision issue to the right of the
decimal place.  Not sure if these issues are fixed in a newer version or
perhaps related to windows, but this is what I ran into working with
against 1.8.1 on python 2.5 for windows.  Hope it helps anyone with a
similar problem.

def getLevel (self, res):
        z = None
        for i in range(len(self.resolutions)):
            if abs( self.resolutions[i] - res ) < 0.00000001:
                res = self.resolutions[i]
                z = i
                break
        if z is None:
            if self.debug:
                warn("can't find resolution index for %f with precision
0.00000001, trying precision 0.0001" % res)
            for i in range(len(self.resolutions)):
                if abs( self.resolutions[i] - res ) < 0.0001:
                    res = self.resolutions[i]
                    z = i
                    break
            if z is None and self.debug:
                warn("can't find resolution index for %f at either
precision" % res)
        return z



Modified getCell():

def getCell (self, (minx, miny, maxx, maxy), z = None, exact = True):

...

if z is None:
            if exact:
                z = self.getLevel(res)
                if z is None: return None # oops
            else:
                z = self.getClosestLevel(res)



and modified getClosestCell(): 

...

return self.getCell((minx, miny, maxx, maxy), z, False)







More information about the Tilecache mailing list