mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 03:13:49 +00:00
added SOG column for race
This commit is contained in:
1 parent
46e6f5f6b2
commit
3cfc7fa02c
15 files changed
+93
-12
No files matched your search
+1
-1
@@ -25,7 +25,7 @@ public enum DetailType implements Serializable {
|
||||
DISPLAY_LEGS(0, NONE), TIME_TRAVELED(0, ASCENDING),
|
||||
TOTAL_TIME_SAILED_DOWNWIND_IN_SECONDS(1, ASCENDING),
|
||||
MAXIMUM_SPEED_OVER_GROUND_IN_KNOTS(1, DESCENDING),
|
||||
TOTAL_TIME_SAILED_IN_SECONDS(1, ASCENDING);
|
||||
TOTAL_TIME_SAILED_IN_SECONDS(1, ASCENDING), RACE_CURRENT_SPEED_OVER_GROUND_IN_KNOTS(2, DESCENDING);
|
||||
|
||||
private int precision;
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ public interface Leaderboard extends Named {
|
||||
Pair<GPSFixMoving, Speed> getMaximumSpeedOverGround(Competitor competitor, TimePoint timePoint);
|
||||
|
||||
/**
|
||||
* @param legType TODO
|
||||
* @param legType the leg type for which to add up the times sailed
|
||||
* @return <code>null</code> if no tracked race is available for <code>competitor</code> in this leaderboard
|
||||
* or the competitor hasn't started sailing a single downwind leg at <code>timePoint</code> for any of the tracked
|
||||
* races attached to this leaderboard
|
||||
|
||||
+6
-1
@@ -498,7 +498,6 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
|
||||
} else {
|
||||
to = timePoint;
|
||||
}
|
||||
// TODO find out in which leg the maximum speed was achieved
|
||||
Pair<GPSFixMoving, Speed> maxSpeed = trackedRace.getTrack(competitor).getMaximumSpeedOverGround(from, to);
|
||||
if (result == null || result.getB() == null || (maxSpeed.getB() != null && maxSpeed.getB().compareTo(result.getB()) > 0)) {
|
||||
result = maxSpeed;
|
||||
@@ -530,6 +529,12 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
|
||||
} else {
|
||||
result += millisecondsSpendOnDownwind;
|
||||
}
|
||||
} else {
|
||||
// Although the competitor has started the leg, no value was produced. This means that
|
||||
// the competitor didn't finish the leg before tracking ended. No useful value can
|
||||
// be obtained for this competitor anymore.
|
||||
result = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -23,7 +23,8 @@ public interface TrackedLegOfCompetitor extends Serializable {
|
||||
* How much time did the {@link #getCompetitor competitor} spend in this {@link #getLeg() leg} at
|
||||
* <code>timePoint</code>? If the competitor hasn't started the leg yet at <code>timePoint</code>, <code>null</code>
|
||||
* is returned. If the competitor has finished the leg already at <code>timePoint</code>, the time it took the
|
||||
* competitor to complete the leg is returned.
|
||||
* competitor to complete the leg is returned. If the competitor didn't finish the leg before the end of tracking,
|
||||
* <code>null</code> is returned because this indicates that the tracker stopped sending valid data.
|
||||
*/
|
||||
Long getTimeInMilliSeconds(TimePoint timePoint);
|
||||
|
||||
|
||||
+8
-2
@@ -61,7 +61,7 @@ public class TrackedLegOfCompetitorImpl implements TrackedLegOfCompetitor {
|
||||
|
||||
@Override
|
||||
public Long getTimeInMilliSeconds(TimePoint timePoint) {
|
||||
long result = 0;
|
||||
Long result;
|
||||
MarkPassing passedStartWaypoint = getTrackedRace().getMarkPassing(getCompetitor(),
|
||||
getTrackedLeg().getLeg().getFrom());
|
||||
if (passedStartWaypoint != null) {
|
||||
@@ -70,8 +70,14 @@ public class TrackedLegOfCompetitorImpl implements TrackedLegOfCompetitor {
|
||||
if (passedEndWaypoint != null) {
|
||||
result = passedEndWaypoint.getTimePoint().asMillis() - passedStartWaypoint.getTimePoint().asMillis();
|
||||
} else {
|
||||
result = timePoint.asMillis() - passedStartWaypoint.getTimePoint().asMillis();
|
||||
if (timePoint.after(getTrackedRace().getEndOfTracking())) {
|
||||
result = null;
|
||||
} else {
|
||||
result = timePoint.asMillis() - passedStartWaypoint.getTimePoint().asMillis();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+1
@@ -16,6 +16,7 @@ public class DetailTypeFormatter {
|
||||
case NUMBER_OF_MANEUVERS:
|
||||
return stringMessages.numberOfManeuvers();
|
||||
case CURRENT_SPEED_OVER_GROUND_IN_KNOTS:
|
||||
case RACE_CURRENT_SPEED_OVER_GROUND_IN_KNOTS:
|
||||
return stringMessages.currentSpeedOverGroundInKnots();
|
||||
case ESTIMATED_TIME_TO_NEXT_WAYPOINT_IN_SECONDS:
|
||||
return stringMessages.estimatedTimeToNextWaypointInSeconds();
|
||||
|
||||
+13
@@ -14,4 +14,17 @@ public class NumberFormatterFactory {
|
||||
return NumberFormat.getFormat(patternBuilder.toString());
|
||||
}
|
||||
|
||||
public static NumberFormat getDecimalFormat(int integerDigits, int decimals) {
|
||||
StringBuilder patternBuilder = new StringBuilder();
|
||||
for (int i=0; i<integerDigits; i++) {
|
||||
patternBuilder.append('0');
|
||||
}
|
||||
if (decimals > 0) {
|
||||
patternBuilder.append('.');
|
||||
}
|
||||
for (int i = 0; i < decimals; i++) {
|
||||
patternBuilder.append('0');
|
||||
}
|
||||
return NumberFormat.getFormat(patternBuilder.toString());
|
||||
}
|
||||
}
|
||||
+1
@@ -387,4 +387,5 @@ public interface StringMessages extends Messages {
|
||||
String totalTimeSailedDownwindInSeconds();
|
||||
String totalTimeSailedInSeconds();
|
||||
String overallDetailsToShow();
|
||||
String hhmmssUnit();
|
||||
}
|
||||
+1
@@ -387,3 +387,4 @@ overallStandings=Overall Standings
|
||||
maximumSpeedOverGroundInKnots=Max SOG
|
||||
totalTimeSailedDownwindInSeconds=Total time downwind
|
||||
totalTimeSailedInSeconds=Total time
|
||||
hhmmssUnit=hh:mm:ss
|
||||
+1
@@ -388,3 +388,4 @@ overallStandings=Gesamtstand
|
||||
maximumSpeedOverGroundInKnots=Max FüG
|
||||
totalTimeSailedDownwindInSeconds=Gesamtzeit Vorwind
|
||||
totalTimeSailedInSeconds=Gesamtzeit
|
||||
hhmmssUnit=hh:mm:ss
|
||||
+1
-1
@@ -72,7 +72,7 @@ public class FormattedDoubleLegDetailColumn extends LegDetailColumn<Double, Stri
|
||||
@Override
|
||||
public String getStringValueToRender(LeaderboardRowDTO object) {
|
||||
String value = getValue(object);
|
||||
if (!value.isEmpty() & value != null) {
|
||||
if (!value.isEmpty() && value != null) {
|
||||
return getValue(object);
|
||||
}
|
||||
return null;
|
||||
|
||||
+13
-1
@@ -1,6 +1,8 @@
|
||||
package com.sap.sailing.gwt.ui.leaderboard;
|
||||
|
||||
import com.google.gwt.i18n.client.NumberFormat;
|
||||
import com.sap.sailing.domain.common.DetailType;
|
||||
import com.sap.sailing.gwt.ui.client.NumberFormatterFactory;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.LeaderboardRowDTO;
|
||||
|
||||
@@ -20,11 +22,21 @@ public class KingOfTheDownwindColumn extends FormattedDoubleLegDetailColumn {
|
||||
}
|
||||
|
||||
public KingOfTheDownwindColumn(StringMessages stringMessages, String headerStyle, String columnStyle) {
|
||||
super(stringMessages.totalTimeSailedDownwindInSeconds(), stringMessages.secondsUnit(),
|
||||
super(stringMessages.totalTimeSailedDownwindInSeconds(), stringMessages.hhmmssUnit(),
|
||||
new KingOfTheDownwindField(),
|
||||
DetailType.TOTAL_TIME_SAILED_DOWNWIND_IN_SECONDS.getPrecision(),
|
||||
DetailType.TOTAL_TIME_SAILED_DOWNWIND_IN_SECONDS.getDefaultSortingOrder(),
|
||||
headerStyle, columnStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStringValueToRender(LeaderboardRowDTO object) {
|
||||
Double timeInSeconds = getDoubleValue(object);
|
||||
int hh = (int) (timeInSeconds/3600);
|
||||
int mm = (int) ((timeInSeconds - 3600*hh)/60);
|
||||
int ss = (int) (timeInSeconds - 3600*hh - 60*mm);
|
||||
NumberFormat numberFormat = NumberFormatterFactory.getDecimalFormat(2, 0);
|
||||
return ""+numberFormat.format(hh)+":"+numberFormat.format(mm)+":"+numberFormat.format(ss);
|
||||
}
|
||||
|
||||
}
|
||||
+30
-2
@@ -576,7 +576,8 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
return new DetailType[] { DetailType.RACE_AVERAGE_SPEED_OVER_GROUND_IN_KNOTS,
|
||||
DetailType.RACE_DISTANCE_TRAVELED, DetailType.RACE_GAP_TO_LEADER_IN_SECONDS,
|
||||
DetailType.RACE_DISTANCE_TO_LEADER_IN_METERS, DetailType.NUMBER_OF_MANEUVERS, DetailType.DISPLAY_LEGS,
|
||||
DetailType.CURRENT_LEG, DetailType.RACE_AVERAGE_CROSS_TRACK_ERROR_IN_METERS };
|
||||
DetailType.CURRENT_LEG, DetailType.RACE_AVERAGE_CROSS_TRACK_ERROR_IN_METERS,
|
||||
DetailType.RACE_CURRENT_SPEED_OVER_GROUND_IN_KNOTS };
|
||||
}
|
||||
|
||||
public static DetailType[] getAvailableOverallDetailColumnTypes() {
|
||||
@@ -652,6 +653,13 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
DetailType.RACE_GAP_TO_LEADER_IN_SECONDS.getPrecision(),
|
||||
DetailType.RACE_GAP_TO_LEADER_IN_SECONDS.getDefaultSortingOrder(), LEG_COLUMN_HEADER_STYLE,
|
||||
LEG_COLUMN_STYLE));
|
||||
result.put(
|
||||
DetailType.RACE_CURRENT_SPEED_OVER_GROUND_IN_KNOTS,
|
||||
new FormattedDoubleLegDetailColumn(stringMessages.currentSpeedOverGroundInKnots(), "["
|
||||
+ stringMessages.currentSpeedOverGroundInKnotsUnit() + "]", new CurrentSpeedOverGroundInKnots(),
|
||||
DetailType.RACE_CURRENT_SPEED_OVER_GROUND_IN_KNOTS.getPrecision(),
|
||||
DetailType.RACE_CURRENT_SPEED_OVER_GROUND_IN_KNOTS.getDefaultSortingOrder(),
|
||||
LEG_COLUMN_HEADER_STYLE, LEG_COLUMN_STYLE));
|
||||
result.put(
|
||||
DetailType.RACE_DISTANCE_TO_LEADER_IN_METERS,
|
||||
new FormattedDoubleLegDetailColumn(stringMessages.windwardDistanceToLeader(), "["
|
||||
@@ -821,7 +829,7 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
}
|
||||
|
||||
/**
|
||||
* Accumulates the average speed over all legs of a race
|
||||
* Computes the gap to leader exploiting the ordering of the leg detail columns
|
||||
*
|
||||
* @author Axel Uhl (D043530)
|
||||
*/
|
||||
@@ -861,6 +869,26 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class CurrentSpeedOverGroundInKnots implements LegDetailField<Double> {
|
||||
@Override
|
||||
public Double get(LeaderboardRowDTO row) {
|
||||
Double result = null;
|
||||
LeaderboardEntryDTO fieldsForRace = row.fieldsByRaceColumnName.get(getRaceColumnName());
|
||||
if (fieldsForRace != null && fieldsForRace.legDetails != null) {
|
||||
int lastLegIndex = fieldsForRace.legDetails.size() - 1;
|
||||
LegEntryDTO lastLegDetail = fieldsForRace.legDetails.get(lastLegIndex);
|
||||
// competitor may be in leg prior to the one the leader is in; find competitors current leg
|
||||
while (lastLegDetail == null && lastLegIndex > 0) {
|
||||
lastLegDetail = fieldsForRace.legDetails.get(--lastLegIndex);
|
||||
}
|
||||
if (lastLegDetail != null) {
|
||||
result = lastLegDetail.currentSpeedOverGroundInKnots;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+12
-1
@@ -1,6 +1,8 @@
|
||||
package com.sap.sailing.gwt.ui.leaderboard;
|
||||
|
||||
import com.google.gwt.i18n.client.NumberFormat;
|
||||
import com.sap.sailing.domain.common.DetailType;
|
||||
import com.sap.sailing.gwt.ui.client.NumberFormatterFactory;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.LeaderboardRowDTO;
|
||||
|
||||
@@ -20,11 +22,20 @@ public class TotalTimeSailedColumn extends FormattedDoubleLegDetailColumn {
|
||||
}
|
||||
|
||||
public TotalTimeSailedColumn(StringMessages stringMessages, String headerStyle, String columnStyle) {
|
||||
super(stringMessages.totalTimeSailedInSeconds(), stringMessages.secondsUnit(),
|
||||
super(stringMessages.totalTimeSailedInSeconds(), stringMessages.hhmmssUnit(),
|
||||
new TotalTimeSailedField(),
|
||||
DetailType.TOTAL_TIME_SAILED_IN_SECONDS.getPrecision(),
|
||||
DetailType.TOTAL_TIME_SAILED_IN_SECONDS.getDefaultSortingOrder(),
|
||||
headerStyle, columnStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStringValueToRender(LeaderboardRowDTO object) {
|
||||
Double timeInSeconds = getDoubleValue(object);
|
||||
int hh = (int) (timeInSeconds/3600);
|
||||
int mm = (int) ((timeInSeconds - 3600*hh)/60);
|
||||
int ss = (int) (timeInSeconds - 3600*hh - 60*mm);
|
||||
NumberFormat numberFormat = NumberFormatterFactory.getDecimalFormat(2, 0);
|
||||
return ""+numberFormat.format(hh)+":"+numberFormat.format(mm)+":"+numberFormat.format(ss);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -510,8 +510,9 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
|
||||
* the column must always be shown.
|
||||
*/
|
||||
@Override
|
||||
protected void updateCarryColumn(LeaderboardDTO leaderboard) {
|
||||
protected boolean updateCarryColumn(LeaderboardDTO leaderboard) {
|
||||
ensureCarryColumn();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user