0

added an option to skip generating region.js and marker.js

This commit is contained in:
Andrew Brown
2010-10-15 22:23:15 -04:00
parent 324ac5d28d
commit ea179118bd
2 changed files with 15 additions and 10 deletions

View File

@@ -52,6 +52,7 @@ def main():
parser.add_option("--optimize-img", dest="optimizeimg", help="If using png, perform image file size optimizations on the output. Specify 1 for pngcrush, 2 for pngcrush+optipng+advdef. This may double (or more) render times, but will produce up to 30% smaller images. NOTE: requires corresponding programs in $PATH or %PATH%") parser.add_option("--optimize-img", dest="optimizeimg", help="If using png, perform image file size optimizations on the output. Specify 1 for pngcrush, 2 for pngcrush+optipng+advdef. This may double (or more) render times, but will produce up to 30% smaller images. NOTE: requires corresponding programs in $PATH or %PATH%")
parser.add_option("-q", "--quiet", dest="quiet", action="count", default=0, help="Print less output. You can specify this option multiple times.") parser.add_option("-q", "--quiet", dest="quiet", action="count", default=0, help="Print less output. You can specify this option multiple times.")
parser.add_option("-v", "--verbose", dest="verbose", action="count", default=0, help="Print more output. You can specify this option multiple times.") parser.add_option("-v", "--verbose", dest="verbose", action="count", default=0, help="Print more output. You can specify this option multiple times.")
parser.add_option("--skip-js", dest="skipjs", action="store_true", help="Don't output marker.js or regions.js")
options, args = parser.parse_args() options, args = parser.parse_args()
@@ -118,6 +119,7 @@ def main():
# Now generate the tiles # Now generate the tiles
q = quadtree.QuadtreeGen(w, destdir, depth=options.zoom, imgformat=imgformat, optimizeimg=optimizeimg) q = quadtree.QuadtreeGen(w, destdir, depth=options.zoom, imgformat=imgformat, optimizeimg=optimizeimg)
q.write_html(options.skipjs)
q.go(options.procs) q.go(options.procs)
def delete_all(worlddir, tiledir): def delete_all(worlddir, tiledir):

View File

@@ -118,8 +118,10 @@ class QuadtreeGen(object):
logging.info("{0}/{1} tiles complete on level {2}/{3}".format( logging.info("{0}/{1} tiles complete on level {2}/{3}".format(
complete, total, level, self.p)) complete, total, level, self.p))
def write_html(self, zoomlevel, imgformat): def write_html(self, skipjs=False):
"""Writes out index.html""" """Writes out index.html, marker.js, and region.js"""
zoomlevel = self.p
imgformat = self.imgformat
templatepath = os.path.join(util.get_program_path(), "template.html") templatepath = os.path.join(util.get_program_path(), "template.html")
html = open(templatepath, 'r').read() html = open(templatepath, 'r').read()
@@ -131,6 +133,15 @@ class QuadtreeGen(object):
with open(os.path.join(self.destdir, "index.html"), 'w') as output: with open(os.path.join(self.destdir, "index.html"), 'w') as output:
output.write(html) output.write(html)
# Write a blank image
blank = Image.new("RGBA", (1,1))
tileDir = os.path.join(self.destdir, "tiles")
if not os.path.exists(tileDir): os.mkdir(tileDir)
blank.save(os.path.join(tileDir, "blank."+self.imgformat))
if skipjs:
return
# write out the default marker table # write out the default marker table
with open(os.path.join(self.destdir, "markers.js"), 'w') as output: with open(os.path.join(self.destdir, "markers.js"), 'w') as output:
output.write("var markerData=%s" % json.dumps(self.world.POI)) output.write("var markerData=%s" % json.dumps(self.world.POI))
@@ -145,12 +156,6 @@ class QuadtreeGen(object):
output.write(' // ]},\n') output.write(' // ]},\n')
output.write('];') output.write('];')
# Write a blank image
blank = Image.new("RGBA", (1,1))
tileDir = os.path.join(self.destdir, "tiles")
if not os.path.exists(tileDir): os.mkdir(tileDir)
blank.save(os.path.join(tileDir, "blank."+self.imgformat))
def _get_cur_depth(self): def _get_cur_depth(self):
"""How deep is the quadtree currently in the destdir? This glances in """How deep is the quadtree currently in the destdir? This glances in
index.html to see what maxZoom is set to. index.html to see what maxZoom is set to.
@@ -287,8 +292,6 @@ class QuadtreeGen(object):
else: else:
pool = multiprocessing.Pool(processes=procs) pool = multiprocessing.Pool(processes=procs)
self.write_html(self.p, self.imgformat)
# Render the highest level of tiles from the chunks # Render the highest level of tiles from the chunks
results = collections.deque() results = collections.deque()
complete = 0 complete = 0