Added small text on top of maps pics + Do not write in a file for parallel

pull/18/head
Sami Mokaddem 2017-10-11 11:24:59 +02:00
parent 41644425fb
commit aec6fa2603
3 changed files with 27 additions and 12 deletions

View File

@ -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):

View File

@ -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(){

View File

@ -43,6 +43,11 @@ img {
border-width: 2px;
}
small {
font-size: 100%;
font-weight: bold;
}
</style>
<body>
@ -72,21 +77,21 @@ img {
<!--<div id="panelbody" class="panel-body" style="height: 37vh; width:100%;">
<div id="feedDiv1A" style="width:50%; height: calc(100% - 30px); position: relative; float: left;"></div>
<div id="feedDiv1B" style="width:50%; height: calc(100% - 30px); position: relative; float: left;"></div>-->
<div id="panelbody" class="panel-body" style="height: 100%;">
<div id="panelbody" class="panel-body" style="height: 100%; padding: 5px">
<div id="feedDivMap1" style="width:50%; height: 50%; position: relative; float: left;">
<small id="textMap1">text1</small>
<img id="img1" src="{{ url_for('static', filename='maps/default.png') }}" style="width:98%;height:97%;">
</div>
<div id="feedDivMap2" style="width:50%; height: 50%; position: relative; float: left;">
<small id="textMap1">text2</small>
<small id="textMap2">text2</small>
<img id="img2" src="{{ url_for('static', filename='maps/default.png') }}" style="width:98%;height:97%;">
</div>
<div id="feedDivMap3" style="width:50%; height: 50%; position: relative; float: left;">
<small style="height:10%;" id="textMap1">text3</small>
<div id="feedDivMap3" style="width:50%; height: 50%; position: relative; float: left; margin-top: 13px;">
<small style="height:10%;" id="textMap3">text3</small>
<img id="img3" src="{{ url_for('static', filename='maps/default.png') }}" style="width:98%;height:87%;">
</div>
<div id="feedDivMap4" style="width:50%; height: 50%; position: relative; float: left;">
<small style="height:10%;" id="textMap1">text4</small>
<div id="feedDivMap4" style="width:50%; height: 50%; position: relative; float: left; margin-top: 13px;">
<small style="height:10%;" id="textMap4">text4</small>
<img id="img4" src="{{ url_for('static', filename='maps/default.png') }}" style="width:98%;height:87%;">
</div>
</div>