View Code? Open in Web Editor
NEW
View current project at https://code-for-chapel-hill.github.io/CrashModel/
License: MIT License
CSS 6.89%
JavaScript 54.02%
HTML 39.08%
crashmodel's Introduction
Chapel Hill Crash Model Project
Create github account
fork this repo
clone/download forked repo
make code change (see issues tab for pending tasks)
push changes to forked repo
create a new pull request
crashmodel's People
crashmodel's Issues
Make it so that you can hide and display the left sidebar. might have to use some jquery for this.
Look at commit here to see how it's done for traffic signals:
1eefed9
System must visualize map of chapel hill with the top 10 highest risk locations highlighted.
Once the sidebar is up, get the sorted list of traffic signals by calling
function getSortedTrafficSignalScores (
urlTrafficSignals ,
urlPedCrashes ,
urlBikeCrashes
) {
trafficSignalPoints = getPointsNonAsync ( urlTrafficSignals , "geo_point" ) ;
pedCrashPoints = getPointsNonAsync ( urlPedCrashes , "geo_point_2d" ) ;
bikeCrashPoints = getPointsNonAsync ( urlBikeCrashes , "geo_point_2d" ) ;
trafficSignalScores = getTrafficSignalScores (
trafficSignalPoints ,
pedCrashPoints ,
bikeCrashPoints
) ;
trafficSignalPointsAndScores = zip ( trafficSignalPoints , trafficSignalScores ) ;
trafficSignalPointsAndScores = trafficSignalPointsAndScores . sort (
trafficSignalComparisionFunction
) ;
return trafficSignalPointsAndScores ;
}
like this:
trafficSignalScores = getSortedTrafficSignalScores (
"https://www.chapelhillopendata.org/api/records/1.0/search/?dataset=traffic-signals-in-chapel-hill&rows=1000" ,
"https://www.chapelhillopendata.org/api/records/1.0/search/?dataset=bicycle-crash-data-chapel-hill-region&rows=1000&facet=ambulancer&facet=bikeage_gr&facet=bike_age&facet=bike_alc_d&facet=bike_dir&facet=bike_injur&facet=bike_pos&facet=bike_race&facet=bike_sex&facet=city&facet=county&facet=crashalcoh&facet=crashday&facet=crash_grp&facet=crash_hour&facet=crash_loc&facet=crash_mont&facet=crash_time&facet=crash_type&facet=crash_year&facet=crsh_sevri&facet=developmen&facet=drvrage_gr&facet=drvr_age&facet=drvr_alc_d&facet=drvr_estsp&facet=drvr_injur&facet=drvr_race&facet=drvr_sex&facet=drvr_vehty&facet=excsspdind&facet=hit_run&facet=light_cond&facet=locality&facet=num_lanes&facet=num_units&facet=rd_charact&facet=rd_class&facet=rd_conditi&facet=rd_config&facet=rd_defects&facet=rd_feature&facet=rd_surface&facet=rural_urba&facet=speed_limi&facet=traff_cntr&facet=weather&facet=workzone_i&facet=bike_unitn&facet=drvr_unitn&facet=on_rd" ,
"https://www.chapelhillopendata.org/api/records/1.0/search/?dataset=pedestrian-crashes-chapel-hill-region&rows=1000&facet=ambulancer&facet=city&facet=county&facet=crashalcoh&facet=crashday&facet=crash_grp&facet=crash_loc&facet=crash_type&facet=crsh_sevri&facet=developmen&facet=drvrage_gr"
) ;
and then just display the coordinates on the sidebar (next step will be getting the street intersections)
Look at commit to see how its done for bike crashes
986b7e2
Just using euclidian estimate right now
function getEuclidianDistance ( x1 , y1 , x2 , y2 ) {
var x = ( x1 - x2 ) * ( x1 - x2 ) ;
var y = ( y1 - y2 ) * ( y1 - y2 ) ;
return Math . sqrt ( x + y ) ;
}
function getEuclidianDistanceInMiles ( lat1 , long1 , lat2 , long2 ) {
var dist = getEuclidianDistance ( lat1 , long1 , lat2 , long2 ) ;
var conversionConstant = 58.8968245849 ;
return conversionConstant * dist ;
}
We should use havesine formula
https://www.movable-type.co.uk/scripts/latlong.html
Write JavaScript script to generate a list of traffic signals ranked by most associated crashes.
Create a new html page called contact.html and link it here:
< li class ="nav-item "> < a class ="nav-link " href ="# "> Contact</ a > </ li >
The toggling no longer works. The behavior seems random.
Create a JavaScript script for determining crashes in proximity of intersections.
Replace the list of lat and longs on the sidebar with road names.
once, we have this, we'll have a useful tool for the town:)