aboutsummaryrefslogtreecommitdiff
path: root/dev/nyc
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2020-06-06 10:11:12 -0600
committerMelody Horn <melody@boringcactus.com>2020-06-06 10:11:12 -0600
commitfd1b7e50bec5c28a9f6dcef7a147dd79b891c20c (patch)
treee45ee899f31b5d12897391a7065e1c32da8fb26d /dev/nyc
parent2c855db95b2f81bcc28a8d6f9c0d622810d76852 (diff)
downloadpig.observer-fd1b7e50bec5c28a9f6dcef7a147dd79b891c20c.tar.gz
pig.observer-fd1b7e50bec5c28a9f6dcef7a147dd79b891c20c.zip
persist coordinates alongside camera info
Diffstat (limited to 'dev/nyc')
-rw-r--r--dev/nyc/convert.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/dev/nyc/convert.py b/dev/nyc/convert.py
index 4b00bfa..2f21861 100644
--- a/dev/nyc/convert.py
+++ b/dev/nyc/convert.py
@@ -9,16 +9,17 @@ data = raw_data['markers']
sources = []
for camera in data:
- result = dict()
- result['id'] = camera['id']
- result['name'] = camera['content']
+ coord = [float(camera['latitude']), float(camera['longitude'])]
+ cam = dict()
+ cam['id'] = camera['id']
+ cam['name'] = camera['content']
fetched = requests.get('https://nyctmc.org/google_popup.php', params={'cid': camera['id']})
match = re.search('http://207.251.86.238/cctv\\d+.jpg', fetched.text)
if match is None:
pprint(camera)
continue
url = match.group()
- result['url'] = url
- sources.append(result)
+ cam['url'] = url
+ sources.append({'coord': coord, 'cams': [cam]})
with open('sources.json', 'w') as f:
json.dump({'NYC': sources}, f)