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.
 
 
 
 
 
 

47 lines
1.3 KiB

import folium
import requests
import json
import subprocess
from datetime import datetime
from glob import glob
#create map object
m = folium.Map(location=[52.516190, 13.377693], tiles='Stamen Toner',zoom_start=13)
#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>ARTIST_NAME + ARTWORK_TITLE<strong/>',
tooltip='ARTIST_NAME_HERE',
icon=folium.Icon(icon='cloud')).add_to(m)
print('created. moving on...')
scooter_counter = scooter_counter+1
#generate map.html
m.save('map.html')
#saving timestamp
print('generating timestamp')
with open('datetime.txt', 'w') as timestamp:
timestamp.write(str(datetime.now()))
print('finished!')