mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-16 07:10:48 +00:00
Merge branch 'master' into permission-vertical
This commit is contained in:
commit
772ec406d8
9 files changed
+138
-41
No files matched your search
+6
-1
@@ -246,11 +246,16 @@ public abstract class OnlineTracTracBasedTest extends AbstractTracTracLiveTest i
|
||||
protected void setUpWithoutLaunchingController(String regattaName, String raceId, final URI liveUri,
|
||||
final URI storedUri) throws MalformedURLException, FileNotFoundException, URISyntaxException,
|
||||
SubscriberInitializationException, CreateModelException {
|
||||
final URL paramUrl = new URL("http://" + TracTracConnectionConstants.HOST_NAME + "/events/"+regattaName+"/"+raceId+".txt");
|
||||
final URL paramUrl = getParamUrl(regattaName, raceId);
|
||||
setUpWithoutLaunchingController(paramUrl, liveUri, storedUri);
|
||||
}
|
||||
|
||||
|
||||
protected URL getParamUrl(String regattaName, String raceId) throws MalformedURLException {
|
||||
return new URL("http://" + TracTracConnectionConstants.HOST_NAME + "/events/"+regattaName+"/"+raceId+".txt");
|
||||
}
|
||||
|
||||
|
||||
protected void setUpWithoutLaunchingController(final URL paramUrl, final URI liveUri, final URI storedUri)
|
||||
throws FileNotFoundException, MalformedURLException, URISyntaxException, SubscriberInitializationException, CreateModelException {
|
||||
super.setUp(paramUrl, liveUri, storedUri);
|
||||
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.sap.sailing.domain.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.common.WindSourceType;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
import com.sap.sailing.domain.common.impl.KnotSpeedWithBearingImpl;
|
||||
import com.sap.sailing.domain.common.impl.WindImpl;
|
||||
import com.sap.sailing.domain.common.impl.WindSourceImpl;
|
||||
import com.sap.sailing.domain.tractracadapter.ReceiverType;
|
||||
import com.sap.sse.common.impl.DegreeBearingImpl;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
import com.tractrac.model.lib.api.event.CreateModelException;
|
||||
import com.tractrac.subscription.lib.api.SubscriberInitializationException;
|
||||
|
||||
/**
|
||||
* See bug 5004
|
||||
*
|
||||
* @author Axel Uhl (d043530)
|
||||
*
|
||||
*/
|
||||
public class SteadyRankingForBiasedFinishLineTest extends OnlineTracTracBasedTest {
|
||||
final static MillisecondsTimePoint TIME_14_30_00 = new MillisecondsTimePoint(1555849800000l);
|
||||
final static MillisecondsTimePoint TIME_14_30_12 = new MillisecondsTimePoint(1555849812000l);
|
||||
|
||||
public SteadyRankingForBiasedFinishLineTest() throws MalformedURLException, URISyntaxException {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getExpectedEventName() {
|
||||
return "Sailing World Cup Genoa 2019";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URL getParamUrl(String regattaName, String raceId) throws MalformedURLException {
|
||||
// TODO adjust once TracTrac has migrated this to the regular back-end; download .mtb file to local resource
|
||||
return new URL("http://aws.tractrac.com/events/"+regattaName+"/clientparams.php?event="+regattaName+"&race="+raceId);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws MalformedURLException, IOException, InterruptedException, URISyntaxException, ParseException, SubscriberInitializationException, CreateModelException {
|
||||
super.setUp();
|
||||
super.setUp("event_20190412_SailingWor",
|
||||
/* raceId */ "0fb18f50-45d7-0137-24dd-021d89ada30e",
|
||||
/* liveUri */ null, /* storedUri */ null,
|
||||
new ReceiverType[] { ReceiverType.MARKPASSINGS, ReceiverType.RACECOURSE, ReceiverType.RAWPOSITIONS, ReceiverType.MARKPOSITIONS, ReceiverType.RACECOURSE,
|
||||
ReceiverType.RACESTARTFINISH });
|
||||
getTrackedRace().recordWind(new WindImpl(/* position */ new DegreePosition(44.37670797575265, 8.925960855558515), TIME_14_30_00,
|
||||
new KnotSpeedWithBearingImpl(7.5, new DegreeBearingImpl(246).reverse())), new WindSourceImpl(WindSourceType.WEB));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVadnaiLead() {
|
||||
Competitor vadnai = getCompetitorByName("Benjamin Vadnai");
|
||||
Competitor lewis = getCompetitorByName("Andrew Lewis");
|
||||
Competitor lynch = getCompetitorByName("Finn Lynch");
|
||||
Competitor blanco = getCompetitorByName("Joaquín Blanco");
|
||||
assertEquals(1, getTrackedRace().getRank(vadnai, TIME_14_30_00));
|
||||
assertEquals(2, getTrackedRace().getRank(lewis, TIME_14_30_00));
|
||||
assertEquals(3, getTrackedRace().getRank(lynch, TIME_14_30_00));
|
||||
assertEquals(4, getTrackedRace().getRank(blanco, TIME_14_30_00));
|
||||
assertEquals(1, getTrackedRace().getRank(vadnai, TIME_14_30_12));
|
||||
assertEquals(2, getTrackedRace().getRank(lewis, TIME_14_30_12));
|
||||
assertEquals(3, getTrackedRace().getRank(lynch, TIME_14_30_12));
|
||||
assertEquals(4, getTrackedRace().getRank(blanco, TIME_14_30_12));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -117,6 +117,13 @@ public interface TrackedLeg extends Serializable {
|
||||
*/
|
||||
Distance getAbsoluteWindwardDistance(Position pos1, Position pos2, TimePoint at, WindPositionMode windPositionMode, WindLegTypeAndLegBearingCache cache);
|
||||
|
||||
/**
|
||||
* Same as {@link #getWindwardDistance(Position, Position, TimePoint, WindPositionMode)}, only that a cache
|
||||
* for leg types, wind data and leg bearings can be passed to save the effort of redundant calculations of these
|
||||
* values.
|
||||
*/
|
||||
Distance getWindwardDistance(final Position pos1, final Position pos2, TimePoint at, WindPositionMode windPositionMode, WindLegTypeAndLegBearingCache cache);
|
||||
|
||||
/**
|
||||
* Same as {@link #getAbsoluteWindwardDistance(Position, Position, TimePoint, WindPositionMode)}, but this method considers the leg's
|
||||
* direction and will return a negative distance if <code>pos1</code> is already "ahead" of <code>pos2</code> in the
|
||||
|
||||
+3
-1
@@ -62,7 +62,9 @@ public interface TrackedLegOfCompetitor extends Serializable {
|
||||
* direction. If the competitor already finished this leg, a zero, non-<code>null</code> 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);
|
||||
|
||||
|
||||
+3
@@ -166,5 +166,8 @@ public abstract class AbstractRaceRankComparator<C extends Comparable<C>> implem
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A distance to use for competitor comparison. Less means better rank. Negative distances are allowed.
|
||||
*/
|
||||
protected abstract C getComparisonValueForSameLeg(Competitor competitor);
|
||||
}
|
||||
+2
-1
@@ -481,7 +481,8 @@ public class TrackedLegImpl implements TrackedLeg {
|
||||
return getAbsoluteWindwardDistance(fromPos, toPos, middle, WindPositionMode.LEG_MIDDLE, cache);
|
||||
}
|
||||
|
||||
Distance getWindwardDistance(final Position pos1, final Position pos2, TimePoint at, WindPositionMode windPositionMode, WindLegTypeAndLegBearingCache cache) {
|
||||
@Override
|
||||
public Distance getWindwardDistance(final Position pos1, final Position pos2, TimePoint at, WindPositionMode windPositionMode, WindLegTypeAndLegBearingCache cache) {
|
||||
Distance result;
|
||||
if (pos1 == null || pos2 == null) {
|
||||
result = null;
|
||||
|
||||
+20
-23
@@ -9,7 +9,6 @@ import java.util.function.BiFunction;
|
||||
import com.sap.sailing.domain.base.Boat;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.Leg;
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sailing.domain.common.LegType;
|
||||
import com.sap.sailing.domain.common.ManeuverType;
|
||||
@@ -221,18 +220,13 @@ public class TrackedLegOfCompetitorImpl implements TrackedLegOfCompetitor {
|
||||
|
||||
@Override
|
||||
public Distance getWindwardDistanceToGo(TimePoint timePoint, WindPositionMode windPositionMode, WindLegTypeAndLegBearingCache cache) {
|
||||
final Distance result;
|
||||
if (hasFinishedLeg(timePoint)) {
|
||||
return Distance.NULL;
|
||||
result = Distance.NULL;
|
||||
} else {
|
||||
Distance result = null;
|
||||
for (Mark mark : getLeg().getTo().getMarks()) {
|
||||
Distance d = getWindwardDistanceTo(mark, timePoint, windPositionMode, cache);
|
||||
if (result == null || d != null && d.compareTo(result) < 0) {
|
||||
result = d;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
result = getWindwardDistanceTo(getLeg().getTo(), timePoint, windPositionMode, cache);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -241,22 +235,25 @@ public class TrackedLegOfCompetitorImpl implements TrackedLegOfCompetitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 <code>mark</code> in the wind's
|
||||
* bearing, and the distance from the projection to the <code>mark</code> is returned. Otherwise, it is assumed that
|
||||
* the leg is neither an upwind nor a downwind leg, and hence the true distance to <code>mark</code> 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 <code>waypoint</code> (its
|
||||
* approximate position) in the wind's bearing, and the distance from the projection to the <code>waypoint</code> is
|
||||
* returned. Otherwise, it is assumed that the leg is neither an upwind nor a downwind leg, and hence the
|
||||
* along-track distance to <code>waypoint</code> is returned. A cache for wind and leg type / bearing can be passed to
|
||||
* avoid their redundant calculation during a single round-trip.
|
||||
* <p>
|
||||
*
|
||||
* If no wind information is available, again the true geometrical distance to <code>mark</code> is returned.
|
||||
* If no wind information is available, again the along-track distance to <code>waypoint</code> is returned.
|
||||
* <p>
|
||||
*
|
||||
* If the competitor's position or the mark's position cannot be determined, <code>null</code> is returned.
|
||||
* If the competitor's position or the waypoint's position cannot be determined, <code>null</code> is returned.
|
||||
* <code>null</code> 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.<p>
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user