moved tile filepath calculation to Tile object
This commit is contained in:
@@ -353,8 +353,7 @@ class QuadtreeGen(object):
|
|||||||
|
|
||||||
poi_queue = self.world.poi_q
|
poi_queue = self.world.poi_q
|
||||||
|
|
||||||
path = os.path.join(self.full_tiledir, *(str(x) for x in tile.path))
|
imgpath = tile.get_filepath(self.full_tiledir, self.imgformat)
|
||||||
imgpath = path + "." + self.imgformat
|
|
||||||
|
|
||||||
# Tiles always involve 3 columns of chunks and 5 rows of tiles (end
|
# Tiles always involve 3 columns of chunks and 5 rows of tiles (end
|
||||||
# ranges are inclusive)
|
# ranges are inclusive)
|
||||||
@@ -385,7 +384,7 @@ class QuadtreeGen(object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
# Create the directory if not exists
|
# Create the directory if not exists
|
||||||
dirdest = os.path.dirname(path)
|
dirdest = os.path.dirname(imgpath)
|
||||||
if not os.path.exists(dirdest):
|
if not os.path.exists(dirdest):
|
||||||
try:
|
try:
|
||||||
os.makedirs(dirdest)
|
os.makedirs(dirdest)
|
||||||
@@ -607,6 +606,14 @@ class Tile(object):
|
|||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return not self == other
|
return not self == other
|
||||||
|
|
||||||
|
def get_filepath(self, tiledir, imgformat):
|
||||||
|
"""Returns the path to this file given the directory to the tiles
|
||||||
|
|
||||||
|
"""
|
||||||
|
path = os.path.join(tiledir, *(str(x) for x in self.path))
|
||||||
|
imgpath = path + "." + imgformat
|
||||||
|
return imgpath
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_path(cls, path):
|
def from_path(cls, path):
|
||||||
"""Constructor that takes a path and computes the col,row address of
|
"""Constructor that takes a path and computes the col,row address of
|
||||||
|
|||||||
Reference in New Issue
Block a user