diff --git a/retreive_map_pic.py b/retreive_map_pic.py index e34a092..96d30b0 100755 --- a/retreive_map_pic.py +++ b/retreive_map_pic.py @@ -7,10 +7,11 @@ import math import sys, os import time from subprocess import PIPE, Popen +import shlex URL_OPEN_MAP = "http://tile.openstreetmap.org/{zoom}/{x}/{y}.png" MAP_DIR = "static/maps/" -ZOOM = 16 +ZOOM = 17 dlat = 2 dlon = 2 serv = redis.StrictRedis('localhost', 6250, 2) @@ -42,14 +43,22 @@ def create_box_around_coord(lon,lat): return pics def download_and_merge(url_list, coord): - with open('in.txt', 'w') as f: - for i, url in enumerate(url_list): - f.write(str(i+1)+' '+url+'\n') + to_process = b"" + for i, url in enumerate(url_list): + to_process += (str(i+1)+' '+url+'\n').encode('utf8') map_name = "map_{lon}-{lat}.png".format(lon=coord['lon'], lat=coord['lat']) path = os.path.join(MAP_DIR, map_name) - FULL_COMMAND = "cat in.txt | parallel --colsep ' ' wget -O maps/{1} {2} && montage -geometry +0+0 maps/1 maps/4 maps/7 maps/2 maps/5 maps/8 maps/3 maps/6 maps/9 "+path - os.system(FULL_COMMAND) + cmd1 = "parallel --colsep ' ' wget -O maps/{1} {2}" + cmd2 = "montage -geometry +0+0 maps/1 maps/4 maps/7 maps/2 maps/5 maps/8 maps/3 maps/6 maps/9 "+path + + # Donwload tiles + p = Popen(shlex.split(cmd1), stdout=PIPE, stdin=PIPE) + p.communicate(input=to_process) + + # Combine tiles + p = Popen(shlex.split(cmd2), stdout=PIPE, stdin=PIPE) + return map_name def download_maps(coord): diff --git a/static/js/index.js b/static/js/index.js index a7af1b4..1226f21 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -168,6 +168,7 @@ $(document).ready(function () { var json = jQuery.parseJSON( event.data ); var img2 = linkForDefaultMap.replace(/\/[^\/]+$/, "/"+json.path); $("#img"+img_to_change).fadeOut(400, function(){ $(this).attr('src', img2); }).fadeIn(400); + $("#textMap"+img_to_change).fadeOut(400, function(){ $(this).text(json.path); }).fadeIn(400); img_to_change = img_to_change == 4 ? 0 : img_to_change+1; }; source_map.onopen = function(){ diff --git a/templates/index.html b/templates/index.html index 7501fa7..dbbfc59 100644 --- a/templates/index.html +++ b/templates/index.html @@ -43,6 +43,11 @@ img { border-width: 2px; } +small { + font-size: 100%; + font-weight: bold; +} + @@ -72,21 +77,21 @@ img { -
+
text1
- text2 + text2
-
- text3 +
+ text3
-
- text4 +
+ text4