mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 03:13:49 +00:00
use compacting fix subclass also for buoy tracks
This commit is contained in:
1 parent
3a01b3e769
commit
4218b779fd
5 files changed
+79
-46
No files matched your search
Executable
+57
@@ -0,0 +1,57 @@
|
|||||||
|
package com.sap.sailing.domain.tracking.impl;
|
||||||
|
|
||||||
|
import com.sap.sailing.domain.base.Position;
|
||||||
|
import com.sap.sailing.domain.base.TimePoint;
|
||||||
|
import com.sap.sailing.domain.base.impl.AbstractPosition;
|
||||||
|
import com.sap.sailing.domain.base.impl.AbstractTimePoint;
|
||||||
|
import com.sap.sailing.domain.tracking.GPSFix;
|
||||||
|
|
||||||
|
public class CompactGPSFixImpl implements GPSFix {
|
||||||
|
private final double latDeg;
|
||||||
|
private final double lngDeg;
|
||||||
|
private final long timePointAsMillis;
|
||||||
|
|
||||||
|
private class CompactPosition extends AbstractPosition {
|
||||||
|
@Override
|
||||||
|
public double getLatDeg() {
|
||||||
|
return latDeg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getLngDeg() {
|
||||||
|
return lngDeg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CompactTimePoint extends AbstractTimePoint implements TimePoint {
|
||||||
|
@Override
|
||||||
|
public long asMillis() {
|
||||||
|
return timePointAsMillis;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompactGPSFixImpl(Position position, TimePoint timePoint) {
|
||||||
|
latDeg = position.getLatDeg();
|
||||||
|
lngDeg = position.getLngDeg();
|
||||||
|
timePointAsMillis = timePoint.asMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompactGPSFixImpl(GPSFix gpsFix) {
|
||||||
|
this(gpsFix.getPosition(), gpsFix.getTimePoint());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getTimePoint() + ": " + getPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position getPosition() {
|
||||||
|
return new CompactPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TimePoint getTimePoint() {
|
||||||
|
return new CompactTimePoint();
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-39
@@ -5,9 +5,7 @@ import com.sap.sailing.domain.base.Position;
|
|||||||
import com.sap.sailing.domain.base.SpeedWithBearing;
|
import com.sap.sailing.domain.base.SpeedWithBearing;
|
||||||
import com.sap.sailing.domain.base.TimePoint;
|
import com.sap.sailing.domain.base.TimePoint;
|
||||||
import com.sap.sailing.domain.base.impl.AbstractBearing;
|
import com.sap.sailing.domain.base.impl.AbstractBearing;
|
||||||
import com.sap.sailing.domain.base.impl.AbstractPosition;
|
|
||||||
import com.sap.sailing.domain.base.impl.AbstractSpeedImpl;
|
import com.sap.sailing.domain.base.impl.AbstractSpeedImpl;
|
||||||
import com.sap.sailing.domain.base.impl.AbstractTimePoint;
|
|
||||||
import com.sap.sailing.domain.tracking.GPSFixMoving;
|
import com.sap.sailing.domain.tracking.GPSFixMoving;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,10 +17,7 @@ import com.sap.sailing.domain.tracking.GPSFixMoving;
|
|||||||
* @author Axel Uhl (d043530)
|
* @author Axel Uhl (d043530)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CompactGPSFixMovingImpl implements GPSFixMoving {
|
public class CompactGPSFixMovingImpl extends CompactGPSFixImpl implements GPSFixMoving {
|
||||||
private final double latDeg;
|
|
||||||
private final double lngDeg;
|
|
||||||
private final long timePointAsMillis;
|
|
||||||
private final double knotSpeed;
|
private final double knotSpeed;
|
||||||
private final double degBearing;
|
private final double degBearing;
|
||||||
|
|
||||||
@@ -60,29 +55,8 @@ public class CompactGPSFixMovingImpl implements GPSFixMoving {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CompactPosition extends AbstractPosition {
|
|
||||||
@Override
|
|
||||||
public double getLatDeg() {
|
|
||||||
return latDeg;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getLngDeg() {
|
|
||||||
return lngDeg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CompactTimePoint extends AbstractTimePoint implements TimePoint {
|
|
||||||
@Override
|
|
||||||
public long asMillis() {
|
|
||||||
return timePointAsMillis;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompactGPSFixMovingImpl(Position position, TimePoint timePoint, SpeedWithBearing speed) {
|
public CompactGPSFixMovingImpl(Position position, TimePoint timePoint, SpeedWithBearing speed) {
|
||||||
latDeg = position.getLatDeg();
|
super(position, timePoint);
|
||||||
lngDeg = position.getLngDeg();
|
|
||||||
timePointAsMillis = timePoint.asMillis();
|
|
||||||
knotSpeed = speed.getKnots();
|
knotSpeed = speed.getKnots();
|
||||||
degBearing = speed.getBearing().getDegrees();
|
degBearing = speed.getBearing().getDegrees();
|
||||||
}
|
}
|
||||||
@@ -98,16 +72,6 @@ public class CompactGPSFixMovingImpl implements GPSFixMoving {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getTimePoint() + ": " + getPosition() + " with " + getSpeed();
|
return super.toString() + " with " + getSpeed();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Position getPosition() {
|
|
||||||
return new CompactPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TimePoint getTimePoint() {
|
|
||||||
return new CompactTimePoint();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Executable
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package com.sap.sailing.domain.tracking.impl;
|
||||||
|
|
||||||
|
import com.sap.sailing.domain.tracking.GPSFix;
|
||||||
|
|
||||||
|
public class DynamicGPSFixTrackImpl<ItemType> extends DynamicTrackImpl<ItemType, GPSFix> {
|
||||||
|
|
||||||
|
public DynamicGPSFixTrackImpl(ItemType trackedItem, long millisecondsOverWhichToAverage) {
|
||||||
|
super(trackedItem, millisecondsOverWhichToAverage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addGPSFix(GPSFix gpsFix) {
|
||||||
|
super.addGPSFix(new CompactGPSFixImpl(gpsFix));
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-7
@@ -113,9 +113,7 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
|||||||
this.buoyTracks = new HashMap<Buoy, GPSFixTrack<Buoy, GPSFix>>();
|
this.buoyTracks = new HashMap<Buoy, GPSFixTrack<Buoy, GPSFix>>();
|
||||||
for (Waypoint waypoint : race.getCourse().getWaypoints()) {
|
for (Waypoint waypoint : race.getCourse().getWaypoints()) {
|
||||||
for (Buoy buoy : waypoint.getBuoys()) {
|
for (Buoy buoy : waypoint.getBuoys()) {
|
||||||
if (!buoyTracks.containsKey(buoy)) {
|
getTrack(buoy);
|
||||||
buoyTracks.put(buoy, new DynamicTrackImpl<Buoy, GPSFix>(buoy, millisecondsOverWhichToAverageSpeed));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trackedLegs = new LinkedHashMap<Leg, TrackedLeg>();
|
trackedLegs = new LinkedHashMap<Leg, TrackedLeg>();
|
||||||
@@ -364,7 +362,7 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
|||||||
synchronized (buoyTracks) {
|
synchronized (buoyTracks) {
|
||||||
GPSFixTrack<Buoy, GPSFix> result = buoyTracks.get(buoy);
|
GPSFixTrack<Buoy, GPSFix> result = buoyTracks.get(buoy);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = new DynamicTrackImpl<Buoy, GPSFix>(buoy, millisecondsOverWhichToAverageSpeed);
|
result = new DynamicGPSFixTrackImpl<Buoy>(buoy, millisecondsOverWhichToAverageSpeed);
|
||||||
buoyTracks.put(buoy, result);
|
buoyTracks.put(buoy, result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -450,9 +448,7 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
|||||||
public synchronized void waypointAdded(int zeroBasedIndex, Waypoint waypointThatGotAdded) {
|
public synchronized void waypointAdded(int zeroBasedIndex, Waypoint waypointThatGotAdded) {
|
||||||
markPassingsForWaypoint.put(waypointThatGotAdded, new ConcurrentSkipListSet<MarkPassing>(TimedComparator.INSTANCE));
|
markPassingsForWaypoint.put(waypointThatGotAdded, new ConcurrentSkipListSet<MarkPassing>(TimedComparator.INSTANCE));
|
||||||
for (Buoy buoy : waypointThatGotAdded.getBuoys()) {
|
for (Buoy buoy : waypointThatGotAdded.getBuoys()) {
|
||||||
if (!buoyTracks.containsKey(buoy)) {
|
getTrack(buoy);
|
||||||
buoyTracks.put(buoy, new DynamicTrackImpl<Buoy, GPSFix>(buoy, millisecondsOverWhichToAverageSpeed));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// a waypoint got added; this means that a leg got added as well; but we shouldn't claim we know where
|
// a waypoint got added; this means that a leg got added as well; but we shouldn't claim we know where
|
||||||
// in the leg list of the course the leg was added; that's an implementation secret of CourseImpl. So try:
|
// in the leg list of the course the leg was added; that's an implementation secret of CourseImpl. So try:
|
||||||
|
|||||||
+1
@@ -23,6 +23,7 @@ public class ExpeditionWindTrackerFactory implements WindTrackerFactory, BundleA
|
|||||||
private static BundleContext defaultBundleContext;
|
private static BundleContext defaultBundleContext;
|
||||||
|
|
||||||
private static final String EXPEDITION_UDP_PORT_PROPERTY_NAME = "expedition.udp.port";
|
private static final String EXPEDITION_UDP_PORT_PROPERTY_NAME = "expedition.udp.port";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remembers the wind tracker and the port on which the UDP receiver with which the wind tracker is
|
* Remembers the wind tracker and the port on which the UDP receiver with which the wind tracker is
|
||||||
* registers is listening for incoming Expedition messages.
|
* registers is listening for incoming Expedition messages.
|
||||||
|
|||||||
Reference in new issue
Block a user