pos1 is already "ahead" of pos2 in the
diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedLegOfCompetitor.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedLegOfCompetitor.java
index 72eb01858a6..4fba5147b45 100755
--- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedLegOfCompetitor.java
+++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedLegOfCompetitor.java
@@ -62,7 +62,9 @@ public interface TrackedLegOfCompetitor extends Serializable {
* direction. If the competitor already finished this leg, a zero, non-null distance will result.
* If the competitor hasn't started the leg yet, the full leg distance is returned. For reaching legs or when
* no wind information is available, the projection onto the leg's direction will be used instead of wind
- * projection.
+ * projection. When for the {@code timePoint} given the competitor hasn't finished the leg yet but has
+ * already passed the approximate windward / along course position of the leg's end, a negative distance
+ * will result.
*/
Distance getWindwardDistanceToGo(TimePoint timePoint, WindPositionMode windPositionMode);
diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/AbstractRaceRankComparator.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/AbstractRaceRankComparator.java
index ed83da1f4b6..50762cf20e8 100644
--- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/AbstractRaceRankComparator.java
+++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/AbstractRaceRankComparator.java
@@ -166,5 +166,8 @@ public abstract class AbstractRaceRankComparatormark in the wind's
- * bearing, and the distance from the projection to the mark is returned. Otherwise, it is assumed that
- * the leg is neither an upwind nor a downwind leg, and hence the true distance to mark is returned. A
- * cache for wind and leg type / bearing can be passed to avoid their redundant calculation during a single
- * round-trip.
+ * If the current {@link #getLeg() leg} is +/- {@link LegType#UPWIND_DOWNWIND_TOLERANCE_IN_DEG} degrees collinear
+ * with the wind's bearing, the competitor's position is projected onto the line crossing waypoint (its
+ * approximate position) in the wind's bearing, and the distance from the projection to the waypoint is
+ * returned. Otherwise, it is assumed that the leg is neither an upwind nor a downwind leg, and hence the
+ * along-track distance to waypoint is returned. A cache for wind and leg type / bearing can be passed to
+ * avoid their redundant calculation during a single round-trip.
*
*
- * If no wind information is available, again the true geometrical distance to mark is returned.
+ * If no wind information is available, again the along-track distance to waypoint is returned.
*
*
- * If the competitor's position or the mark's position cannot be determined, null is returned.
+ * If the competitor's position or the waypoint's position cannot be determined, null is returned.
* null is also returned if the leg's bearing cannot be determined because for at least one of its two
- * waypoints no mark has a known position.
+ * waypoints no mark has a known position.
+ * + * The distance returned may turn negative if the competitor sailed past the approximate windward position of the + * leg's {@link Leg#getTo() end waypoint} but hasn't finished the leg yet. */ - private Distance getWindwardDistanceTo(Mark mark, TimePoint at, WindPositionMode windPositionMode, WindLegTypeAndLegBearingCache cache) { + private Distance getWindwardDistanceTo(Waypoint waypoint, TimePoint at, WindPositionMode windPositionMode, WindLegTypeAndLegBearingCache cache) { Position estimatedPosition = getTrackedRace().getTrack(getCompetitor()).getEstimatedPosition(at, false); if (!hasStartedLeg(at) || estimatedPosition == null) { // covers the case with no fixes for this leg yet, also if the mark passing has already been received @@ -266,11 +263,11 @@ public class TrackedLegOfCompetitorImpl implements TrackedLegOfCompetitor { if (estimatedPosition == null) { // may happen if mark positions haven't been received yet return null; } - final Position estimatedMarkPosition = getTrackedRace().getOrCreateTrack(mark).getEstimatedPosition(at, false); - if (estimatedMarkPosition == null) { + final Position approximateWaypointPosition = getTrackedRace().getApproximatePosition(waypoint, at); + if (approximateWaypointPosition == null) { return null; } - return getTrackedLeg().getAbsoluteWindwardDistance(estimatedPosition, estimatedMarkPosition, at, windPositionMode, cache); + return getTrackedLeg().getWindwardDistance(estimatedPosition, approximateWaypointPosition, at, windPositionMode, cache); } /** diff --git a/java/com.sap.sailing.mongodb.test/src/com/sap/sailing/mongodb/test/MongoClientURITest.java b/java/com.sap.sailing.mongodb.test/src/com/sap/sailing/mongodb/test/MongoClientURITest.java index a29347972e2..39385c06732 100755 --- a/java/com.sap.sailing.mongodb.test/src/com/sap/sailing/mongodb/test/MongoClientURITest.java +++ b/java/com.sap.sailing.mongodb.test/src/com/sap/sailing/mongodb/test/MongoClientURITest.java @@ -19,7 +19,7 @@ public class MongoClientURITest { } @Test - public void testSpecifigConnectionOptions() { + public void testSpecificConnectionOptions() { MongoDBConfiguration config = new MongoDBConfiguration("mongodb://humba:12345/mydb?replicaset=rs0&readpreference=primary"); assertEquals("humba", config.getHostname()); assertEquals(12345, config.getPort()); diff --git a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBConfiguration.java b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBConfiguration.java index 6c385c9e281..3d8c8cda1e2 100644 --- a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBConfiguration.java +++ b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBConfiguration.java @@ -60,23 +60,27 @@ public class MongoDBConfiguration { } public static MongoDBConfiguration getDefaultTestConfiguration() { - String defaultHostName = "127.0.0.1"; - if (System.getProperty(MONGO_HOSTNAME) != null) { - defaultHostName = System.getProperty(MONGO_HOSTNAME); - } else { - if (System.getenv("MONGODB_HOST") != null) { - defaultHostName = System.getenv("MONGODB_HOST"); - } - } - String defaultDatabaseName = System.getProperty(MONGO_DB_NAME, DEFAULT_TEST_DB_NAME); final MongoDBConfiguration result; - if (System.getProperty(MONGO_PORT) != null) { - result = new MongoDBConfiguration(defaultHostName, Integer.valueOf(System.getProperty(MONGO_PORT).trim()), defaultDatabaseName); + if (System.getProperty(MONGO_URI) != null) { + result = new MongoDBConfiguration(new MongoClientURI(System.getProperty(MONGO_URI))); } else { - if (System.getenv("MONGODB_PORT") != null) { - result = new MongoDBConfiguration(defaultHostName, Integer.valueOf(System.getenv("MONGODB_PORT").trim()), defaultDatabaseName); + String defaultHostName = "127.0.0.1"; + if (System.getProperty(MONGO_HOSTNAME) != null) { + defaultHostName = System.getProperty(MONGO_HOSTNAME); } else { - result = new MongoDBConfiguration(defaultHostName, defaultDatabaseName); + if (System.getenv("MONGODB_HOST") != null) { + defaultHostName = System.getenv("MONGODB_HOST"); + } + } + String defaultDatabaseName = System.getProperty(MONGO_DB_NAME, DEFAULT_TEST_DB_NAME); + if (System.getProperty(MONGO_PORT) != null) { + result = new MongoDBConfiguration(defaultHostName, Integer.valueOf(System.getProperty(MONGO_PORT).trim()), defaultDatabaseName); + } else { + if (System.getenv("MONGODB_PORT") != null) { + result = new MongoDBConfiguration(defaultHostName, Integer.valueOf(System.getenv("MONGODB_PORT").trim()), defaultDatabaseName); + } else { + result = new MongoDBConfiguration(defaultHostName, defaultDatabaseName); + } } } return result;