From a44f8c23b6fcc82f49d6838471ccefba1fcfc5f2 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 3 Feb 2024 01:21:58 -0600 Subject: [PATCH 1/6] Add Alaska; improve travel-iq processing; update README --- layers/dot-cams/README.md | 104 +++++++++++++------------- layers/dot-cams/travel-iq/get_data.py | 19 ++++- 2 files changed, 69 insertions(+), 54 deletions(-) diff --git a/layers/dot-cams/README.md b/layers/dot-cams/README.md index 4ee53a9..fb1fcbb 100644 --- a/layers/dot-cams/README.md +++ b/layers/dot-cams/README.md @@ -5,58 +5,58 @@ Many states are through one of a few providers: * Castle Rock: https://www.castlerockits.com/oneweb * IBI Travel IQ: https://www.ibigroup.com/ibi-products/traveliq/ -| State | DOT Name[^name] | Online Service Name | Video? | Web provider | Link | -| ----- | --------------- | ------------------- | ------ | ------------ | ------------------------------- | -| AK | DOT&PF | | | Travel IQ | https://511.alaska.gov/ | -| AL | ALDOT | | | | | -| AR | ARDOT | | | | | -| AZ | ADOT | | | | | -| CA | Caltrans | | | | | -| CO | CDOT | | | | | -| CT | CTDOT | | | | | -| DE | DelDOT | | | | | -| FL | FDOT | | | | | -| GA | GDOT | | | | | -| HI | HDOT | | | | | -| IA | Iowa DOT | | | | | -| ID | ITD | | | | | -| IL | IDOT | | | | | -| IN | IDOT | | | | | -| KS | KDOT | | | | | -| KY | KYTC | | | | | -| LA | DOTD | | | | | -| MA | MassDOT | | | | | -| MD | MDOT | | | | | -| ME | MaineDOT | | | | | -| MI | MDOT | | | | | -| MN | MNDOT | 511MN | most | Castle Rock | https://511mn.org/ | -| MO | MoDOT | | | | https://traveler.modot.org/map/ | -| MS | MDOT | | | | | -| MT | MDT | | | | | -| NC | NCDOT | | | | | -| ND | NDDOT | | | | | -| NE | NDOT | | | | | -| NH | NHDOT | | | | | -| NJ | NJDOT | | | | | -| NM | NMDOT | | | | | -| NV | NDOT | | | | | -| NY | NYSDOT | | | | | -| OH | ODOT | | | | | -| OK | ODOT | | | | | -| OR | ODOT | | | | | -| PA | PennDOT | | | | | -| RI | RIDOT | | | | | -| SC | SCDOT | | | | | -| SD | SDDOT | | | | | -| TN | TDOT | | | | | -| TX | TxDOT | | | | | -| UT | UDOT | | | | | -| VA | VDOT | | | | | -| VT | VTrans | | | | | -| WA | WSDOT | | | | | -| WI | WisDOT | | | | | -| WV | WVDOT | | | | | -| WY | WYDOT | | | | | +| State | DOT Name[^name] | Online Service Name | Still | Video | Web provider | Link | +| ----- | --------------- | ------------------- | ----- | ----- | ------------ | ------------------------------- | +| AK | DOT&PF | Alaska 511 | 111 | 0 | Travel IQ | https://511.alaska.gov/ | +| AL | ALDOT | algotraffic | 0 | 568 | custom | https://algotraffic.com/cameras | +| AR | ARDOT | | | | | | +| AZ | ADOT | | | | | | +| CA | Caltrans | | | | | | +| CO | CDOT | | | | | | +| CT | CTDOT | | | | | | +| DE | DelDOT | | | | | | +| FL | FDOT | | | | | | +| GA | GDOT | 511GA | 1 | 3416 | Travel IQ | https://511ga.org/ | +| HI | HDOT | | | | | | +| IA | Iowa DOT | | | | | | +| ID | ITD | | | | | | +| IL | IDOT | | | | | | +| IN | IDOT | | | | | | +| KS | KDOT | | | | | | +| KY | KYTC | | | | | | +| LA | DOTD | 511 | 0 | 288 | Travel IQ | https://www.511la.org/ | +| MA | MassDOT | | | | | | +| MD | MDOT | | | | | | +| ME | MaineDOT | | | | | | +| MI | MDOT | | | | | | +| MN | MNDOT | 511MN | most | | Castle Rock | https://511mn.org/ | +| MO | MoDOT | | | | | https://traveler.modot.org/map/ | +| MS | MDOT | | | | | | +| MT | MDT | | | | | | +| NC | NCDOT | | | | | | +| ND | NDDOT | | | | | | +| NE | NDOT | | | | | | +| NH | NHDOT | | | | | | +| NJ | NJDOT | | | | | | +| NM | NMDOT | | | | | | +| NV | NDOT | Nevada 511 | 0 | 606 | Travel IQ | https://www.nvroads.com/ | +| NY | NYSDOT | 511NY | 369 | 1272 | Travel IQ | https://www.511ny.org/ | +| OH | ODOT | | | | | | +| OK | ODOT | | | | | | +| OR | ODOT | | | | | | +| PA | PennDOT | | | | | | +| RI | RIDOT | | | | | | +| SC | SCDOT | | | | | | +| SD | SDDOT | | | | | | +| TN | TDOT | | | | | | +| TX | TxDOT | | | | | | +| UT | UDOT | | | | | | +| VA | VDOT | | | | | | +| VT | VTrans | | | | | | +| WA | WSDOT | | | | | | +| WI | WisDOT | 511WI | 0 | 468 | Travel IQ | https://511wi.gov/ | +| WV | WVDOT | | | | | | +| WY | WYDOT | | | | | | [^name]: From https://en.wikipedia.org/wiki/Department_of_transportation#List_of_U.S._state_and_insular_area_departments_of_transportation diff --git a/layers/dot-cams/travel-iq/get_data.py b/layers/dot-cams/travel-iq/get_data.py index 29f49e1..05c3561 100755 --- a/layers/dot-cams/travel-iq/get_data.py +++ b/layers/dot-cams/travel-iq/get_data.py @@ -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 # From c12552541300f9babf510e4141d41c68cfb417b3 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 3 Feb 2024 01:36:11 -0600 Subject: [PATCH 2/6] Update README for castle-rock; improve nebraska workaround --- layers/dot-cams/README.md | 14 +++++++------- layers/dot-cams/castle-rock/get_data.py | 6 +++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/layers/dot-cams/README.md b/layers/dot-cams/README.md index fb1fcbb..f6dd2ef 100644 --- a/layers/dot-cams/README.md +++ b/layers/dot-cams/README.md @@ -12,30 +12,30 @@ Many states are through one of a few providers: | AR | ARDOT | | | | | | | AZ | ADOT | | | | | | | CA | Caltrans | | | | | | -| CO | CDOT | | | | | | +| CO | CDOT | COtrip | 832 | 686 | Castle Rock | https://maps.cotrip.org/ | | CT | CTDOT | | | | | | | DE | DelDOT | | | | | | | FL | FDOT | | | | | | | GA | GDOT | 511GA | 1 | 3416 | Travel IQ | https://511ga.org/ | | HI | HDOT | | | | | | -| IA | Iowa DOT | | | | | | +| IA | Iowa DOT | 511IA | 446 | 485 | Castle Rock | https://511ia.org/ | | ID | ITD | | | | | | | IL | IDOT | | | | | | -| IN | IDOT | | | | | | -| KS | KDOT | | | | | | +| IN | IDOT | TrafficWise | 0 | 640 | Castle Rock | https://511in.org/ | +| KS | KDOT | KanDrive | 382 | 167 | Castle Rock | https://www.kandrive.gov/ | | KY | KYTC | | | | | | | LA | DOTD | 511 | 0 | 288 | Travel IQ | https://www.511la.org/ | -| MA | MassDOT | | | | | | +| MA | MassDOT | Mass511 | 20 | 225 | Castle Rock | https://mass511.com/ | | MD | MDOT | | | | | | | ME | MaineDOT | | | | | | | MI | MDOT | | | | | | -| MN | MNDOT | 511MN | most | | Castle Rock | https://511mn.org/ | +| MN | MNDOT | 511MN | 647 | 1131 | Castle Rock | https://511mn.org/ | | MO | MoDOT | | | | | https://traveler.modot.org/map/ | | MS | MDOT | | | | | | | MT | MDT | | | | | | | NC | NCDOT | | | | | | | ND | NDDOT | | | | | | -| NE | NDOT | | | | | | +| NE | NDOT | Nebraska 511 | 919 | 0 | Castle Rock | https://new.511.nebraska.gov/ | | NH | NHDOT | | | | | | | NJ | NJDOT | | | | | | | NM | NMDOT | | | | | | diff --git a/layers/dot-cams/castle-rock/get_data.py b/layers/dot-cams/castle-rock/get_data.py index 4067bd7..1c811a8 100755 --- a/layers/dot-cams/castle-rock/get_data.py +++ b/layers/dot-cams/castle-rock/get_data.py @@ -65,7 +65,11 @@ for state, baseURL in states.items(): print(f"warn: Differing types detected: {c['views']}") if view['category'] == 'VIDEO': if state == "Nebraska": - print(c) + # Nebraska has mislabeled a small amount of their data; + # there is one location with 4 views labeled as "VIDEO" + # which are not, in fact, video-containing views + view['category'] = "PHOTO" + continue videoCount += 1 if len(view['sources']) != 1: raise Exception(f"Unexpected number of sources ({len(view['sources'])})") From 8f5803b5bc291b8de3475c8f2e4946bff2dbf5d5 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 3 Feb 2024 03:01:05 -0600 Subject: [PATCH 3/6] Add more Travel IQ dot cam states --- layers/dot-cams/README.md | 120 +++++++++++++------------- layers/dot-cams/travel-iq/get_data.py | 24 ++++-- 2 files changed, 76 insertions(+), 68 deletions(-) diff --git a/layers/dot-cams/README.md b/layers/dot-cams/README.md index f6dd2ef..c9a586d 100644 --- a/layers/dot-cams/README.md +++ b/layers/dot-cams/README.md @@ -5,64 +5,71 @@ Many states are through one of a few providers: * Castle Rock: https://www.castlerockits.com/oneweb * IBI Travel IQ: https://www.ibigroup.com/ibi-products/traveliq/ -| State | DOT Name[^name] | Online Service Name | Still | Video | Web provider | Link | -| ----- | --------------- | ------------------- | ----- | ----- | ------------ | ------------------------------- | -| AK | DOT&PF | Alaska 511 | 111 | 0 | Travel IQ | https://511.alaska.gov/ | -| AL | ALDOT | algotraffic | 0 | 568 | custom | https://algotraffic.com/cameras | -| AR | ARDOT | | | | | | -| AZ | ADOT | | | | | | -| CA | Caltrans | | | | | | -| CO | CDOT | COtrip | 832 | 686 | Castle Rock | https://maps.cotrip.org/ | -| CT | CTDOT | | | | | | -| DE | DelDOT | | | | | | -| FL | FDOT | | | | | | -| GA | GDOT | 511GA | 1 | 3416 | Travel IQ | https://511ga.org/ | -| HI | HDOT | | | | | | -| IA | Iowa DOT | 511IA | 446 | 485 | Castle Rock | https://511ia.org/ | -| ID | ITD | | | | | | -| IL | IDOT | | | | | | -| IN | IDOT | TrafficWise | 0 | 640 | Castle Rock | https://511in.org/ | -| KS | KDOT | KanDrive | 382 | 167 | Castle Rock | https://www.kandrive.gov/ | -| 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 | | | | | | -| ME | MaineDOT | | | | | | -| MI | MDOT | | | | | | -| MN | MNDOT | 511MN | 647 | 1131 | Castle Rock | https://511mn.org/ | -| MO | MoDOT | | | | | https://traveler.modot.org/map/ | -| MS | MDOT | | | | | | -| MT | MDT | | | | | | -| NC | NCDOT | | | | | | -| ND | NDDOT | | | | | | -| NE | NDOT | Nebraska 511 | 919 | 0 | Castle Rock | https://new.511.nebraska.gov/ | -| NH | NHDOT | | | | | | -| NJ | NJDOT | | | | | | -| NM | NMDOT | | | | | | -| NV | NDOT | Nevada 511 | 0 | 606 | Travel IQ | https://www.nvroads.com/ | -| NY | NYSDOT | 511NY | 369 | 1272 | Travel IQ | https://www.511ny.org/ | -| OH | ODOT | | | | | | -| OK | ODOT | | | | | | -| OR | ODOT | | | | | | -| PA | PennDOT | | | | | | -| RI | RIDOT | | | | | | -| SC | SCDOT | | | | | | -| SD | SDDOT | | | | | | -| TN | TDOT | | | | | | -| TX | TxDOT | | | | | | -| UT | UDOT | | | | | | -| VA | VDOT | | | | | | -| VT | VTrans | | | | | | -| WA | WSDOT | | | | | | -| WI | WisDOT | 511WI | 0 | 468 | Travel IQ | https://511wi.gov/ | -| WV | WVDOT | | | | | | -| WY | WYDOT | | | | | | +### State list + +| State | DOT Name[^name] | Online Service Name | Still | Video | Web provider | Link | +| ----- | --------------- | ------------------- | ----- | ----- | ------------ | --------------------------------- | +| AK | DOT&PF | Alaska 511 | 111 | 0 | Travel IQ | https://511.alaska.gov/ | +| AL | ALDOT | algotraffic | 0 | 568 | custom | https://algotraffic.com/cameras | +| AR | ARDOT | | | | | | +| AZ | ADOT | AZ511 | 602 | 0 | Travel IQ | https://az511.com/ | +| CA | Caltrans | | | | | | +| CO | CDOT | COtrip | 832 | 686 | Castle Rock | https://maps.cotrip.org/ | +| CT | CTDOT | CTroads | 350 | 0 | Travel IQ | https://ctroads.org/ | +| DE | DelDOT | | | | | | +| FL | FDOT | | | | | | +| GA | GDOT | 511GA | 1 | 3416 | Travel IQ | https://511ga.org/ | +| HI | HDOT | | | | | | +| IA | Iowa DOT | 511IA | 446 | 485 | Castle Rock | https://511ia.org/ | +| ID | ITD | Idaho 511 | 274 | 0 | Travel IQ | https://511.idaho.gov/ | +| IL | IDOT | | | | | | +| IN | IDOT | TrafficWise | 0 | 640 | Castle Rock | https://511in.org/ | +| KS | KDOT | KanDrive | 382 | 167 | Castle Rock | https://www.kandrive.gov/ | +| 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 | | | | | | +| ME | MaineDOT | | | | | | +| MI | MDOT | | | | | | +| MN | MNDOT | 511MN | 647 | 1131 | Castle Rock | https://511mn.org/ | +| MO | MoDOT | | | | | https://traveler.modot.org/map/ | +| MS | MDOT | | | | | | +| MT | MDT | | | | | | +| NC | NCDOT | | | | | | +| ND | NDDOT | | | | | | +| NE | NDOT | Nebraska 511 | 919 | 0 | Castle Rock | https://new.511.nebraska.gov/ | +| NH | NHDOT | | | | | | +| NJ | NJDOT | | | | | | +| NM | NMDOT | | | | | | +| NV | NDOT | Nevada 511 | 0 | 606 | Travel IQ | https://www.nvroads.com/ | +| NY | NYSDOT | 511NY | 369 | 1272 | Travel IQ | https://www.511ny.org/ | +| OH | ODOT | | | | | | +| OK | ODOT | | | | | | +| OR | ODOT | | | | | | +| PA | PennDOT | | | | | | +| RI | RIDOT | | | | | | +| SC | SCDOT | | | | | | +| SD | SDDOT | | | | | | +| TN | TDOT | | | | | | +| TX | TxDOT | | | | | | +| UT | UDOT | UDOT Traffic | 0 | 1787 | Travel IQ | https://www.udottraffic.utah.gov/ | +| VA | VDOT | | | | | | +| VT | VTrans | | | | | | +| WA | WSDOT | | | | | | +| WI | WisDOT | 511WI | 0 | 468 | Travel IQ | https://511wi.gov/ | +| WV | WVDOT | | | | | | +| WY | WYDOT | | | | | | [^name]: From https://en.wikipedia.org/wiki/Department_of_transportation#List_of_U.S._state_and_insular_area_departments_of_transportation +### Non-State aligned +* New England 511 (https://newengland511.org/) consolidates Maine, New Hampshire, and Vermont into one site (341 photo/0 video/Travel IQ) + + +### Notes https://map.wyoroad.info/wtimap/index.html @@ -128,14 +135,5 @@ https://dot.ca.gov/programs/traffic-operations/traveler-information/511 "rr": "https://riverregion511.org" castlerock - -No video, only photos ?? - "ak": "https://511.alaska.gov/", - "az": "https://az511.com/", - "ct": "https://ctroads.org/", - "new england": "https://newengland511.org/", - "id": "https://511.idaho.gov/", - "ut": "https://www.udottraffic.utah.gov/", - Some kind of signature needed: "fl": "https://fl511.com/", diff --git a/layers/dot-cams/travel-iq/get_data.py b/layers/dot-cams/travel-iq/get_data.py index 05c3561..ad5ff15 100755 --- a/layers/dot-cams/travel-iq/get_data.py +++ b/layers/dot-cams/travel-iq/get_data.py @@ -5,10 +5,15 @@ import json states = { "Alaska": "https://511.alaska.gov/", + "Arizona": "https://az511.com/", + "Connecticut": "https://ctroads.org/", "Georgia": "https://511ga.org/", + "Idaho": "https://511.idaho.gov/", "Louisiana": "https://www.511la.org/", "Nevada": "https://www.nvroads.com/", + "NewEngland": "https://newengland511.org/", "NewYork": "https://www.511ny.org/", + "Utah": "https://www.udottraffic.utah.gov/", "Wisconsin": "https://511wi.gov/" } @@ -54,18 +59,23 @@ for state, baseURL in states.items(): available_cameras = 999_999 # lots while len(cameras) < available_cameras: - res = requests.get(f"{baseURL}/List/GetData/Cameras", { - "query": json.dumps(query), - "lang": "en", - }) + if state == "Connecticut": + # gotta be a special snowflake I guess? + res = requests.post(f"{baseURL}/List/GetData/Cameras", json={"draw":1,"columns":[{"data":"sortId","name":"sortId","searchable":True,"orderable":True,"search":{"value":"","regex":False}},{"data":"cityName","name":"cityName","searchable":True,"orderable":True,"search":{"value":"","regex":False}},{"data":"roadway","name":"roadway","searchable":True,"orderable":True,"search":{"value":"","regex":False}},{"data":"sortIdDisplay","name":"sortIdDisplay","searchable":True,"orderable":True,"search":{"value":"","regex":False}},{"data":"description1","name":"description1","searchable":False,"orderable":True,"search":{"value":"","regex":False}},{"data":"direction","name":"direction","searchable":False,"orderable":False,"search":{"value":"","regex":False}},{"data":6,"name":"","searchable":False,"orderable":False,"search":{"value":"","regex":False}}],"order":[{"column":0,"dir":"asc"},{"column":1,"dir":"asc"}],"start":0,"length":10,"search":{"value":"","regex":False}}) + else: + res = requests.get(f"{baseURL}/List/GetData/Cameras", { + "query": json.dumps(query), + "lang": "en", + }) res.raise_for_status() res = res.json() available_cameras = res['recordsTotal'] for c in res['data']: - if isinstance(c['videoUrl'], list): # LA returns multiple (identical?) streams + if 'videoUrl' in c and isinstance(c['videoUrl'], list): # LA returns multiple (identical?) streams src = c['videoUrl'][0] video_camera_count += 1 - elif c['videoUrl']: + elif 'videoUrl' in c and c['videoUrl'] and c['videoUrl'] != '0': + # Yeah, Idaho has a single camera where videoURL = '0'. Nice. src = c['videoUrl'] video_camera_count += 1 else: @@ -81,7 +91,7 @@ for state, baseURL in states.items(): "properties": { 'name': c['displayName'], 'views': [{ - 'hasVideo': bool(c['videoUrl']), + 'hasVideo': 'videoUrl' in c and bool(c['videoUrl']), 'src': src, }], }, From c37ffbb353f9c4d3d676d8620f1c4d2897d332f2 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 3 Feb 2024 03:11:44 -0600 Subject: [PATCH 4/6] Add notes about known data errors --- layers/dot-cams/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/layers/dot-cams/README.md b/layers/dot-cams/README.md index c9a586d..09f17ed 100644 --- a/layers/dot-cams/README.md +++ b/layers/dot-cams/README.md @@ -137,3 +137,9 @@ https://dot.ca.gov/programs/traffic-operations/traveler-information/511 Some kind of signature needed: "fl": "https://fl511.com/", + + +### Known data errors +- WI sure has a lot of cameras on null island +- Nebraska has one camera located in California +- Several workarounds documented in code From a0675bc37653b4c3e364fcb6cf11ca0414651dde Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 3 Feb 2024 03:14:48 -0600 Subject: [PATCH 5/6] Add Delware cameras --- layers/dot-cams/README.md | 2 +- layers/dot-cams/de/get_data.py | 78 ++++++++++++++++++++++++++++++++++ layers/dot-cams/index.js | 2 + 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100755 layers/dot-cams/de/get_data.py diff --git a/layers/dot-cams/README.md b/layers/dot-cams/README.md index 09f17ed..52bc336 100644 --- a/layers/dot-cams/README.md +++ b/layers/dot-cams/README.md @@ -16,7 +16,7 @@ Many states are through one of a few providers: | CA | Caltrans | | | | | | | CO | CDOT | COtrip | 832 | 686 | Castle Rock | https://maps.cotrip.org/ | | CT | CTDOT | CTroads | 350 | 0 | Travel IQ | https://ctroads.org/ | -| DE | DelDOT | | | | | | +| DE | DelDOT | DelDOT Maps | 0 | 282 | Custom | https://deldot.gov/map/ | | FL | FDOT | | | | | | | GA | GDOT | 511GA | 1 | 3416 | Travel IQ | https://511ga.org/ | | HI | HDOT | | | | | | diff --git a/layers/dot-cams/de/get_data.py b/layers/dot-cams/de/get_data.py new file mode 100755 index 0000000..9458176 --- /dev/null +++ b/layers/dot-cams/de/get_data.py @@ -0,0 +1,78 @@ +#!/usr/bin/python3 + +import requests +import json + +cameras = [] + +res = requests.get("https://tmc.deldot.gov/json/videocamera.json") +res.raise_for_status() +# { +# "timestamp": "2024-02-03T09:00:50Z", +# "timestampMS": "1706950850013", +# "version": "1.1", +# "uid": "-8569684966613574390", +# "status": "normal", +# "message": "", +# "cameraCount": 282, +# "cameraHash": "-1859423038", +# "videoCameras": [ +# { +# "urls": { +# "rtmp": "rtmpt://167.21.72.35:80/live/KCAM001.stream", +# "rtsp": "rtsp://167.21.72.35:554/live/KCAM001.stream", +# "f4m": "http://167.21.72.35:1935/live/KCAM001.stream/manifest.f4m", +# "m3u8": "http://167.21.72.35:1935/live/KCAM001.stream/playlist.m3u8", +# "m3u8s": "https://video.deldot.gov:443/live/KCAM001.stream/playlist.m3u8", +# "mssmooth": "http://167.21.72.35:1935/live/KCAM001.stream/Manifest" +# }, +# "id": "KCAM001", +# "title": "DE 1 @ MILFORD NECK ROAD (NORTH OFF)", +# "county": "Kent", +# "lat": 38.990771, +# "lon": -75.448487, +# "hash": "966393601", +# "enabled": true +# }, +# ... + +for c in res.json()['videoCameras']: + try: + if not c['enabled']: + print("warn: camera disabled; ignoring:", c) + continue + if not c['urls']['m3u8s'].startswith('https://'): + raise Exception("invalid hlsUrl") + cameras.append({ + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [c['lon'], c['lat']], # yes, [lon, lat] since it's [x, y] + }, + "properties": { + "name": c['title'], + "views": [ + { + 'hasVideo': True, + 'src': c['urls']['m3u8s'], + }, + # { + # '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") diff --git a/layers/dot-cams/index.js b/layers/dot-cams/index.js index 1d5ee46..92ba4da 100644 --- a/layers/dot-cams/index.js +++ b/layers/dot-cams/index.js @@ -13,6 +13,7 @@ import pinVideo from './pin-video.svg?url'; // TODO: remove `?url`? 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 dot_names from './layer_names.js'; @@ -20,6 +21,7 @@ const allStates = { ...castleRockStates, ...travelIqStates, 'Alabama': al, + 'Delaware': de, }; let dot_cams = { From cc4a8cca8e42a492c03a105a6d115db707ace26e Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 3 Feb 2024 03:30:10 -0600 Subject: [PATCH 6/6] 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")