Skip to content

Modernize Tennessee and Washington #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OpenTrafficCamMap
A crowdsourced database of 7515 traffic cameras.
A crowdsourced database of 9883 traffic cameras.

[Checkout the interactive map!](http://otc.armchairresearch.org/map)

Expand Down
2 changes: 1 addition & 1 deletion cameras/USA.json

Large diffs are not rendered by default.

50 changes: 0 additions & 50 deletions compilation/OhioGo.js

This file was deleted.

55 changes: 0 additions & 55 deletions compilation/TennesseeSW.js

This file was deleted.

35 changes: 35 additions & 0 deletions compilation/USA/hawaiiTC.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

class Camera {
constructor ( cam ) {
this.description = cam.description;
this.latitude = cam.location.coordinates.latitude;
this.longitude = cam.location.coordinates.longitude;

const lastImage = cam.images[cam.images.length - 1];
this.url = lastImage.nativeURL;
if ( lastImage.type === 'Snapshot' ) {
this.encoding = 'JPEG';
this.format = 'IMAGE_STREAM';
} else {
this.encoding = 'H.264';
this.format = 'M3U8';
}
}
}

async function compile ( ) {
const data = await ( await fetch( 'http://a.cameraservice.goakamai.org/cameras', { headers: { 'X-Icx-Copyright': 'ICxTransportationGroup', 'X-Icx-Ts': Date.now(), 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', 'Origin': 'http://goakamai.org' } }) ).json();
const cameras = {};

for ( const cam of data ) {
if ( cameras.other === undefined ) {
cameras.other = [];
}

cameras.other.push( new Camera( cam ) );
}

return cameras;
}

export default [ 'Hawaii', compile ];
29 changes: 29 additions & 0 deletions compilation/USA/tennesseeSW.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import standardizeDirection from '../utils/standardizeDirection.cjs';

class Camera {
constructor ( cam ) {
this.description = cam.description;
this.latitude = cam.location.coordinates[0].lat;
this.longitude = cam.location.coordinates[0].lng;
this.url = cam.thumbnailUrl;
this.encoding = 'PNG';
this.format = 'IMAGE_STREAM';
}
}

async function compile ( ) {
const data = await ( await fetch( 'https://www.tdot.tn.gov/opendata/api/public/RoadwayCameras', { headers: { 'Apikey': '8d3b7a82635d476795c09b2c41facc60' } }) ).json();
const cameras = {};

for ( const cam of data ) {
if ( cameras.other === undefined ) {
cameras.other = [];
}

cameras.other.push( new Camera( cam ) );
}

return cameras;
}

export default [ 'Tennessee', compile ];
50 changes: 50 additions & 0 deletions compilation/USA/washingtonDOT.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import standardizeDirection from '../utils/standardizeDirection.cjs';

class Camera {
constructor ( cam ) {
if ( cam.attributes.CompassDirection !== null ) {
this.direction = standardizeDirection( cam.attributes.CompassDirection );
}

this.description = cam.attributes.CameraTitle;
this.latitude = convertLatitude( cam.geometry.y );
this.longitude = convertLongitude( cam.geometry.x );
this.url = cam.attributes.ImageURL;
this.encoding = 'JPG';
this.format = 'IMAGE_STREAM';
}
}

async function compile ( ) {
const data = await ( await fetch( 'https://data.wsdot.wa.gov/travelcenter/Cameras.json' ) ).json();
const cameras = {};

for ( const cam of data.features ) {
if ( cameras.other === undefined ) {
cameras.other = [];
}

cameras.other.push( new Camera( cam ) );
}

return cameras;
}

export default [ 'Washington', compile ];

function convertLongitude ( long3857 ) {
const X = 20037508.34;
const long4326 = ( long3857*180 )/X;
return long4326;
}

function convertLatitude ( lat3857 ) {
const e = 2.7182818284;
const X = 20037508.34;
let lat4326 = lat3857/( X / 180 );
const exponent = ( Math.PI / 180 ) * lat4326;
lat4326 = Math.atan( e ** exponent );
lat4326 = lat4326 / ( Math.PI / 360 );
lat4326 = lat4326 - 90;
return lat4326;
}
78 changes: 0 additions & 78 deletions compilation/WashingtonDOT.js

This file was deleted.