Skip to content

Commit

Permalink
[HG] Refactoring stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
hgarcia committed Oct 23, 2014
1 parent 2bca301 commit 84a651c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions www/js/all.js
Expand Up @@ -48,10 +48,6 @@ angular.module('dynamic-sports.controllers')
}

function calculateDistance(starting, ending) {
/*
latitude":43.64241221061246,"longitude":-79.37423813140495
latitude":43.6424056308755 ,"longitude":-79.37427474668694
*/
var KM_RATIO = 6371;
try {
var dLat = toRad(ending.latitude - starting.latitude);
Expand All @@ -72,12 +68,13 @@ angular.module('dynamic-sports.controllers')
$scope.distance = calculateDistance;

function setSpeed(coords) {
var KMS_TO_KMH = 3600;
if (!prevCoord) {
prevCoord = coords;
}
$scope.session.distance += calculateDistance(prevCoord, coords);
if (duration.asSeconds() > 0) {
$scope.session.avgSpeed = ($scope.session.distance / duration.asSeconds()) * 3600;
$scope.session.avgSpeed = ($scope.session.distance / duration.asSeconds()) * KMS_TO_KMH;
}
prevCoord = coords;
}
Expand Down Expand Up @@ -190,7 +187,7 @@ angular.module('dynamic-sports.controllers')
$scope.recording = function (on) {
if (on) {
fileName = String((new Date()).getTime());
geoLocationService.start(onChange, function (err) { alert("Error geolocation service:" + JSON.stringify(err)); });
geoLocationService.start(onChange, function (err) { });
startTimer();
} else {
geoLocationService.stop();
Expand Down Expand Up @@ -329,7 +326,9 @@ angular.module('dynamic-sports.services')
}, 1000);
},
stop: function () {
$interval.cancel(watchId);
if (watchId) {
$interval.cancel(watchId);
}
}
};
}]);
Expand Down

0 comments on commit 84a651c

Please sign in to comment.