-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.py
22 lines (16 loc) · 1.04 KB
/
make.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python3
import os
buildings_dir = './data/buildings/'
buildings_color = {'stadt': '#FF0000'}
#L.polygon([[51.460852,6.945248],[51.458285,6.957264],[51.449942,6.953487],[51.450905,6.946106]], { weight: 0, fillColor: '#ff0000', fillOpacity: 0.4 }).addTo(map).bindPopup("I am a polygon.");
def make_leaflet():
add = []
buildingsdir = './data/buildings/'
for (dirpath, dirnames, filenames) in os.walk('./data/buildings/'):
for filename in filenames:
data = open(os.path.join(dirpath, filename)).read()
title, latlng, description = data.split('\n', 2)
add.append("L.polygon(%s, {weight: 3, color: '%s', fillColor: '%s', fillOpacity: 0.4}).addTo(map).bindPopup('<strong>%s</strong><br><br>%s');" % (latlng, buildings_color[dirpath[len(buildingsdir):]], buildings_color[dirpath[len(buildingsdir):]], title, description.strip().replace('\n', '<br>')))
open('index.html', 'w').write(open('index.tpl.html').read().replace('/* add */', '\n'.join(add)))
if __name__ == '__main__':
make_leaflet()