Skip to content

Commit

Permalink
Merge pull request #29 from krisma/mapBranch
Browse files Browse the repository at this point in the history
map fixed, bug fixed
  • Loading branch information
shankari committed Apr 11, 2016
2 parents 94fcb64 + 1bc348a commit 57c468e
Show file tree
Hide file tree
Showing 11 changed files with 588 additions and 545 deletions.
Binary file added resources/minus.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/plus.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions www/css/main.diary.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,28 @@
a.item-content {
padding: 0 !important;
}
.leaflet-div-icon {
background-color: white;
width: 6px;
height: 6px;
border-radius: 3px;
margin-left: 3px;
margin-top: 3px;
border-color: white;
}
.leaflet-div-icon-start {
background-color: #72b026;
border-radius: 6px;
}
.leaflet-div-icon-stop {
background-color: #d63e2a;
border-radius: 6px;
}
.inner-icon {
background-color: white;
width: 6px;
height: 6px;
border-radius: 3px;
margin-left: 3px;
margin-top: 3px;
}
Binary file added www/img/minus.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/img/plus.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions www/js/common/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,28 @@ angular.module('emission.main.common.services', [])
return commonGraph.data.cTripCountMap[cTripId];
};

var findLargestIndex = function(array) {
// assume array.length > 0
// assume all non-negative elements
var maxIndex = 0;
var maxElement = 0;
for (var i=0; i<array.length; i++) {
if (array[i] > maxElement) {
maxElement = array[i];
maxIndex = i;
}
}
return maxIndex;
}
commonGraph.probabilitiesToMostFrequentHours = function(twodarray) {
var rtn = [];
for (var i=0; i<twodarray.length; i++) {
var onedarray = twodarray[i];
rtn.push(findLargestIndex(onedarray));
}
return rtn;
}

var postProcessData = function() {
// Count the number of trips in each common trip. Also, create a map
// from the trip list to the trip for efficient lookup
Expand Down
130 changes: 16 additions & 114 deletions www/js/diary/detail.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use strict';

angular.module('emission.main.diary.detail',['ui-leaflet', 'nvd3ChartDirectives',
'ionic-datepicker'])

.controller("DiaryDetailCtrl", function($scope, $stateParams, Timeline) {
.controller("DiaryDetailCtrl", function($scope, $stateParams, Timeline, DiaryHelper) {
console.log("controller DiaryDetailCtrl called with params = "+
JSON.stringify($stateParams));

Expand All @@ -19,118 +18,21 @@ angular.module('emission.main.diary.detail',['ui-leaflet', 'nvd3ChartDirectives'
}
}
});
$scope.getIcon = function(section) {
var icons = {"BICYCLING":"ion-android-bicycle",
"WALKING":" ion-android-walk",
"RUNNING":" ion-android-walk",
"IN_VEHICLE":"ion-disc",}
return icons[$scope.getHumanReadable(section.properties.sensed_mode)];
}
$scope.getHumanReadable = function(sensed_mode) {
ret_string = sensed_mode.split('.')[1];
if(ret_string == 'ON_FOOT') {
return 'WALKING';
} else {
return ret_string;
}
};
$scope.getPercentages = function(trip) {
var rtn0 = []; // icons
var rtn1 = []; //percentages
var icons = {"BICYCLING":"ion-android-bicycle",
"WALKING":" ion-android-walk",
"RUNNING":" ion-android-walk",
"IN_VEHICLE":"ion-disc",}
var total = 0;
for (var i=0; i<trip.sections.length; i++) {
if (rtn0.indexOf($scope.getHumanReadable(trip.sections[i].properties.sensed_mode)) == -1) {
rtn0.push($scope.getHumanReadable(trip.sections[i].properties.sensed_mode));
rtn1.push(trip.sections[i].properties.distance);
total += trip.sections[i].properties.distance;
} else {
rtn1[rtn0.indexOf($scope.getHumanReadable(trip.sections[i].properties.sensed_mode))] += trip.sections[i].properties.distance;
total += trip.sections[i].properties.distance;
}
}
for (var i=0; i<rtn0.length; i++) {
rtn0[i] = "icon " + icons[rtn0[i]];
rtn1[i] = Math.floor((rtn1[i] / total) * 100);
}
return [rtn0, rtn1];
}

$scope.starColor = function(trip) {
if (trip.common_count >= 3) {
return 'yellow';
} else {
return 'transparent';
}
}
$scope.allModes = function(trip) {
var rtn = [];
var icons = {"BICYCLING":"ion-android-bicycle",
"WALKING":" ion-android-walk",
"RUNNING":" ion-android-walk",
"IN_VEHICLE":"ion-disc",}
for (var i=0; i<trip.sections.length; i++) {
if (rtn.indexOf($scope.getHumanReadable(trip.sections[i].properties.sensed_mode)) == -1) {
rtn.push($scope.getHumanReadable(trip.sections[i].properties.sensed_mode));
}
}
for (var i=0; i<rtn.length; i++) {
rtn[i] = "icon " + icons[rtn[i]];
}

return rtn;
}

$scope.parseEarlierOrLater = DiaryHelper.parseEarlierOrLater;
$scope.getEarlierOrLater = DiaryHelper.getEarlierOrLater;
$scope.getIcon = DiaryHelper.getIcon;
$scope.getHumanReadable = DiaryHelper.getHumanReadable;
$scope.getPercentages = DiaryHelper.getPercentages;
$scope.allModes = DiaryHelper.allModes;
$scope.trip = Timeline.getTrip($stateParams.tripId);
$scope.getKmph = function(section) {
metersPerSec = section.properties.distance / section.properties.duration;
return (metersPerSec * 3.6).toFixed(2);
};

$scope.getFormattedDistance = function(dist_in_meters) {
if (dist_in_meters > 1000) {
return (dist_in_meters/1000).toFixed(0);
} else {
return (dist_in_meters/1000).toFixed(3);
}
}

$scope.getSectionDetails = function(section) {
startMoment = moment(section.properties.start_ts * 1000);
endMoment = moment(section.properties.end_ts * 1000);
retVal = [startMoment.format('LT'),
endMoment.format('LT'),
endMoment.to(startMoment, true),
formatDistance(section.properties.distance),
tokmph(section.properties.distance, section.properties.duration).toFixed(2),
$scope.getHumanReadable(section.properties.sensed_mode)];
return retVal;
};

$scope.getFormattedTime = function(ts_in_secs) {
if (angular.isDefined(ts_in_secs)) {
return moment(ts_in_secs * 1000).format('LT');
} else {
return "---";
}
};

$scope.getFormattedTimeRange = function(end_ts_in_secs, start_ts_in_secs) {
startMoment = moment(start_ts_in_secs * 1000);
endMoment = moment(end_ts_in_secs * 1000);
return endMoment.to(startMoment, true);
};

$scope.getFormattedDuration = function(duration_in_secs) {
return moment.duration(duration_in_secs * 1000).humanize()
};

$scope.getTripDetails = function(trip) {
return (trip.sections.length) + " sections";
}; $scope.tripgj = {}
$scope.tripgj.data = $scope.trip;
$scope.getKmph = DiaryHelper.getKmph;
$scope.getFormattedDistance = DiaryHelper.getFormattedDistance;
$scope.getSectionDetails = DiaryHelper.getSectionDetails;
$scope.getFormattedTime = DiaryHelper.getFormattedTime;
$scope.getFormattedTimeRange = DiaryHelper.getFormattedTimeRange;
$scope.getFormattedDuration = DiaryHelper.getFormattedDuration;
$scope.getTripDetails = DiaryHelper.getTripDetails
$scope.tripgj = DiaryHelper.directiveForTrip($scope.trip);

console.log("trip.start_place = " + JSON.stringify($scope.trip.start_place));
})
Loading

0 comments on commit 57c468e

Please sign in to comment.