Permalink
Browse files

Adds workzone, road & light conditions.

  • Loading branch information...
dsummersl committed Nov 18, 2015
1 parent 0fa5a6f commit 9dd8f0750d35c00d2a7186452b7ed235d4f3b679
Showing with 41 additions and 15 deletions.
  1. +6 −1 html/includes/angular/MainMap.js
  2. +35 −14 html/includes/angular/app.js
@@ -6,9 +6,15 @@ function ($scope, $location, leafletData, getCrashes, getCrashesUserSubmitted, d
// draw on (data is loaded and leaflet is setup):
$scope.leafletLoaded = false;
// keyToHumanReadables defines the kinds of data that will show up on the
// map legend (things you can color the accidents by). If its not defined
// here its NOT on the map!
$scope.keyToHumanReadables = {};
$scope.keyToHumanReadables['crash.ambulance'] = dataSettings.description('crash','ambulance');
$scope.keyToHumanReadables['crash.weather'] = dataSettings.description('crash','weather');
$scope.keyToHumanReadables['crash.light_conditions'] = dataSettings.description('crash','light_conditions');
$scope.keyToHumanReadables['crash.road_conditions'] = dataSettings.description('crash','road_conditions');
$scope.keyToHumanReadables['crash.workzone'] = dataSettings.description('crash','workzone');
$scope.keyToHumanReadables['biker.alcohol'] = dataSettings.description('biker','alcohol');
$scope.keyToHumanReadables['biker.injury'] = dataSettings.description('biker','injury');
$scope.keyToHumanReadables['biker.race'] = dataSettings.description('biker','race');
@@ -21,7 +27,6 @@ function ($scope, $location, leafletData, getCrashes, getCrashesUserSubmitted, d
$scope.keyToHumanReadables['driver.sex'] = dataSettings.description('driver','sex');
$scope.keyToHumanReadables['driver.estimated_speed'] = dataSettings.description('driver','estimated_speed');
$scope.keyToHumanReadables['driver.vehicle_type'] = dataSettings.description('driver','vehicle_type');
// TODO biker.age - increments of 5 years?
// Get the schema metadata for an option, or the data for an option.
//
@@ -52,15 +52,22 @@ var races = [
];
var UNKNOWN_COLOR = '#aaaaaa';
var genders = [ 'Unknown', 'Female', 'Male' ];
var booleanColorsFunction = function(d) {
var booleanColors = {
Male: '#FA6019',
Female: '#4E98C6',
No: '#FA6019',
Yes: '#4E98C6',
Unknown: UNKNOWN_COLOR
// Given a dictionary of legend descriptions, return the color points to, and
// also take care of the 'Unknown' coloring
var mapColorToDictionaryFunction = function(map) {
return function(d) {
if (d in map) {
return map[d];
}
if (d === 'Unknown') {
return UNKNOWN_COLOR;
}
return 'hotpink';
};
return booleanColors[d];
};
var yesNoMap = {
No: '#FA6019',
Yes: '#4E98C6'
};
var speeds = [
'Unknown',
@@ -100,7 +107,7 @@ var bikerAndDriver = {
description: 'Intoxicated',
type: 'list',
options: booleans,
colors: booleanColorsFunction,
colors: mapColorToDictionaryFunction(yesNoMap)
},
injury: {
description: 'Injury',
@@ -118,7 +125,10 @@ var bikerAndDriver = {
description: 'Gender',
type: 'list',
options: genders,
colors: booleanColorsFunction
colors: mapColorToDictionaryFunction({
Male: '#FA6019',
Female: '#4E98C6'
})
}
};
@@ -190,13 +200,21 @@ var dataSetMapping = {
description: 'Ambulance Called',
type: 'list',
options: booleans,
colors: booleanColorsFunction
colors: mapColorToDictionaryFunction(yesNoMap)
},
group: {},
hit_and_run: {},
light_conditions: {},
light_conditions: {
description: 'Light Conditions'
},
location: {},
road_conditions: {},
road_conditions: {
description: 'Road Conditions',
colors: mapColorToDictionaryFunction({
Dry: '#FFA500',
Wet: '#4E98C6'
})
},
road_defects: {},
timestamp: {},
type: {},
@@ -226,7 +244,10 @@ var dataSetMapping = {
}
}
},
workzone: {}
workzone: {
description: 'Workzone',
colors: mapColorToDictionaryFunction(yesNoMap)
}
},
driver: driver,
location: {

0 comments on commit 9dd8f07

Please sign in to comment.