From e8b1b78618404081699421a569ef424f035f89cd Mon Sep 17 00:00:00 2001 From: Sraddha Bhattacharjee Date: Sun, 7 Apr 2024 20:44:39 -0400 Subject: [PATCH] Revert "Added speed of chairlift functionality for Chairlift Statistics" This reverts commit 243e7951021d9732b85cb36109bfe3bb7548688c. --- .../opentracks/data/models/Chairlift.java | 34 +++++++------------ .../opentracks/stats/ChairliftStatistics.java | 14 -------- 2 files changed, 12 insertions(+), 36 deletions(-) delete mode 100644 src/main/java/de/dennisguse/opentracks/stats/ChairliftStatistics.java diff --git a/src/main/java/de/dennisguse/opentracks/data/models/Chairlift.java b/src/main/java/de/dennisguse/opentracks/data/models/Chairlift.java index 062487809..09c08acdf 100644 --- a/src/main/java/de/dennisguse/opentracks/data/models/Chairlift.java +++ b/src/main/java/de/dennisguse/opentracks/data/models/Chairlift.java @@ -10,7 +10,7 @@ public class Chairlift { // Fields private String name; private int number; - private double chairliftSpeed; + private double averageSpeed; private String liftType; private int id; @@ -19,10 +19,10 @@ public class Chairlift { private static final Map validChairlifts = new HashMap<>(); // Constructors - public Chairlift(String name, int number, double chairliftSpeed, String liftType) { + public Chairlift(String name, int number, double averageSpeed, String liftType) { this.name = name; this.number = number; - this.chairliftSpeed = chairliftSpeed; + this.averageSpeed = averageSpeed; this.liftType = liftType; this.id = nextId++; } @@ -44,12 +44,12 @@ public void setNumber(int number) { this.number = number; } - public double getchairliftSpeed() { - return chairliftSpeed; + public double getAverageSpeed() { + return averageSpeed; } - public void setchairliftSpeed(double chairliftSpeed) { - this.chairliftSpeed = chairliftSpeed; + public void setAverageSpeed(double averageSpeed) { + this.averageSpeed = averageSpeed; } public String getLiftType() { @@ -86,20 +86,21 @@ public boolean isUserRidingChairlift(List trackPoints) { return false; // Likely not on chairlift } - // Calculate total time + // Calculate total distance and time + double totalDistance = calculateTotalDistance(trackPoints); double totalTime = calculateTotalTime(trackPoints); // Calculate average speed - double chairliftSpeed = calculateChairliftSpeed(trackPoints); + double averageSpeed = totalDistance / totalTime; // Check average speed and total time - if ((chairliftSpeed < speedThreshold || chairliftSpeed > 6) || + if ((averageSpeed < speedThreshold || averageSpeed > 6) || (totalTime > timeThreshold && totalTime < 7.7)) { return false; } // Add chairlift to valid chairlifts and mark track points as chairlift segment - Chairlift validChairlift = new Chairlift(name, number, chairliftSpeed, liftType); + Chairlift validChairlift = new Chairlift(name, number, averageSpeed, liftType); validChairlifts.put(validChairlift.getId(), validChairlift); trackPoints.forEach(trackPoint -> trackPoint.setChairliftSegment(true)); @@ -128,17 +129,6 @@ private double calculateTotalTime(List trackPoints) { return totalTime.toMinutes(); } - private double calculateChairliftSpeed(List trackPoints){ - // Calculate total distance and time - double totalDistance = calculateTotalDistance(trackPoints); - double totalTime = calculateTotalTime(trackPoints); - - // Calculate average speed - return totalDistance / totalTime; - } - - - public static List getValidChairlifts() { return new ArrayList<>(validChairlifts.values()); } diff --git a/src/main/java/de/dennisguse/opentracks/stats/ChairliftStatistics.java b/src/main/java/de/dennisguse/opentracks/stats/ChairliftStatistics.java deleted file mode 100644 index cb9d87756..000000000 --- a/src/main/java/de/dennisguse/opentracks/stats/ChairliftStatistics.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.dennisguse.opentracks.stats; - -import de.dennisguse.opentracks.data.models.Chairlift; - -public class ChairliftStatistics extends Chairlift{ - - public ChairliftStatistics(String name, int number, double averageSpeed, String liftType) { - super(name, number, averageSpeed, liftType); - } - - public double getChairliftSpeed(){ - return super.getchairliftSpeed(); - } -}