Merge remote branch 'munki/master'
This commit is contained in:
17
gmap.py
17
gmap.py
@@ -36,22 +36,21 @@ def main():
|
|||||||
|
|
||||||
print "processing chunks in background"
|
print "processing chunks in background"
|
||||||
results = world.render_chunks_async(chunks, False, options.procs)
|
results = world.render_chunks_async(chunks, False, options.procs)
|
||||||
|
|
||||||
print "Generating quad tree. This may take a while and has no progress bar right now, so sit tight."
|
print "Writing out html file"
|
||||||
|
|
||||||
if not os.path.exists(destdir):
|
if not os.path.exists(destdir):
|
||||||
os.mkdir(destdir)
|
os.mkdir(destdir)
|
||||||
|
zoom = world.get_quadtree_depth(mincol, maxcol, minrow, maxrow)
|
||||||
|
write_html(destdir, 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):
|
if not os.path.exists(tiledir):
|
||||||
os.mkdir(tiledir)
|
os.mkdir(tiledir)
|
||||||
|
world.generate_quadtree(results, mincol, maxcol, minrow, maxrow, tiledir)
|
||||||
zoom = world.generate_quadtree(results, mincol, maxcol, minrow, maxrow, tiledir)
|
|
||||||
|
|
||||||
print "DONE"
|
print "DONE"
|
||||||
|
|
||||||
print "Writing out html file"
|
|
||||||
write_html(destdir, zoom+1)
|
|
||||||
|
|
||||||
def write_html(path, zoomlevel):
|
def write_html(path, zoomlevel):
|
||||||
templatepath = os.path.join(os.path.split(__file__)[0], "template.html")
|
templatepath = os.path.join(os.path.split(__file__)[0], "template.html")
|
||||||
html = open(templatepath, 'r').read()
|
html = open(templatepath, 'r').read()
|
||||||
|
|||||||
31
world.py
31
world.py
@@ -292,15 +292,13 @@ def render_worldtile(chunkmap, colstart, colend, rowstart, rowend, oldhash):
|
|||||||
|
|
||||||
return tileimg, digest
|
return tileimg, digest
|
||||||
|
|
||||||
def generate_quadtree(chunkmap, colstart, colend, rowstart, rowend, prefix):
|
def get_quadtree_depth(colstart, colend, rowstart, rowend):
|
||||||
"""Base call for quadtree_recurse. This sets up the recursion and generates
|
"""Determines the zoom depth of a requested quadtree.
|
||||||
a quadtree given a chunkmap and the ranges.
|
|
||||||
|
Return value is an integer >= 0. Higher integers mean higher resolution maps.
|
||||||
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.)
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
# Pulled out of generate_quadtree. Original comment follows:
|
||||||
|
#
|
||||||
# This first call has a special job. No matter the input, we need to
|
# This first call has a special job. No matter the input, we need to
|
||||||
# make sure that each recursive call splits both dimensions evenly
|
# make sure that each recursive call splits both dimensions evenly
|
||||||
# into a power of 2 tiles wide and high.
|
# into a power of 2 tiles wide and high.
|
||||||
@@ -319,6 +317,21 @@ def generate_quadtree(chunkmap, colstart, colend, rowstart, rowend, prefix):
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise Exception("Your map is waaaay to big")
|
raise Exception("Your map is waaaay to big")
|
||||||
|
|
||||||
|
return p
|
||||||
|
|
||||||
|
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
|
||||||
colstart = colmid - 2*2**p
|
colstart = colmid - 2*2**p
|
||||||
@@ -331,8 +344,6 @@ def generate_quadtree(chunkmap, colstart, colend, rowstart, rowend, prefix):
|
|||||||
|
|
||||||
quadtree_recurse(chunkmap, colstart, colend, rowstart, rowend, prefix, "base")
|
quadtree_recurse(chunkmap, colstart, colend, rowstart, rowend, prefix, "base")
|
||||||
|
|
||||||
return p
|
|
||||||
|
|
||||||
def quadtree_recurse(chunkmap, colstart, colend, rowstart, rowend, prefix, quadrant):
|
def quadtree_recurse(chunkmap, colstart, colend, rowstart, rowend, prefix, quadrant):
|
||||||
"""Recursive method that generates a quadtree.
|
"""Recursive method that generates a quadtree.
|
||||||
A single call generates, saves, and returns an image with the range
|
A single call generates, saves, and returns an image with the range
|
||||||
|
|||||||
Reference in New Issue
Block a user