From 32c2626b39ff2c5346f63a1e9bd41fb38b8a4129 Mon Sep 17 00:00:00 2001 From: Gregory Short Date: Tue, 7 Sep 2010 19:56:44 -0500 Subject: [PATCH 1/3] Added configurable option for controlling how long a tile will live in the browser's cache before being refetched. Good for configurations where the map will be automatically updated ona regular basis and the web browser's cache would get out of sync. Default is 24 hours. --- gmap.py | 7 +++++-- template.html | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gmap.py b/gmap.py index 7ff6de0..1a2a23c 100755 --- a/gmap.py +++ b/gmap.py @@ -15,6 +15,7 @@ helptext = """ def main(): parser = OptionParser(usage=helptext) parser.add_option("-p", "--processes", dest="procs", help="How many chunks to render in parallel. A good number for this is 1 more than the number of cores in your computer. Default 2", default=2, action="store", type="int") + parser.add_option("-c", "--cachelife", dest="cachelife", help="How many minutes a tile will be considered valid by the web browser before it fetches a new copy. Used if you have a crontab or similar running this every once in a while. Default is 24 hours.", default=1440, action="store", type="int") options, args = parser.parse_args() @@ -41,7 +42,7 @@ def main(): if not os.path.exists(destdir): os.mkdir(destdir) zoom = world.get_quadtree_depth(mincol, maxcol, minrow, maxrow) - write_html(destdir, zoom+1) + write_html(destdir, zoom+1, options.cachelife) 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"); @@ -51,11 +52,13 @@ def main(): print "DONE" -def write_html(path, zoomlevel): +def write_html(path, zoomlevel, cachelife): templatepath = os.path.join(os.path.split(__file__)[0], "template.html") html = open(templatepath, 'r').read() html = html.replace( "{maxzoom}", str(zoomlevel)) + html = html.replace( + "{cachelife}", str(cachelife)) with open(os.path.join(path, "index.html"), 'w') as output: output.write(html) diff --git a/template.html b/template.html index 079a19a..b314738 100644 --- a/template.html +++ b/template.html @@ -16,7 +16,8 @@ fileExt: 'png', tileSize: 384, defaultZoom: 1, - maxZoom: {maxzoom} + maxZoom: {maxzoom}, + cacheMinutes: {cachelife} }; var MCMapOptions = { @@ -34,6 +35,8 @@ } } url = url + '.' + config.fileExt; + var d = new Date(); + url += '?c=' + Math.floor(d.getTime() / (1000 * 60 * config.cacheMinutes)); return(url); }, tileSize: new google.maps.Size(config.tileSize, config.tileSize), From 94f1b25777e2694f4f6d0a1e09da8a1687d34cf3 Mon Sep 17 00:00:00 2001 From: Gregory Short Date: Tue, 7 Sep 2010 20:02:25 -0500 Subject: [PATCH 2/3] Map is better centered now when initially loading the page. The latitude is an approximation of the center, since we're using a mercator projection with what should be a rotated euclidean one. It's close enough. --- template.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template.html b/template.html index b314738..4d86b25 100644 --- a/template.html +++ b/template.html @@ -54,7 +54,7 @@ function initialize() { var mapOptions = { zoom: config.defaultZoom, - center: new google.maps.LatLng(0, 0), + center: new google.maps.LatLng(-45, 90), mapTypeControlOptions: { mapTypeIds: ['mcmap'], style: google.maps.MapTypeControlStyle.DROPDOWN_MENU From 1ebde2ff550eacfcb748fe65193df4ac60451042 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 7 Sep 2010 23:56:29 +0800 Subject: [PATCH 3/3] readme updates, added a features section at the top --- README.rst | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 93e8132..64dabf8 100644 --- a/README.rst +++ b/README.rst @@ -12,8 +12,19 @@ resolution images. It performs a similar function to the existing Minecraft Cartographer program but with a slightly different goal in mind: to generate large resolution images such that one can zoom in and see details. -**New**: gmap.py generates tiles for a Google Map interface, so that people -with large worlds and/or limited computer memory can still view their worlds! +Features +======== + +* Renders large resolution images of your world, such that you can zoom in and + see details + +* Outputs a Google Map powered interface that is memory efficient, both in + generating and viewing. + +* Utilizes 2 levels of caching to speed up subsequent renderings of your world. + +* Throw the output directory up on a web server to share your Minecraft world + with everyone! Requirements ============ @@ -37,7 +48,7 @@ problems. First, it's slow. If your map is really large, this could take at least half an hour, and for really large maps, several hours (Subsequent runs will be quicker since it only re-renders tiles that have changed). Second, there's no progress bar. You can watch the tiles get generated, but the program -gives no feedback at this time on how far it is. +gives no direct feedback at this time on how far along it is. There are probably some other minor glitches along the way, hopefully they will be fixed soon. See the `Bugs`_ section below. @@ -78,8 +89,8 @@ Crushing the Output Tiles ------------------------- Image files taking too much disk space? Try using pngcrush. On Linux and probably Mac, if you have pngcrush installed, this command will go and crush -all your images in the given destination. This took the total disk usage of my -world from 85M to 67M. +all your images in the given destination. This took the total disk usage of the +render for my world from 85M to 67M. ::