Last active
February 22, 2017 04:55
-
-
Save vielmetti/c69e5197c656a2615cf406e63db62bc0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python -u | |
import sys | |
import geojson | |
import json | |
import urllib3 | |
http = urllib3.PoolManager() | |
r = http.request('GET', 'http://www.a2dda.org/map/AADDACount.json') | |
a2dda = json.loads(r.data.decode('utf-8')) | |
features = [] | |
garagedict = { "86": { "garage": "Ann-Ashley", "address": "220 N. Ashley", | |
"lat": 42.2825859 , "lon": -83.7496809}, | |
"80": { "garage": "Fourth and Washington", "address": "123 E. Washington", | |
"lat": 42.2804988 , "lon": -83.7478584 }, | |
"83": { "garage": "Forest", "address": "650 S. Forest", | |
"lat": 42.2740834 , "lon": -83.733664 }, | |
"84": { "garage": "Fourth and William", "address": "115 E. William", | |
"lat": 42.2781412, "lon": -83.7478005 }, | |
"82": { "garage": "Maynard", "address": "324 Maynard", | |
"lat": 42.2786736, "lon": -83.7426345}, | |
"85": { "garage": "Liberty Square", "address": "510 E. Washington", | |
"lat": 42.2799723, "lon": -83.7426013}, | |
"88": { "garage": "S. Ashley Lot", "address": "305 S. Ashley", | |
"lat": 42.2793726, "lon": -83.7498497}, | |
"89": { "garage": "First and Huron", "address": "201 W. Huron", | |
"lat": 42.2814443, "lon": -83.7498116}, | |
"87": { "garage": "Library Lane", "address": "319 S. Fifth Ave.", | |
"lat": 42.278754, "lon": -83.745565}, | |
"81": { "garage": "First and Washington", "address": "201 S. First", | |
"lat": 42.2805561, "lon": -83.7510042}, | |
"87 S": {}, | |
} | |
for countdata in a2dda["countdata"]: | |
garagedict[countdata["facility"]]["timestamp"]=countdata["timestamp"] | |
garagedict[countdata["facility"]]["spacesavail"]=countdata["spacesavail"] | |
for garage in ["80","81","82","83","84","85","86","87","88","89"]: | |
lat = garagedict[garage]["lat"] | |
lon = garagedict[garage]["lon"] | |
point = geojson.Point([lon,lat]) | |
feature = geojson.Feature(geometry=point, | |
id=garage, | |
properties=garagedict[garage]) | |
features.append(feature) | |
geofile = geojson.FeatureCollection(features) | |
dump = json.dumps(geofile) | |
print(dump) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment