Skip to content

Commit

Permalink
Pre-processed data
Browse files Browse the repository at this point in the history
  • Loading branch information
RushiDonga committed Apr 7, 2024
1 parent 15e2056 commit 11cb251
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.util.Log;

import androidx.annotation.NonNull;

import java.time.Duration;
import java.time.Instant;
import java.util.List;
import java.util.ArrayList;
Expand Down Expand Up @@ -42,9 +44,25 @@ public Distance getDistanceBetweenFirstAndLast() {
TrackPoint first = trackPoints.get(0);
TrackPoint last = trackPoints.get(trackPoints.size() - 1);
Distance distance = last.distanceToPrevious(first);
Log.d(TAG, "Kevin: distance between first and last in meters: " + distance.toM());

return distance;
}
}

public Long getTotalTime(){

if(trackPoints == null){
return null;
}
TrackPoint startTime = trackPoints.get(0);
TrackPoint endTime = trackPoints.get(trackPoints.size() - 1);

Duration totalTime = Duration.between(startTime.getTime(), endTime.getTime());
return totalTime.toMinutes();
}

public double getSpeed(Distance totalDistance, Long totalTime){
return totalDistance.distance_m()/totalTime;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import de.dennisguse.opentracks.data.ContentProviderUtils;
import de.dennisguse.opentracks.data.TrackDataHub;
import de.dennisguse.opentracks.data.TrackPointIterator;
<<<<<<< HEAD
=======
import de.dennisguse.opentracks.data.models.Distance;
>>>>>>> 08fc483e8 (Pre-processed data)
import de.dennisguse.opentracks.data.models.Track;
import de.dennisguse.opentracks.data.models.TrackPoint;
import de.dennisguse.opentracks.data.models.TrackSegment;
Expand Down Expand Up @@ -86,8 +90,13 @@ public void updateTrackSegments() {
Log.d(TAG, "No Action for TrackPoint IDLE/SENSORPOINT while recording segments");
}
}
trackSegments.forEach(segment -> System.out.println("KEVIN: Distance for segment: " + segment.getDistanceBetweenFirstAndLast().toM()));
System.out.println("Segments count: " + trackSegments.size());

for(int i=0; i<trackSegments.size(); i++){
Log.d("RUSHI", "TrackPoint No.: " + i);
Log.d("RUSHI", "Distance for segment " + trackSegments.get(i).getDistanceBetweenFirstAndLast().toM());
Log.d("RUSHI", "Time for segment " + trackSegments.get(i).getTotalTime() + "Minutes");
Log.d("RUSHI", "Speed for segment " + trackSegments.get(i).getSpeed(trackSegments.get(i).getDistanceBetweenFirstAndLast(), trackSegments.get(i).getTotalTime()) + "M/Sec");
}
}
}
private Date getDummyDate() {
Expand Down

0 comments on commit 11cb251

Please sign in to comment.