Beispiel #1
0
def seed(svc, base, layer, levels=(0, 5), bbox=None):
    from Layer import Tile

    if not bbox: bbox = layer.bbox

    start = time.time()
    total = 0

    for z in range(*levels):
        bottomleft = layer.getClosestCell(z, bbox[0:2])
        topright = layer.getClosestCell(z, bbox[2:4])
        print >> sys.stderr, "###### %s, %s" % (bottomleft, topright)
        zcount = 0
        metaSize = layer.getMetaSize(z)
        ztiles = int(
            math.ceil(float(topright[1] - bottomleft[1]) / metaSize[0]) *
            math.ceil(float(topright[0] - bottomleft[0]) / metaSize[1]))
        for y in range(bottomleft[1], topright[1], metaSize[1]):
            for x in range(bottomleft[0], topright[0], metaSize[0]):
                tileStart = time.time()
                tile = Tile(layer, x, y, z)
                bounds = tile.bounds()
                svc.renderTile(tile)
                total += 1
                zcount += 1
                box = "(%.4f %.4f %.4f %.4f)" % bounds
                print "%02d (%06d, %06d) = %s [%.4fs : %.3f/s] %s/%s" \
                     % (z,x,y, box, time.time() - tileStart, total / (time.time() - start + .0001), zcount, ztiles)
Beispiel #2
0
def seed(svc,
         layer,
         levels=(0, 5),
         bbox=None,
         padding=0,
         force=False,
         reverse=False,
         delay=0):
    from Layer import Tile
    try:
        padding = int(padding)
    except:
        raise Exception(
            'Your padding parameter is %s, but should be an integer' % padding)

    if not bbox: bbox = layer.bbox

    start = time.time()
    total = 0

    for z in range(*levels):
        bottomleft = layer.getClosestCell(z, bbox[0:2])
        topright = layer.getClosestCell(z, bbox[2:4])
        # Why Are we printing to sys.stderr??? It's not an error.
        # This causes a termination if run from cron or in background if shell is terminated
        #print >>sys.stderr, "###### %s, %s" % (bottomleft, topright)
        print "###### %s, %s" % (bottomleft, topright)
        zcount = 0
        metaSize = layer.getMetaSize(z)
        ztiles = int(
            math.ceil(float(topright[1] - bottomleft[1]) / metaSize[0]) *
            math.ceil(float(topright[0] - bottomleft[0]) / metaSize[1]))
        if reverse:
            startX = topright[0] + metaSize[0] + (1 * padding)
            endX = bottomleft[0] - (1 * padding)
            stepX = -metaSize[0]
            startY = topright[1] + metaSize[1] + (1 * padding)
            endY = bottomleft[1] - (1 * padding)
            stepY = -metaSize[1]
        else:
            startX = bottomleft[0] - (1 * padding)
            endX = topright[0] + metaSize[0] + (1 * padding)
            stepX = metaSize[0]
            startY = bottomleft[1] - (1 * padding)
            endY = topright[1] + metaSize[1] + (1 * padding)
            stepY = metaSize[1]
        for y in range(startY, endY, stepY):
            for x in range(startX, endX, stepX):
                tileStart = time.time()
                tile = Tile(layer, x, y, z)
                bounds = tile.bounds()
                svc.renderTile(tile, force=force)
                total += 1
                zcount += 1
                box = "(%.4f %.4f %.4f %.4f)" % bounds
                print "%02d (%06d, %06d) = %s [%.4fs : %.3f/s] %s/%s" \
                     % (z,x,y, box, time.time() - tileStart, total / (time.time() - start + .0001), zcount, ztiles)
                if delay:
                    time.sleep(delay)
Beispiel #3
0
 def thaw_GET(self, msgtxt, layers):
     layername, level, row, col = struct.unpack(self.tilespec, msgtxt)
     self.tile = Tile(layers[layername], row, col, level)