Refactor DOT cam layers; misc features
* Add more travel-iq states * Combine DOT cam layer UI into single place * Use standard schema for cam data * Differentiate between photo and video cameras
This commit is contained in:
parent
710930f428
commit
dbcd151364
16 changed files with 324 additions and 276 deletions
|
|
@ -4,13 +4,21 @@ import requests
|
|||
import json
|
||||
import re
|
||||
|
||||
with open('states.json') as f:
|
||||
states = json.loads(f.read())
|
||||
states = {
|
||||
"Minnesota": "https://511mn.org/",
|
||||
"Colorado": "https://maps.cotrip.org/",
|
||||
"Iowa": "https://511ia.org/",
|
||||
"Indiana": "https://511in.org/",
|
||||
"Kansas": "https://www.kandrive.gov/",
|
||||
"Massachusetts": "https://mass511.com/",
|
||||
"Nebraska": "https://new.511.nebraska.gov/"
|
||||
}
|
||||
|
||||
with open("query.graphql") as f:
|
||||
QUERY = f.read()
|
||||
|
||||
for state, baseURL in states.items():
|
||||
print(f"{state}: ", end="", flush=True)
|
||||
PAYLOAD = [
|
||||
{
|
||||
"query": QUERY,
|
||||
|
|
@ -38,6 +46,8 @@ for state, baseURL in states.items():
|
|||
cameras = []
|
||||
|
||||
viewCount = 0
|
||||
photoCount = 0
|
||||
videoCount = 0
|
||||
|
||||
for c in camera_views:
|
||||
if len(c['features']) != 1:
|
||||
|
|
@ -47,22 +57,36 @@ for state, baseURL in states.items():
|
|||
if re.match(r"Show .* cameras", c['tooltip']):
|
||||
raise Exception(f"Not zoomed in enough! Finding aggregate cameras: {c}")
|
||||
|
||||
if len(c['views']) == 0:
|
||||
raise Exception("Camera has no views")
|
||||
|
||||
for view in c['views']:
|
||||
if len(view['sources']) != 1 if view['category'] == 'VIDEO' else 0:
|
||||
print(view)
|
||||
raise Exception(f"Unexpected number of sources ({len(view['sources'])})")
|
||||
if view['category'] != c['views'][0]['category']:
|
||||
print(f"warn: Differing types detected: {c['views']}")
|
||||
if view['category'] == 'VIDEO':
|
||||
if state == "Nebraska":
|
||||
print(c)
|
||||
videoCount += 1
|
||||
if len(view['sources']) != 1:
|
||||
raise Exception(f"Unexpected number of sources ({len(view['sources'])})")
|
||||
else:
|
||||
photoCount += 1
|
||||
for source in view['sources'] or []:
|
||||
if source['type'] != 'application/x-mpegURL':
|
||||
raise Exception(f"Unexpected type {source['type']}")
|
||||
|
||||
viewCount += len(c['views'])
|
||||
cameras.append({
|
||||
"type": "Feature",
|
||||
"geometry": c['features'][0]['geometry'],
|
||||
"properties": {
|
||||
'address': c['tooltip'],
|
||||
'website': c['views'][0]['url'],
|
||||
'originalData': c,
|
||||
'name': c['tooltip'],
|
||||
'views': [
|
||||
{
|
||||
'hasVideo': v['category'] == 'VIDEO',
|
||||
'src': v['sources'][0]['src'] if v['category'] == 'VIDEO' else v['url'],
|
||||
} for v in c['views']
|
||||
],
|
||||
# 'originalData': c,
|
||||
},
|
||||
})
|
||||
|
||||
|
|
@ -74,8 +98,8 @@ for state, baseURL in states.items():
|
|||
with open(f"data/{state}.geojson", "w") as f:
|
||||
f.write(json.dumps(geojson))
|
||||
|
||||
print(f"{len(cameras)} locations found for {state}")
|
||||
print(f"{viewCount} total views for {state}")
|
||||
print(f"{len(cameras)} locations found")
|
||||
print(f"{state}: {photoCount} photo + {videoCount} video cameras")
|
||||
|
||||
# hack hack hack
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue