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
|
|
@ -7,18 +7,60 @@ cameras = []
|
|||
|
||||
res = requests.get("https://api.algotraffic.com/v3.0/Cameras")
|
||||
res.raise_for_status()
|
||||
# {
|
||||
# "id": 1164,
|
||||
# "location": {
|
||||
# "latitude": 30.56705,
|
||||
# "longitude": -88.19211,
|
||||
# "city": "Theodore",
|
||||
# "county": "Mobile",
|
||||
# "displayRouteDesignator": "I-10",
|
||||
# "routeDesignator": "I-10",
|
||||
# "routeDesignatorType": "Interstate",
|
||||
# "displayCrossStreet": "Theodore Dawes Rd",
|
||||
# "crossStreet": "Theodore Dawes Rd",
|
||||
# "crossStreetType": "Arterial",
|
||||
# "direction": "East",
|
||||
# "linearReference": 14.0
|
||||
# },
|
||||
# "responsibleRegion": "Southwest",
|
||||
# "hlsUrl": "https://cdn3.wowza.com/5/aTZuSEJVaHcxakdx/mobile-fastly/mob-cam-c090.stream/playlist.m3u8",
|
||||
# "imageUrl": "https://api.algotraffic.com/v3/Cameras/1164/snapshot.jpg",
|
||||
# "accessLevel": "Public"
|
||||
# }
|
||||
|
||||
for c in res.json():
|
||||
cameras.append({
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [c['location']['longitude'], c['location']['latitude']], # yes, [lon, lat] since it's [x, y]
|
||||
},
|
||||
"properties": {
|
||||
'originalData': c,
|
||||
},
|
||||
})
|
||||
try:
|
||||
if c['accessLevel'] != 'Public':
|
||||
print("warn: access level is not public; ignoring:", c)
|
||||
continue
|
||||
if not c['hlsUrl'].startswith('https://'):
|
||||
raise Exception("invalid hlsUrl")
|
||||
if not c['imageUrl'].startswith('https://'):
|
||||
raise Exception("invalid imageUrl")
|
||||
cameras.append({
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [c['location']['longitude'], c['location']['latitude']], # yes, [lon, lat] since it's [x, y]
|
||||
},
|
||||
"properties": {
|
||||
"name": c['location']['displayRouteDesignator'] + '/' + c['location']['displayCrossStreet'],
|
||||
"views": [
|
||||
{
|
||||
'hasVideo': True,
|
||||
'src': c['hlsUrl'],
|
||||
},
|
||||
# {
|
||||
# 'hasVideo': False,
|
||||
# 'src': c['imageUrl'],
|
||||
# }
|
||||
]
|
||||
},
|
||||
})
|
||||
except Exception as e:
|
||||
print(c)
|
||||
raise e
|
||||
|
||||
geojson = {
|
||||
"type": "FeatureCollection",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue