Merge remote branch 'munki/master'
Conflicts: gmap.py
This commit is contained in:
7
gmap.py
7
gmap.py
@@ -15,6 +15,7 @@ helptext = """
|
|||||||
def main():
|
def main():
|
||||||
parser = OptionParser(usage=helptext)
|
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("-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()
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ def main():
|
|||||||
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)
|
zoom = world.get_quadtree_depth(mincol, maxcol, minrow, maxrow)
|
||||||
write_html(destdir, zoom+1)
|
write_html(destdir, zoom+1, options.cachelife)
|
||||||
print "Your map will have {0} zoom levels".format(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."
|
||||||
@@ -52,11 +53,13 @@ def main():
|
|||||||
|
|
||||||
print "DONE"
|
print "DONE"
|
||||||
|
|
||||||
def write_html(path, zoomlevel):
|
def write_html(path, zoomlevel, cachelife):
|
||||||
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()
|
||||||
html = html.replace(
|
html = html.replace(
|
||||||
"{maxzoom}", str(zoomlevel))
|
"{maxzoom}", str(zoomlevel))
|
||||||
|
html = html.replace(
|
||||||
|
"{cachelife}", str(cachelife))
|
||||||
|
|
||||||
with open(os.path.join(path, "index.html"), 'w') as output:
|
with open(os.path.join(path, "index.html"), 'w') as output:
|
||||||
output.write(html)
|
output.write(html)
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
fileExt: 'png',
|
fileExt: 'png',
|
||||||
tileSize: 384,
|
tileSize: 384,
|
||||||
defaultZoom: 1,
|
defaultZoom: 1,
|
||||||
maxZoom: {maxzoom}
|
maxZoom: {maxzoom},
|
||||||
|
cacheMinutes: {cachelife}
|
||||||
};
|
};
|
||||||
|
|
||||||
var MCMapOptions = {
|
var MCMapOptions = {
|
||||||
@@ -34,6 +35,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
url = url + '.' + config.fileExt;
|
url = url + '.' + config.fileExt;
|
||||||
|
var d = new Date();
|
||||||
|
url += '?c=' + Math.floor(d.getTime() / (1000 * 60 * config.cacheMinutes));
|
||||||
return(url);
|
return(url);
|
||||||
},
|
},
|
||||||
tileSize: new google.maps.Size(config.tileSize, config.tileSize),
|
tileSize: new google.maps.Size(config.tileSize, config.tileSize),
|
||||||
@@ -51,7 +54,7 @@
|
|||||||
function initialize() {
|
function initialize() {
|
||||||
var mapOptions = {
|
var mapOptions = {
|
||||||
zoom: config.defaultZoom,
|
zoom: config.defaultZoom,
|
||||||
center: new google.maps.LatLng(0, 0),
|
center: new google.maps.LatLng(-45, 90),
|
||||||
mapTypeControlOptions: {
|
mapTypeControlOptions: {
|
||||||
mapTypeIds: ['mcmap'],
|
mapTypeIds: ['mcmap'],
|
||||||
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
|
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
|
||||||
|
|||||||
Reference in New Issue
Block a user