From fd1b7e50bec5c28a9f6dcef7a147dd79b891c20c Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sat, 6 Jun 2020 10:11:12 -0600 Subject: persist coordinates alongside camera info --- dev/nyc/convert.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'dev/nyc') 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) -- cgit v1.2.3