|
|
@@ -47,36 +47,35 @@ def _write_commutes(f, commutes):
|
|
|
|
|
|
def _write_properties(f, properties_dict):
|
|
|
f.write('<Folder><name>Properties</name><visibility>0</visibility>\n')
|
|
|
- max_score = max(x['score'] for x in properties_dict.values())
|
|
|
+
|
|
|
properties_list = list(properties_dict.items())
|
|
|
-
|
|
|
- # properties_list.sort(key=lambda x: x[1]['score'], reverse=True)
|
|
|
- import random
|
|
|
- random.shuffle(properties_list)
|
|
|
+ properties_list.sort(key=lambda x: x[1]['score'], reverse=True)
|
|
|
+ # properties_list = properties_list[:1000]
|
|
|
|
|
|
- for i, (pid, data) in enumerate(properties_list[:500]):
|
|
|
- color = 20 + (int((data['score']/float(max_score)) * 236) if max_score else 0)
|
|
|
- color = min(color, 255)
|
|
|
+ min_score = max(0, min(x['score'] for x in properties_dict.values()))
|
|
|
+ max_score = max(x['score'] for x in properties_dict.values())
|
|
|
+ min_max_delta = max_score - min_score
|
|
|
|
|
|
- # color = 20 + int(236*(float(i)/len(properties_list)))
|
|
|
+ for pid, data in properties_list:
|
|
|
+ value = (data['score'] - min_score) / min_max_delta
|
|
|
+ value = min(1, value)
|
|
|
+ color = 20 + value * 235
|
|
|
|
|
|
- title = ','.join([str(x) for x in [
|
|
|
- int(data['price']),
|
|
|
- data['size'],
|
|
|
- ]])
|
|
|
+ title = '%.0f-%.0f' % (data['price'], data['size'])
|
|
|
|
|
|
description = '<br>\n'.join([
|
|
|
'https://www.myhome.ie/_/brochure/_/%i' % pid,
|
|
|
'',
|
|
|
'Price: %s (%.3f)' % (data.get('price', '---'), ranking.r_price(data.get('price'))),
|
|
|
'Size: %s (%.3f)' % (int(data.get('size', 0)), ranking.r_size(data.get('size'))),
|
|
|
- 'Bedrooms: %s' % data.get('bedrooms', '---'),
|
|
|
+ 'Bedrooms: %s (%.3f)' % (data.get('bedrooms') or '---', ranking.r_bedrooms(data.get('bedrooms'))),
|
|
|
+ 'BER: %s (%.3f)' % (data.get('ber') or '---', ranking.r_ber(data.get('ber'))),
|
|
|
])
|
|
|
|
|
|
total_duration = sum(x['duration'] for x in data.get('commute_path', []))
|
|
|
|
|
|
- description += '<br>\nCommute: %i (%.3f)<br>' % (total_duration, ranking.r_commute_duration(total_duration))
|
|
|
- description += '<br>\n'.join([(' %i: %s' % (x['duration'], (x.get('desc') or x['mode']).replace('>','>').replace('<', '<')))
|
|
|
+ description += '<br>\nCommute: %.1f (%.3f)<br>' % (total_duration/60.0, ranking.r_commute_duration(total_duration))
|
|
|
+ description += '<br>\n'.join([(' %.1f: %s' % (x['duration']/60.0, (x.get('desc') or x['mode']).replace('>','>').replace('<', '<')))
|
|
|
for x in reversed(data.get('commute_path', []))])
|
|
|
|
|
|
f.write('''<Placemark>
|
|
|
@@ -122,6 +121,8 @@ def run():
|
|
|
|
|
|
properties_dict = {k: v for k, v in properties_dict.items() if v['score'] > 0}
|
|
|
|
|
|
+ print('Loaded %i locations with score>0' % len(properties_dict))
|
|
|
+
|
|
|
_write_kml(commutes, properties_dict, 'vis.kml')
|
|
|
|
|
|
if __name__ == '__main__':
|