0

cleaned up some comments

This commit is contained in:
Andrew Brown
2010-09-07 21:32:57 -04:00
parent dda682ce51
commit 8382e6664a
2 changed files with 17 additions and 13 deletions

View File

@@ -42,9 +42,10 @@ def main():
os.mkdir(destdir)
zoom = world.get_quadtree_depth(mincol, maxcol, minrow, maxrow)
write_html(destdir, zoom+1)
print "Your map will have {0} zoom levels".format(zoom+1)
print "Generating quad tree. This may take a while and has no progress bar right now, so sit tight."
tiledir = os.path.join(destdir, "tiles");
tiledir = os.path.join(destdir, "tiles")
if not os.path.exists(tiledir):
os.mkdir(tiledir)
world.generate_quadtree(results, mincol, maxcol, minrow, maxrow, tiledir)

View File

@@ -295,13 +295,19 @@ def render_worldtile(chunkmap, colstart, colend, rowstart, rowend, oldhash):
def get_quadtree_depth(colstart, colend, rowstart, rowend):
"""Determines the zoom depth of a requested quadtree.
Return value is an integer >= 0. Higher integers mean higher resolution maps.
Return value is an integer >= 0. Higher integers mean higher resolution
maps. This is one less than the maximum zoom (level 0 is a single tile,
level 1 is 2 tiles wide by 2 tiles high, etc.)
"""
# Pulled out of generate_quadtree. Original comment follows:
# This determines how many zoom levels we need to encompass the entire map.
# We need to make sure that each recursive call splits both dimensions
# evenly into a power of 2 tiles wide and high, so this function determines
# how many splits to make, and generate_quadtree() uses this to adjust the
# row and column limits so that everything splits just right.
#
# This first call has a special job. No matter the input, we need to
# make sure that each recursive call splits both dimensions evenly
# into a power of 2 tiles wide and high.
# This comment makes more sense if you consider it inlined in its call from
# generate_quadtree()
# Since a single tile has 3 columns of chunks and 5 rows of chunks, this
# split needs to be sized into the void so that it is some number of rows
# in the form 2*2^p. And columns must be in the form 4*2^p
@@ -324,23 +330,20 @@ def generate_quadtree(chunkmap, colstart, colend, rowstart, rowend, prefix):
"""Base call for quadtree_recurse. This sets up the recursion and generates
a quadtree given a chunkmap and the ranges.
This returns the power of 2 tiles wide and high the image is. This is one
less than the maximum zoom (level 0 is a single tile, level 1 is 2 tiles
wide by 2 tiles high, etc.)
"""
p = get_quadtree_depth(colstart, colend, rowstart, rowend);
colmid = (colstart + colend) // 2
rowmid = (rowstart + rowend) // 2
# Modify the lower and upper bounds to be sized correctly
# Modify the lower and upper bounds to be sized correctly. See comments in
# get_quadtree_depth()
colstart = colmid - 2*2**p
colend = colmid + 2*2**p
rowstart = rowmid - 4*2**p
rowend = rowmid + 4*2**p
print " power is", p
print " new bounds: {0},{1} {2},{3}".format(colstart, colend, rowstart, rowend)
#print " power is", p
#print " new bounds: {0},{1} {2},{3}".format(colstart, colend, rowstart, rowend)
quadtree_recurse(chunkmap, colstart, colend, rowstart, rowend, prefix, "base")