From cc4a8cca8e42a492c03a105a6d115db707ace26e Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 3 Feb 2024 03:30:10 -0600 Subject: [PATCH] Add Maryland DOT cameras --- layers/dot-cams/README.md | 4 +- layers/dot-cams/index.js | 2 + layers/dot-cams/md/get_data.py | 74 ++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100755 layers/dot-cams/md/get_data.py diff --git a/layers/dot-cams/README.md b/layers/dot-cams/README.md index 52bc336..0852bcc 100644 --- a/layers/dot-cams/README.md +++ b/layers/dot-cams/README.md @@ -28,7 +28,7 @@ Many states are through one of a few providers: | KY | KYTC | | | | | | | LA | DOTD | 511 | 0 | 288 | Travel IQ | https://www.511la.org/ | | MA | MassDOT | Mass511 | 20 | 225 | Castle Rock | https://mass511.com/ | -| MD | MDOT | | | | | | +| MD | MDOT | CHART | 0 | 538 | Custom | https://chart.maryland.gov/ | | ME | MaineDOT | | | | | | | MI | MDOT | | | | | | | MN | MNDOT | 511MN | 647 | 1131 | Castle Rock | https://511mn.org/ | @@ -122,8 +122,6 @@ https://www.511virginia.org/ https://wv511.org/ -https://chart.maryland.gov/TrafficCameras/GetTrafficCameras - http://goakamai.org/cameras diff --git a/layers/dot-cams/index.js b/layers/dot-cams/index.js index 92ba4da..166c0ec 100644 --- a/layers/dot-cams/index.js +++ b/layers/dot-cams/index.js @@ -14,6 +14,7 @@ import castleRockStates from './castle-rock/data/states.js'; import travelIqStates from './travel-iq/data/states.js'; import al from './al/data.geojson?url'; import de from './de/data.geojson?url'; +import md from './md/data.geojson?url'; import dot_names from './layer_names.js'; @@ -22,6 +23,7 @@ const allStates = { ...travelIqStates, 'Alabama': al, 'Delaware': de, + 'Maryland': md, }; let dot_cams = { diff --git a/layers/dot-cams/md/get_data.py b/layers/dot-cams/md/get_data.py new file mode 100755 index 0000000..402b405 --- /dev/null +++ b/layers/dot-cams/md/get_data.py @@ -0,0 +1,74 @@ +#!/usr/bin/python3 + +import requests +import json + +cameras = [] + +res = requests.get("https://chartexp1.sha.maryland.gov/CHARTExportClientService/getCameraMapDataJSON.do") +res.raise_for_status() +# { +# "error": null, +# "data": [ +# { +# "description": "I-270 & Old Hundred Rd (MD 109)(CAM 165)", +# "lat": 39.2773, +# "lon": -77.3236, +# "cctvIp": "strmr5.sha.maryland.gov", +# "milePost": 22.27, +# "cameraCategories": [ +# "Wash. DC" +# ], +# "routeNumber": 270, +# "commMode": "ONLINE", +# "routePrefix": "IS", +# "routeSuffix": "", +# "opStatus": "OK", +# "publicVideoURL": "https://chart.maryland.gov/Video/GetVideo/7a00a1dc01250075004d823633235daa", +# "lastCachedDataUpdateTime": 1706950514352, +# "name": "I-270 & Old Hundred Rd (MD 109)", +# "id": "7a00a1dc01250075004d823633235daa" +# }, + +for c in res.json()['data']: + try: + # # 50-ish are marginal; let's ignore that and put 'em on the map anyway + # if not c['commMode'] == "ONLINE": + # print("warn: camera offline; ignoring:", c) + # continue + # if not c['opStatus'] == "OK": + # print("warn: camera not ok; ignoring:", c) + # continue + cameras.append({ + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [c['lon'], c['lat']], # yes, [lon, lat] since it's [x, y] + }, + "properties": { + "name": c['description'], + "views": [ + { + 'hasVideo': True, + 'src': f"https://{c['cctvIp']}/rtplive/{c['id']}/playlist.m3u8", + }, + # { + # 'hasVideo': False, + # 'src': c['imageUrl'], + # } + ] + }, + }) + except Exception as e: + print(c) + raise e + +geojson = { + "type": "FeatureCollection", + "features": cameras, +} + +with open("data.geojson", "w") as f: + f.write(json.dumps(geojson)) + +print(f"{len(cameras)} locations found")