Skip to content

Commit 67fa79a

Browse files
committed
initial commit
0 parents  commit 67fa79a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2962
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
/node_modules/
3+
node_modules/
4+
client/bundle*.js
5+
server/data/tmp/uber_raw_data*
6+
server/solr/tmp/centroided*
7+
*npm-debug*

client/app.js

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
2+
var _ = require('lodash');
3+
var angular = require('angular');
4+
5+
var typeExtensions = require('./objects/typeExtensions');
6+
var mapService = require('./services/map.service');
7+
var markerLabelerService = require('./services/markerLabeler.service');
8+
var solrService = require('./services/solr.service');
9+
var queryTranslatorService = require('./services/queryTranslator.service');
10+
var facetTranslatorService = require('./services/facetTranslator.service');
11+
var groupingTranslatorService = require('./services/groupingTranslator.service');
12+
var toolsService = require('./services/tools.service.js');
13+
14+
var googleMapDirective = require('./directives/googleMap.directive');
15+
var dateRangePickerDirective = require('./directives/tools/dateRangePicker.directive');
16+
var groupingsDirective = require('./directives/tools/groupings.directive');
17+
var statsDirective = require('./directives/tools/stats.directive');
18+
var mapDirections = require('./directives/tools/mapDirections.directive');
19+
var toggleHeatMap = require('./directives/tools/toggleHeatMap.directive');
20+
var filterModal = require('./directives/tools/filter.directive');
21+
var mapLegend = require('./directives/tools/mapLegend.directive');
22+
23+
angular.module('foil', [require('angular-ui-bootstrap'), require('angular-ui-router')])
24+
25+
.config(function($stateProvider, $urlRouterProvider) {
26+
27+
$urlRouterProvider.otherwise("/map/view");
28+
29+
$stateProvider
30+
.state('map', {
31+
abstract:true,
32+
templateUrl: '/routes/map/layout.html'
33+
})
34+
.state('map.view', {
35+
url: '/map/view?pickups&dropoffs&mapCenter&polygon&zoom&startDate&endDate',
36+
templateUrl: '/routes/map/view/map.html',
37+
params:{ zoom: '', polygon: '', startDate:'', endDate: '', dropoffs: '', pickups: '', mapCenter:'' }
38+
})
39+
;
40+
41+
42+
43+
})
44+
.run(function($rootScope, mapSvc){
45+
$rootScope.$on('$stateChangeError',function(event, toState, toParams, fromState, fromParams, error){
46+
console.log('state change error!', error)
47+
})
48+
$rootScope.mapSvcIsLoading = function(){
49+
return mapSvc.loading
50+
}
51+
})
52+
53+
.service('mapSvc', mapService)
54+
.service('markerLabelerSvc', markerLabelerService)
55+
.service('solrSvc', solrService)
56+
.service('queryTranslatorSvc', queryTranslatorService)
57+
.service('facetTranslatorSvc', facetTranslatorService)
58+
.service('groupingTranslatorSvc', groupingTranslatorService)
59+
.service('toolsSvc', toolsService)
60+
61+
.directive('mapLegend', mapLegend)
62+
.directive('filterModal', filterModal)
63+
.directive('googleMap', googleMapDirective)
64+
.directive('dateRangePicker', dateRangePickerDirective)
65+
.directive('groupings', groupingsDirective)
66+
.directive('stats', statsDirective)
67+
.directive('mapDirections', mapDirections)
68+
.directive('toggleHeatMap', toggleHeatMap)
69+
;
70+
71+
72+
73+
74+
75+
76+
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
//initializes a google map-->
3+
4+
module.exports = function($state, mapSvc){
5+
6+
function link(scope, element, attrs) {
7+
mapSvc.bootstrap(scope, element);
8+
}
9+
10+
return {
11+
restrict: 'E',
12+
link:link
13+
};
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var util = require('util');
2+
3+
module.exports = {
4+
configurations:[
5+
{
6+
position: google.maps.ControlPosition.TOP_CENTER,
7+
directiveLink: function($state){
8+
return util.format('<date-range-picker date="\'%s\'" temporal="\'startDate\'"></date-range-picker>', $state.params.startDate)
9+
}
10+
},
11+
{
12+
position: google.maps.ControlPosition.TOP_CENTER,
13+
directiveLink: function($state){
14+
return util.format('<date-range-picker date="\'%s\'" temporal="\'endDate\'"></date-range-picker>', $state.params.endDate)
15+
}
16+
}
17+
]
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<div ng-init="shortName = temporal.replace('Date','')" class="custom-drawing-control" title="{{shortName}} date"
2+
style="{{temporal === 'startDate' ? 'margin-left:-5px;' : ''}}"
3+
ng-click="isOpen = !isOpen">
4+
5+
<span>
6+
<div class="control-container">
7+
{{shortName}}:
8+
<span uib-datepicker-popup class="date-picker"
9+
is-open="isOpen"
10+
ng-model="date"
11+
datepicker-append-to-body="true"
12+
show-button-bar="false"
13+
show-weeks="false"
14+
ng-bind="getDisplayDate()"
15+
ng-change="handleDateChange()"
16+
>
17+
</span>
18+
<span class="glyphicon glyphicon-calendar"></span>
19+
</div>
20+
</span>
21+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
var moment = require('moment'),
2+
_ = require('lodash');
3+
4+
5+
module.exports = function($state){
6+
return {
7+
restrict: 'E',
8+
templateUrl:'/directives/tools/dateRangePicker.directive.html',
9+
scope:{
10+
date:'=',
11+
temporal:'='
12+
},
13+
controller: function($scope, $element, $attrs, $state, solrSvc) {
14+
$scope.startOrEnd = $scope.temporal === 'startDate' ? 'start' : 'end';
15+
16+
$scope.getDisplayDate = function(){ return moment($scope.date).format('MM/DD/YYYY').toString(); }
17+
18+
$scope.handleDateChange = function handleDateChange(){
19+
var date = {};
20+
date[$scope.temporal] = $scope.date;
21+
22+
$state.go($state.current, _.assign($state.params, moment(date).toISOString())).then(function(){
23+
return solrSvc.getSolrPoints($state.params);
24+
})
25+
};
26+
}
27+
};
28+
}
29+
30+
31+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<div class="custom-drawing-control" title="View top stats" ng-click="showStats()">
2+
3+
<span>
4+
<div class="control-container">
5+
<span class="glyphicon glyphicon-flash"></span>
6+
</div>
7+
</span>
8+
</div>
9+
10+
<script type="text/ng-template" id="statsModal.html">
11+
<div class="modal-header">
12+
<h3 class="modal-title">MAP STATS</h3>
13+
</div>
14+
<div class="modal-body">
15+
<h4>Top 5 Points:</h4>
16+
<p ng-repeat="marker in mapSvc.markers | limitTo: 5 track by $index" ng-bind="formatMarker(marker)"></p>
17+
</div>
18+
<div class="modal-footer">
19+
<button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
20+
</div>
21+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
var moment = require('moment');
2+
3+
module.exports = function($state){
4+
return {
5+
restrict: 'E',
6+
templateUrl:'/directives/tools/filter.directive.html',
7+
scope:{ },
8+
controller: function($scope, $element, $attrs, $uibModal) {
9+
var self = this;
10+
11+
//shows stats modal-->
12+
$scope.showStats = function(){
13+
14+
self.modalInstance = $uibModal.open({
15+
animation: true,
16+
templateUrl:'statsModal.html',
17+
controller: function($scope, mapSvc){
18+
$scope.mapSvc = mapSvc;
19+
20+
//closes stats modal -->
21+
$scope.ok = function(){
22+
self.modalInstance.dismiss('cancel');
23+
}
24+
25+
//formats the marker string-->
26+
$scope.formatMarker = function(marker){
27+
return (!marker.label) ?
28+
'1 point :: ' + marker.title :
29+
marker.label + ' points :: ' + marker.title;
30+
}
31+
}
32+
});
33+
34+
}
35+
36+
37+
}
38+
};
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var util = require('util');
2+
3+
module.exports = {
4+
configurations:[
5+
{
6+
position: google.maps.ControlPosition.TOP_CENTER,
7+
directiveLink: function($state) {
8+
return util.format('<groupings></groupings>', $state.params.startDate)
9+
}
10+
}
11+
]
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div class="custom-drawing-control" title="show/hide pickups & dropoffs">
2+
<span>
3+
<div class="control-container">
4+
<span>
5+
<input type="checkbox" ng-model="pickups" ng-change="change('pickups')" /> pickups
6+
</span>
7+
<span>
8+
<input type="checkbox" ng-model="dropoffs" ng-change="change('dropoffs')" /> dropoffs
9+
</span>
10+
</div>
11+
</span>
12+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var moment = require('moment');
2+
3+
module.exports = function($state){
4+
return {
5+
restrict: 'E',
6+
templateUrl:'/directives/tools/groupings.directive.html',
7+
scope:{ },
8+
controller: function($scope, $state, mapSvc) {
9+
$scope.pickups = $state.params.pickups === 'true';
10+
$scope.dropoffs = $state.params.dropoffs === 'true';
11+
$scope.change = function(pickupsOrDropoffs){
12+
$state.params[pickupsOrDropoffs] = $scope[pickupsOrDropoffs];
13+
$state.go($state.current, $state.params, {notify:false}).then(function(state){
14+
mapSvc.updateMap();
15+
})
16+
}
17+
}
18+
19+
};
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<div class="custom-drawing-control" title="How to use this map..." ng-click="info()">
2+
3+
<span>
4+
<div class="control-container">
5+
<span class="glyphicon glyphicon-question-sign"></span>
6+
</div>
7+
</span>
8+
</div>
9+
10+
<script type="text/ng-template" id="infoModal.html">
11+
<div class="modal-header">
12+
<h3 class="modal-title">MAP TOOLS</h3>
13+
</div>
14+
<div class="modal-body">
15+
<p>
16+
<div style="width: 16px; height: 16px; overflow: hidden; position: relative;"><img src="https://maps.gstatic.com/mapfiles/drawing.png" draggable="false" style="position: absolute; left: 0px; top: -144px; -webkit-user-select: none; border: 0px; padding: 0px; margin: 0px; width: 16px; height: 192px;"></div>
17+
- moves the map
18+
s</p>
19+
<p><div style="width: 16px; height: 16px; overflow: hidden; position: relative;"><img src="https://maps.gstatic.com/mapfiles/drawing.png" draggable="false" style="position: absolute; left: 0px; top: -64px; -webkit-user-select: none; border: 0px; padding: 0px; margin: 0px; width: 16px; height: 192px;"></div>
20+
- draws a shape on the map, narrowing markers to that region<br />
21+
- ESC key removes the polygon
22+
</p>
23+
<p>start: 01/31/2012 <span class="glyphicon glyphicon-calendar"></span><br />
24+
- sets the start date for the markers on the map<br />
25+
- defaults to present day - 4 years
26+
</p>
27+
<p>end: 02/01/2016 <span class="glyphicon glyphicon-calendar"></span><br />
28+
- sets the end date for the markers on the map<br />
29+
- defaults to present day + 1
30+
</p>
31+
<p>
32+
<span class="glyphicon glyphicon-flash"></span><br />
33+
- opens modal dialog and displays the top 5 marker statistics
34+
</p>
35+
<p>
36+
<span class="glyphicon glyphicon-fire"></span><br />
37+
- toggles heat map on/off
38+
</p>
39+
</div>
40+
<div class="modal-footer">
41+
<button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
42+
</div>
43+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
3+
module.exports = function($state){
4+
return {
5+
restrict: 'E',
6+
templateUrl:'/directives/tools/mapDirections.directive.html',
7+
scope:{ },
8+
controller: function($scope, $element, $attrs, $uibModal) {
9+
var self = this;
10+
11+
//displays the directions modal dialog-->
12+
$scope.info = function(){
13+
14+
self.modalInstance = $uibModal.open({
15+
animation: true,
16+
templateUrl:'infoModal.html',
17+
controller: function($scope){
18+
19+
//closes the directions modal dialog
20+
$scope.ok = function(){
21+
self.modalInstance.dismiss('cancel');
22+
}
23+
}
24+
});
25+
26+
}
27+
28+
29+
}
30+
};
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var util = require('util');
2+
3+
module.exports = {
4+
configurations:[
5+
{
6+
position: google.maps.ControlPosition.TOP_RIGHT,
7+
directiveLink: function($state){
8+
return util.format('<map-legend class="top-right"></map-legend>', $state.params.startDate)
9+
}
10+
}
11+
]
12+
}

0 commit comments

Comments
 (0)