Add Alaska; improve travel-iq processing; update README

This commit is contained in:
Chandler Swift 2024-02-03 01:21:58 -06:00
parent 0065c7f4f5
commit a44f8c23b6
Signed by: chandlerswift
GPG key ID: A851D929D52FB93F
2 changed files with 69 additions and 54 deletions

View file

@ -4,6 +4,7 @@ import requests
import json
states = {
"Alaska": "https://511.alaska.gov/",
"Georgia": "https://511ga.org/",
"Louisiana": "https://www.511la.org/",
"Nevada": "https://www.nvroads.com/",
@ -46,6 +47,9 @@ for state, baseURL in states.items():
"length": 100,
}
video_camera_count = 0
still_camera_count = 0
cameras = []
available_cameras = 999_999 # lots
@ -58,6 +62,16 @@ for state, baseURL in states.items():
res = res.json()
available_cameras = res['recordsTotal']
for c in res['data']:
if isinstance(c['videoUrl'], list): # LA returns multiple (identical?) streams
src = c['videoUrl'][0]
video_camera_count += 1
elif c['videoUrl']:
src = c['videoUrl']
video_camera_count += 1
else:
src = baseURL + "map/Cctv/" + c['id']
still_camera_count += 1
cameras.append({
"type": "Feature",
"geometry": {
@ -67,8 +81,8 @@ for state, baseURL in states.items():
"properties": {
'name': c['displayName'],
'views': [{
'hasVideo': c['videoUrl'],
'src': c['videoUrl'][0] if isinstance(c['videoUrl'], list) else c['videoUrl'], # LA returns multiple (identical?) streams
'hasVideo': bool(c['videoUrl']),
'src': src,
}],
},
})
@ -83,6 +97,7 @@ for state, baseURL in states.items():
f.write(json.dumps(geojson))
print(f"{len(cameras)} locations found for {state}")
print(f"{state}: {still_camera_count} photo + {video_camera_count} video cameras")
# hack hack hack
#