|
@@ -1,3 +1,4 @@
|
|
|
|
|
+import sys
|
|
|
import commute
|
|
import commute
|
|
|
import config
|
|
import config
|
|
|
import db
|
|
import db
|
|
@@ -33,6 +34,8 @@ def _write_styles(f):
|
|
|
hexvalue = '0' + hexvalue
|
|
hexvalue = '0' + hexvalue
|
|
|
f.write('<Style id="color-%i"><IconStyle><color>ff%s%sff</color></IconStyle></Style>\n' % (i, hexvalue, hexvalue))
|
|
f.write('<Style id="color-%i"><IconStyle><color>ff%s%sff</color></IconStyle></Style>\n' % (i, hexvalue, hexvalue))
|
|
|
|
|
|
|
|
|
|
+ f.write('<Style id="color-green"><IconStyle><color>ff00ff00</color></IconStyle></Style>\n')
|
|
|
|
|
+
|
|
|
def _write_commutes(f, commutes):
|
|
def _write_commutes(f, commutes):
|
|
|
f.write('<Folder><name>Commutes</name><visibility>0</visibility>\n')
|
|
f.write('<Folder><name>Commutes</name><visibility>0</visibility>\n')
|
|
|
max_duration = min(4000, max([x['duration'] for x in commutes.values()]))
|
|
max_duration = min(4000, max([x['duration'] for x in commutes.values()]))
|
|
@@ -59,9 +62,13 @@ def _write_properties(f, properties_dict, tmp_ids):
|
|
|
min_max_delta = max_score - min_score
|
|
min_max_delta = max_score - min_score
|
|
|
|
|
|
|
|
for pid, data in properties_list:
|
|
for pid, data in properties_list:
|
|
|
- value = ((data['score'] - min_score) / min_max_delta) if min_max_delta else 1
|
|
|
|
|
- value = min(1, value)
|
|
|
|
|
- color = 20 + value * 235
|
|
|
|
|
|
|
+ color = None
|
|
|
|
|
+ if data['favourite']:
|
|
|
|
|
+ color = 'green'
|
|
|
|
|
+ else:
|
|
|
|
|
+ value = ((data['score'] - min_score) / min_max_delta) if min_max_delta else 1
|
|
|
|
|
+ value = min(1, value)
|
|
|
|
|
+ color = int(20 + value * 235)
|
|
|
|
|
|
|
|
title = '%.0f-%.0f-%s-%i' % (data['price'], data['size'], data.get('ber', ''), tmp_ids[pid])
|
|
title = '%.0f-%.0f-%s-%i' % (data['price'], data['size'], data.get('ber', ''), tmp_ids[pid])
|
|
|
|
|
|
|
@@ -84,7 +91,7 @@ def _write_properties(f, properties_dict, tmp_ids):
|
|
|
|
|
|
|
|
f.write('''<Placemark>
|
|
f.write('''<Placemark>
|
|
|
<Point><coordinates>%f,%f</coordinates></Point>
|
|
<Point><coordinates>%f,%f</coordinates></Point>
|
|
|
- <styleUrl>#color-%i</styleUrl>
|
|
|
|
|
|
|
+ <styleUrl>#color-%s</styleUrl>
|
|
|
<name>%s</name>
|
|
<name>%s</name>
|
|
|
<description><![CDATA[ %s ]]></description>
|
|
<description><![CDATA[ %s ]]></description>
|
|
|
</Placemark>\n''' % (data['loc'][1], data['loc'][0], color, title, description))
|
|
</Placemark>\n''' % (data['loc'][1], data['loc'][0], color, title, description))
|
|
@@ -128,7 +135,8 @@ def _set_tmp_ids(properties_dict):
|
|
|
return res
|
|
return res
|
|
|
|
|
|
|
|
def run():
|
|
def run():
|
|
|
- load_since = datetime.datetime.now() - datetime.timedelta(days=365)
|
|
|
|
|
|
|
+ days = int(sys.argv[1]) if len(sys.argv) > 1 else 31
|
|
|
|
|
+ load_since = datetime.datetime.now() - datetime.timedelta(days=days)
|
|
|
properties_dict = properties.load_properties(True, load_since)
|
|
properties_dict = properties.load_properties(True, load_since)
|
|
|
print('Loaded %i properties' % len(properties_dict))
|
|
print('Loaded %i properties' % len(properties_dict))
|
|
|
|
|
|