mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-26 23:46:36 +00:00
fixed visibilities, avoid warnings
This commit is contained in:
@@ -5,6 +5,8 @@ import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -17,10 +19,32 @@ import com.sap.sailing.domain.tracking.Wind;
|
||||
import com.sap.sailing.domain.tracking.WindTrack;
|
||||
import com.sap.sailing.domain.tracking.impl.WindImpl;
|
||||
import com.sap.sailing.domain.tracking.impl.WindTrackImpl;
|
||||
import com.sap.sailing.util.Util;
|
||||
|
||||
public class WindTest {
|
||||
private static final int AVERAGING_INTERVAL_MILLIS = 30000 /* 30s averaging interval */;
|
||||
|
||||
@Test
|
||||
public void testMultipleWindFixesWithSameTimestampInSameWindTrack() {
|
||||
WindTrack track = new WindTrackImpl(AVERAGING_INTERVAL_MILLIS);
|
||||
TimePoint now = MillisecondsTimePoint.now();
|
||||
DegreePosition pos1 = new DegreePosition(0, 0);
|
||||
DegreePosition pos2 = new DegreePosition(1, 1);
|
||||
Wind wind1 = new WindImpl(pos1, now, new KnotSpeedWithBearingImpl(10, new DegreeBearingImpl(0)));
|
||||
Wind wind2 = new WindImpl(pos2, now, new KnotSpeedWithBearingImpl(20, new DegreeBearingImpl(0)));
|
||||
track.add(wind1);
|
||||
track.add(wind2);
|
||||
assertEquals(2, Util.size(track.getFixes()));
|
||||
Set<Wind> expectedWind = new HashSet<Wind>();
|
||||
expectedWind.add(wind1);
|
||||
expectedWind.add(wind2);
|
||||
Set<Wind> actualWind = new HashSet<Wind>();
|
||||
for (Wind wind : track.getFixes()) {
|
||||
actualWind.add(wind);
|
||||
}
|
||||
assertEquals(expectedWind, actualWind);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyTrackYieldsNullAsWindEstimate() {
|
||||
WindTrack track = new WindTrackImpl(AVERAGING_INTERVAL_MILLIS);
|
||||
|
||||
@@ -32,10 +32,13 @@ public abstract class TrackImpl<FixType extends Timed> implements Track<FixType>
|
||||
}
|
||||
|
||||
public TrackImpl() {
|
||||
super();
|
||||
this.fixes = new ArrayListNavigableSet<Timed>(TimedComparator.INSTANCE);
|
||||
this(new ArrayListNavigableSet<Timed>(TimedComparator.INSTANCE));
|
||||
}
|
||||
|
||||
protected TrackImpl(NavigableSet<Timed> fixes) {
|
||||
this.fixes = fixes;
|
||||
}
|
||||
|
||||
protected NavigableSet<FixType> getInternalRawFixes() {
|
||||
@SuppressWarnings("unchecked")
|
||||
NavigableSet<FixType> result = (NavigableSet<FixType>) fixes;
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.sap.sailing.domain.tracking.impl;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.sap.sailing.domain.base.Timed;
|
||||
import com.sap.sailing.domain.tracking.Wind;
|
||||
|
||||
/**
|
||||
* Compares two {@link Wind} objects first by their {@link Wind#getTimePoint() time point}. Only if both
|
||||
* wind fixes were taken at the same time, their position is used as a secondary criteria. A more or less
|
||||
* arbitrary ordering is used, sorting first by latitude, and if that is equal too, sorting by longitude.
|
||||
*
|
||||
* @author Axel Uhl (d043530)
|
||||
*
|
||||
*/
|
||||
public class WindComparator implements Comparator<Timed> {
|
||||
public static final Comparator<Timed> INSTANCE = new WindComparator();
|
||||
|
||||
@Override
|
||||
public int compare(Timed o1, Timed o2) {
|
||||
int result = o1.getTimePoint().compareTo(o2.getTimePoint());
|
||||
if (result == 0) {
|
||||
if (o1 instanceof Wind && o2 instanceof Wind) {
|
||||
Wind o1Wind = (Wind) o1;
|
||||
Wind o2Wind = (Wind) o2;
|
||||
// use the coordinates as secondary criteria:
|
||||
result = Double.compare(o1Wind.getPosition().getLatDeg(), o2Wind.getPosition().getLatDeg());
|
||||
if (result == 0) {
|
||||
result = Double.compare(o1Wind.getPosition().getLngDeg(), o2Wind.getPosition().getLngDeg());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -13,11 +13,13 @@ import com.sap.sailing.domain.base.Position;
|
||||
import com.sap.sailing.domain.base.Speed;
|
||||
import com.sap.sailing.domain.base.SpeedWithBearing;
|
||||
import com.sap.sailing.domain.base.TimePoint;
|
||||
import com.sap.sailing.domain.base.Timed;
|
||||
import com.sap.sailing.domain.base.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.domain.base.impl.KnotSpeedWithBearingImpl;
|
||||
import com.sap.sailing.domain.tracking.Wind;
|
||||
import com.sap.sailing.domain.tracking.WindListener;
|
||||
import com.sap.sailing.domain.tracking.WindTrack;
|
||||
import com.sap.sailing.util.impl.ArrayListNavigableSet;
|
||||
|
||||
/**
|
||||
* Records {@link Wind} objects over time and offers to average the last so many of them into an
|
||||
@@ -35,6 +37,7 @@ public class WindTrackImpl extends TrackImpl<Wind> implements WindTrack {
|
||||
private final Set<WindListener> listeners;
|
||||
|
||||
public WindTrackImpl(long millisecondsOverWhichToAverage) {
|
||||
super(new ArrayListNavigableSet<Timed>(WindComparator.INSTANCE));
|
||||
this.millisecondsOverWhichToAverage = millisecondsOverWhichToAverage;
|
||||
listeners = new HashSet<WindListener>();
|
||||
}
|
||||
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.4.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.4.0/distro-source/core/src/gwt-module.dtd">
|
||||
<module>
|
||||
<inherits name="com.google.gwt.user.User" />
|
||||
<inherits name="com.sap.sailing.gwt.ui.AdminConsole" />
|
||||
<source path="client"/>
|
||||
|
||||
<servlet path='/testsailing' class='com.sap.sailing.gwt.ui.test.TestSailingServiceImpl'/>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.4.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.4.0/distro-source/core/src/gwt-module.dtd">
|
||||
<module>
|
||||
<inherits name="com.google.gwt.user.User" />
|
||||
<inherits name="com.sap.sailing.gwt.ui.AdminConsole" />
|
||||
<source path="client"/>
|
||||
|
||||
<servlet path='/testsailing' class='com.sap.sailing.gwt.ui.test.MyTestSailingServiceImpl'/>
|
||||
</module>
|
||||
@@ -2,8 +2,7 @@ source.. = src/,\
|
||||
resources/
|
||||
output.. = bin
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
war/
|
||||
.
|
||||
jars.compile.order = .
|
||||
source.. = src/,\
|
||||
resources/
|
||||
|
||||
@@ -28,7 +28,7 @@ Bundle-ClassPath: lib/gwt-maps.jar,
|
||||
Bundle-Activator: com.sap.sailing.gwt.ui.server.Activator
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.sap.sailing.gwt.ui.client;x-friends:="com.sap.sailing.gwt.ui.test",
|
||||
com.sap.sailing.gwt.ui.server;x-friends:="com.sap.sailing.gwt.ui.test",
|
||||
com.sap.sailing.gwt.ui.server;x-friends:="com.sap.sailing.gwt.ui.test,com.sap.ui.phoenix.resource-osgi",
|
||||
com.sap.sailing.gwt.ui.shared;x-friends:="com.sap.sailing.gwt.ui.test"
|
||||
Import-Package: org.osgi.framework,
|
||||
org.osgi.util.tracker,
|
||||
|
||||
Reference in New Issue
Block a user