Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dk1702 committed Feb 11, 2024
1 parent a54e444 commit 2f0f31e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions views/DashboardContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class DashboardContainer extends React.PureComponent<DashboardContainerProps> {

const gpsDistanceData = [
gps.data.map((data) => data.latitude),
gps.data.map((data) => data.longitude),
gps.data.map((data) => data.heading)
gps.data.map((data) => data.longitude)
];

const batteriesVoltageData = [
Expand All @@ -47,7 +46,7 @@ class DashboardContainer extends React.PureComponent<DashboardContainerProps> {
windSensors.data.map((data) => data.windSensors[1].speed),
];

const totalTripDistance = this.computeTotalTripDistance(gpsDistanceData[0], gpsDistanceData[1])
const totalTripDistance = this._computeTotalTripDistance(gpsDistanceData[0], gpsDistanceData[1])

return (
<div>
Expand Down Expand Up @@ -101,7 +100,7 @@ class DashboardContainer extends React.PureComponent<DashboardContainerProps> {
return Math.floor(Date.parse(s) / 1000); // Converts to seconds
}

haversineDistance(lat1: number, long1: number, lat2: number, long2: number) {
_haversineDistance(lat1: number, long1: number, lat2: number, long2: number) {

function toRadians(angle: number): number{
return angle * Math.PI / 180
Expand All @@ -125,15 +124,15 @@ class DashboardContainer extends React.PureComponent<DashboardContainerProps> {
return distance
}

computeTotalTripDistance(latitude: number[], longitude: number[]) {
_computeTotalTripDistance(latitude: number[], longitude: number[]) {
if(latitude.length != longitude.length){
return -1;
}

var totalDistance = 0;

for(let i = 1; i < latitude.length; i++){
totalDistance += this.haversineDistance(latitude[i-1], longitude[i-1], latitude[i], longitude[i]);
totalDistance += this._haversineDistance(latitude[i-1], longitude[i-1], latitude[i], longitude[i]);
}

return Number(totalDistance.toFixed(2));
Expand Down

0 comments on commit 2f0f31e

Please sign in to comment.