I got rid of the isTurn method from the AbstractPosition

This commit is contained in:
I077899 committed 2013-03-22 14:11:07 +02:00
1 parent 012850ec68
commit 0adfb84db8
3 files changed
+15 -20

No files matched your search

@@ -6,7 +6,6 @@ import com.sap.sailing.domain.common.impl.RadianPosition;
public class AbstractPosition implements Position {
private static final double TRESHOLD_DEGREES = 25.0;
private static final long serialVersionUID = -3057027562787541064L;
@Override
@@ -123,17 +122,4 @@ public class AbstractPosition implements Position {
public String toString() {
return "("+getLatDeg()+","+getLngDeg()+")";
}
@Override
public boolean isTurn(final Position previousPoint, final Position nextPoint) {
final Bearing b1 = previousPoint.getBearingGreatCircle(this);
final Bearing b2 = this.getBearingGreatCircle(nextPoint);
double diff = b1.getDifferenceTo(b2).getDegrees();
if (diff < 0) {
diff = 360 + diff;
}
return !((diff >= 0 && diff <= TRESHOLD_DEGREES) || (diff >= (180 - TRESHOLD_DEGREES) && diff <= (180 + TRESHOLD_DEGREES)) || (diff >= (360 - TRESHOLD_DEGREES) && diff <= 360));
}
}
@@ -57,9 +57,4 @@ public interface Position extends Serializable {
* no solution, and a <code>NaN</code> or exception will result.
*/
Distance alongTrackDistance(Position p, Bearing bearing);
/**
* Returns true is the current position can be considered a turn comparing to the previous and the next one.
*/
boolean isTurn(Position previousPoint, Position nextPoint);
}
@@ -24,6 +24,8 @@ import com.sap.sailing.simulator.windfield.WindField;
public class PathImpl implements Path, Serializable {
private static final double TRESHOLD_DEGREES = 25.0;
private static final long serialVersionUID = -6354445155884413937L;
List<TimedPositionWithSpeed> pathPoints;
WindField windField;
@@ -266,7 +268,7 @@ public class PathImpl implements Path, Serializable {
previousPoint = this.pathPoints.get(index - 1);
nextPoint = this.pathPoints.get(index + 1);
if (currentPoint.getPosition().isTurn(previousPoint.getPosition(), nextPoint.getPosition())) {
if (isTurn(currentPoint.getPosition(), previousPoint.getPosition(), nextPoint.getPosition())) {
list.add(currentPoint);
}
}
@@ -356,4 +358,16 @@ public class PathImpl implements Path, Serializable {
return true;
}
private static boolean isTurn(Position currentPosition, Position previousPoint, Position nextPoint) {
final Bearing b1 = previousPoint.getBearingGreatCircle(currentPosition);
final Bearing b2 = currentPosition.getBearingGreatCircle(nextPoint);
double diff = b1.getDifferenceTo(b2).getDegrees();
if (diff < 0) {
diff = 360 + diff;
}
return !((diff >= 0 && diff <= TRESHOLD_DEGREES) || (diff >= (180 - TRESHOLD_DEGREES) && diff <= (180 + TRESHOLD_DEGREES)) || (diff >= (360 - TRESHOLD_DEGREES) && diff <= 360));
}
}