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/georgia/convert.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'dev/georgia') diff --git a/dev/georgia/convert.py b/dev/georgia/convert.py index 10633e1..f734030 100644 --- a/dev/georgia/convert.py +++ b/dev/georgia/convert.py @@ -1,17 +1,16 @@ import json from pprint import pprint -from collections import defaultdict with open('cctv.json', 'r') as f: raw_data = json.load(f) cameras = raw_data['features'] -sources = defaultdict(list) +sources = [] for camera in cameras: - subdiv = camera['properties']['subdivision'] - result = dict() - result['id'] = camera['properties']['cctv_id'] + coord = [float(x) for x in camera['geometry']['coordinates']] + cam = dict() + cam['id'] = camera['properties']['cctv_id'] if 'HLS' in camera['properties']: url = camera['properties']['HLS'] url = url.replace('http://vss1live.dot.ga.gov:80/lo', '/georgiavss1') @@ -19,14 +18,14 @@ for camera in cameras: url = url.replace('http://vss3live.dot.ga.gov:80/lo', '/georgiavss3') url = url.replace('http://vss4live.dot.ga.gov:80/lo', '/georgiavss4') url = url.replace('http://vss5live.dot.ga.gov:80/lo', '/georgiavss5') - result['stream'] = url + cam['stream'] = url elif camera['properties']['url'] is not None: url = camera['properties']['url'] url = url.replace('http://navigator-c2c.dot.ga.gov/snapshots', '/georgiasnapshots') - result['url'] = url + cam['url'] = url else: continue - result['name'] = camera['properties']['location_description'] - sources[subdiv].append(result) + cam['name'] = camera['properties']['location_description'] + sources.append({'coord': coord, 'cams': [cam]}) with open('sources.json', 'w') as f: - json.dump(dict(sources), f) + json.dump(sources, f) -- cgit v1.2.3