Repo for non destructive e-scooter intervention materials
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.7 KiB

4 years ago
import folium
import requests
import json
4 years ago
import subprocess
from datetime import datetime
from glob import glob
4 years ago
def application():
#create map object
m = folium.Map(location=[52.516190, 13.377693], tiles='Stamen Toner',zoom_start=13, zoom_control=False, max_zoom=25)
#make api request (writes api responses to json)
subprocess.call(['sh','./scooter_locations.sh'])
#import scooter data
scooter_counter = 1
for file in glob('Scooters/*.json'):
print ('importing data of scooter nr.' + str(scooter_counter) + '/10')
with open(file, 'r') as scooter_location:
location_data=scooter_location.read()
#print(location_data)
location_data_json = json.loads(location_data)
#print(location_data_json)
lat = location_data_json['data']['attributes']['lat']
#print(lat)
lng = location_data_json['data']['attributes']['lng']
#print(lng)
print('imported. moving on...')
#create markers for scooter
print('creating marker for scooter nr.' + str(scooter_counter) + '/10')
folium.Marker([lat,lng],
popup='<strong>ARTWORK_TITLE<br>short descriptive one liner about the work<strong/>',
tooltip='ARTIST_NAME_HERE',
icon=folium.Icon(color='purple', icon='remove')).add_to(m)
print('created. moving on...')
scooter_counter = scooter_counter+1
#generate map.html
m.save('map.html')
#adding mobile support
m.get_root().header.add_child(folium.Element(
'<meta name="viewport" content="width=device-width,'
' initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />'
))
#saving timestamp
print('generating timestamp')
with open('datetime.txt', 'w') as timestamp:
timestamp.write(str(datetime.now()))
print('finished!')
application()