[Tilecache] seed problem with significant digits

Bart van den Eijnden (OSGIS) bartvde at osgis.nl
Fri May 11 08:49:08 EDT 2007


Hi list,

while seeding we found that sometimes a lot of tiles are not created (seed
thinks it needs to create 28 tiles while we are expecting something like
1600 for a certain resolution). It turns out that the getCell function in
Layer.py sometimes comes back with one resolution off.

Our resolutions are e.g. like:

70,00018267303670

and it tried to match with something like 70,000182673 so our value is above
that level and it ends up one resolution off ...

To get around this problem, we modified the getCell function to also get z
as an argument (since z is already known in the calling function), so:

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

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

and then:

    def getClosestCell (self, z, (minx, miny)):
        res = self.resolutions[z]
        maxx = minx + self.size[0] * res
        maxy = miny + self.size[1] * res
        return self.getCell((minx, miny, maxx, maxy), z, False)

Hope this helps. Maybe there is a cleaner solution though.

Best regards,
Bart

--
Bart van den Eijnden
OSGIS, Open Source GIS
http://www.osgis.nl








More information about the Tilecache mailing list