Beispiel #1
0
class Seeder:
    def __init__(self, tileCacheConfigFile, userId=-1, groupId=-1):
        self.tileCacheConfigFile = tileCacheConfigFile
        self.service = TileCache.Service.load(self.tileCacheConfigFile)
        self.tileFinder = TileFinder(self.tileCacheConfigFile)

    def seedForPoint(self,
                     layerName,
                     point,
                     delta=(0.0, 0.0),
                     levels=None,
                     tilePadding=0,
                     force=False):
        bbox = (point[0] - delta[0], point[1] - delta[1], point[0] + delta[0],
                point[1] + delta[1])
        func = lambda tile: self.__processTile(tile, force)
        self.tileFinder.findTiles(layerName, levels, bbox, tilePadding, func)

    def seedForTmsPath(self, layerName, x, y, z, force=False):
        tile = self.tileFinder.tileForTmsPath(layerName, x, y, z)
        self.service.renderTile(tile, force=force)

    def seedForTile(self, tile, force=False):
        self.service.renderTile(tile, force=force)

    def __processTile(self, tile, force=False):
        self.service.renderTile(tile, force=force)
Beispiel #2
0
class Killer:
    def __init__(self, tileCacheConfigFile):
        self.tileCacheConfigFile = tileCacheConfigFile
        self.service = TileCache.Service.load(self.tileCacheConfigFile)
        self.tileFinder = TileFinder(self.tileCacheConfigFile)

    def killForPoint(self,
                     layerName,
                     point,
                     delta=(0.0, 0.0),
                     levels=None,
                     tilePadding=0):
        bbox = (point[0] - delta[0], point[1] - delta[1], point[0] + delta[0],
                point[1] + delta[1])
        func = lambda tile: self.service.cache.delete(tile)
        self.tileFinder.findTiles(layerName, levels, bbox, tilePadding, func)

    def killForTmsPath(self, layerName, x, y, z):
        tile = self.tileFinder.tileForTmsPath(layerName, x, y, z)
        self.service.cache.delete(tile)

    def killToSize(self, maxMBs):
        maxBytes = maxMBs * 1048576
        heap, cacheSize = self.__walkDiskCache()
        while heap and cacheSize > maxBytes:
            atime, size, path = heapq.heappop(heap)
            cacheSize -= size
            path = self.__cachePath() + path
            try:
                os.unlink(path)
            except OSError, e:
                print >> sys.stderr, "Error removing tile %s: %s" % (path, e)
Beispiel #3
0
class Killer:
	def __init__(self, tileCacheConfigFile):
		self.tileCacheConfigFile = tileCacheConfigFile
		self.service = TileCache.Service.load(self.tileCacheConfigFile)
		self.tileFinder = TileFinder(self.tileCacheConfigFile)

	def killForPoint(self, layerName, point, delta=(0.0, 0.0), levels=None, tilePadding=0):
		bbox = (point[0] - delta[0], point[1] - delta[1], point[0] + delta[0], point[1] + delta[1])
		func = lambda tile: self.service.cache.delete(tile)
		self.tileFinder.findTiles(layerName, levels, bbox, tilePadding, func)

	def killForTmsPath(self, layerName, x, y, z):
		tile = self.tileFinder.tileForTmsPath(layerName, x, y, z)
		self.service.cache.delete(tile)

	def killToSize(self, maxMBs):
		maxBytes = maxMBs * 1048576
		heap, cacheSize = self.__walkDiskCache()
		while heap and cacheSize > maxBytes:
			atime, size, path = heapq.heappop(heap)
			cacheSize -= size
			path = self.__cachePath() + path
			try:
				os.unlink(path)
			except OSError, e:
				print >> sys.stderr, "Error removing tile %s: %s" % (path, e)
Beispiel #4
0
class TileFinderTests(unittest.TestCase):
    def countTiles(self, tile):
        self.tileCount += 1

    def setUp(self):
        self.finder = TileFinder(testConfigFile())
        self.tileCount = 0

    def testFindingSimpleTiles(self):
        tiles = self.finder.findTiles('polar', (0, 2))
        self.assertEqual(8, len(tiles))

    def testDoingSomethingToEachTile(self):
        tiles = self.finder.findTiles('polar', (0, 2), block=self.countTiles)
        self.assertEqual(8, self.tileCount)
Beispiel #5
0
class TileFinderTests(unittest.TestCase):

	def countTiles(self, tile):
		self.tileCount += 1

	def setUp(self):
		self.finder = TileFinder(testConfigFile())
		self.tileCount = 0

	def testFindingSimpleTiles(self):
		tiles = self.finder.findTiles('polar', (0, 2))
		self.assertEqual(8, len(tiles))

	def testDoingSomethingToEachTile(self):
		tiles = self.finder.findTiles('polar', (0, 2), block=self.countTiles)
		self.assertEqual(8, self.tileCount)
Beispiel #6
0
class Seeder:
	def __init__(self, tileCacheConfigFile, userId=-1, groupId=-1):
		self.tileCacheConfigFile = tileCacheConfigFile
		self.service = TileCache.Service.load(self.tileCacheConfigFile)
		self.tileFinder = TileFinder(self.tileCacheConfigFile)

	def seedForPoint(self, layerName, point, delta=(0.0, 0.0), levels=None, tilePadding=0, force=False):
		bbox = (point[0] - delta[0], point[1] - delta[1], point[0] + delta[0], point[1] + delta[1])
		func = lambda tile: self.__processTile(tile, force)
		self.tileFinder.findTiles(layerName, levels, bbox, tilePadding, func)

	def seedForTmsPath(self, layerName, x, y, z, force=False):
		tile = self.tileFinder.tileForTmsPath(layerName, x, y, z)
		self.service.renderTile(tile, force=force)

	def seedForTile(self, tile, force=False):
		self.service.renderTile(tile, force=force)

	def __processTile(self, tile, force=False):
		self.service.renderTile(tile, force=force)
Beispiel #7
0
	def __init__(self, tileCacheConfigFile, userId=-1, groupId=-1):
		self.tileCacheConfigFile = tileCacheConfigFile
		self.service = TileCache.Service.load(self.tileCacheConfigFile)
		self.tileFinder = TileFinder(self.tileCacheConfigFile)
Beispiel #8
0
 def __init__(self, tileCacheConfigFile):
     self.tileCacheConfigFile = tileCacheConfigFile
     self.service = TileCache.Service.load(self.tileCacheConfigFile)
     self.tileFinder = TileFinder(self.tileCacheConfigFile)
Beispiel #9
0
	def __init__(self, tileCacheConfigFile):
		self.tileCacheConfigFile = tileCacheConfigFile
		self.service = TileCache.Service.load(self.tileCacheConfigFile)
		self.tileFinder = TileFinder(self.tileCacheConfigFile)
Beispiel #10
0
 def setUp(self):
     self.finder = TileFinder(testConfigFile())
     self.tileCount = 0
Beispiel #11
0
	def setUp(self):
		self.finder = TileFinder(testConfigFile())
		self.tileCount = 0
Beispiel #12
0
 def __init__(self, tileCacheConfigFile, userId=-1, groupId=-1):
     self.tileCacheConfigFile = tileCacheConfigFile
     self.service = TileCache.Service.load(self.tileCacheConfigFile)
     self.tileFinder = TileFinder(self.tileCacheConfigFile)