cleaned up some comments
This commit is contained in:
3
gmap.py
3
gmap.py
@@ -42,9 +42,10 @@ def main():
|
|||||||
os.mkdir(destdir)
|
os.mkdir(destdir)
|
||||||
zoom = world.get_quadtree_depth(mincol, maxcol, minrow, maxrow)
|
zoom = world.get_quadtree_depth(mincol, maxcol, minrow, maxrow)
|
||||||
write_html(destdir, zoom+1)
|
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."
|
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):
|
if not os.path.exists(tiledir):
|
||||||
os.mkdir(tiledir)
|
os.mkdir(tiledir)
|
||||||
world.generate_quadtree(results, mincol, maxcol, minrow, maxrow, tiledir)
|
world.generate_quadtree(results, mincol, maxcol, minrow, maxrow, tiledir)
|
||||||
|
|||||||
27
world.py
27
world.py
@@ -295,13 +295,19 @@ def render_worldtile(chunkmap, colstart, colend, rowstart, rowend, oldhash):
|
|||||||
def get_quadtree_depth(colstart, colend, rowstart, rowend):
|
def get_quadtree_depth(colstart, colend, rowstart, rowend):
|
||||||
"""Determines the zoom depth of a requested quadtree.
|
"""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
|
# This comment makes more sense if you consider it inlined in its call from
|
||||||
# make sure that each recursive call splits both dimensions evenly
|
# generate_quadtree()
|
||||||
# into a power of 2 tiles wide and high.
|
|
||||||
# Since a single tile has 3 columns of chunks and 5 rows of chunks, this
|
# 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
|
# 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
|
# 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
|
"""Base call for quadtree_recurse. This sets up the recursion and generates
|
||||||
a quadtree given a chunkmap and the ranges.
|
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);
|
p = get_quadtree_depth(colstart, colend, rowstart, rowend);
|
||||||
colmid = (colstart + colend) // 2
|
colmid = (colstart + colend) // 2
|
||||||
rowmid = (rowstart + rowend) // 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
|
colstart = colmid - 2*2**p
|
||||||
colend = colmid + 2*2**p
|
colend = colmid + 2*2**p
|
||||||
rowstart = rowmid - 4*2**p
|
rowstart = rowmid - 4*2**p
|
||||||
rowend = rowmid + 4*2**p
|
rowend = rowmid + 4*2**p
|
||||||
|
|
||||||
print " power is", p
|
#print " power is", p
|
||||||
print " new bounds: {0},{1} {2},{3}".format(colstart, colend, rowstart, rowend)
|
#print " new bounds: {0},{1} {2},{3}".format(colstart, colend, rowstart, rowend)
|
||||||
|
|
||||||
quadtree_recurse(chunkmap, colstart, colend, rowstart, rowend, prefix, "base")
|
quadtree_recurse(chunkmap, colstart, colend, rowstart, rowend, prefix, "base")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user