mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
fixed NPE bug 1453 in start analysis in case a mark position is not known
This commit is contained in:
1 parent
9ca047a8f5
commit
30df01b9af
2 files changed
+30
-18
No files matched your search
+11
-7
@@ -63,13 +63,17 @@ public class AbstractPosition implements Position {
|
||||
|
||||
@Override
|
||||
public Bearing getBearingGreatCircle(Position p) {
|
||||
double result = Math.atan2(Math.sin(p.getLngRad()-getLngRad()) * Math.cos(p.getLatRad()),
|
||||
Math.cos(getLatRad())*Math.sin(p.getLatRad()) -
|
||||
Math.sin(getLatRad())*Math.cos(p.getLatRad())*Math.cos(p.getLngRad()-getLngRad())) ;
|
||||
if (result < 0) {
|
||||
result = result + 2*Math.PI;
|
||||
Bearing bearing = null;
|
||||
if (p != null) {
|
||||
double result = Math.atan2(Math.sin(p.getLngRad() - getLngRad()) * Math.cos(p.getLatRad()),
|
||||
Math.cos(getLatRad()) * Math.sin(p.getLatRad()) - Math.sin(getLatRad()) * Math.cos(p.getLatRad())
|
||||
* Math.cos(p.getLngRad() - getLngRad()));
|
||||
if (result < 0) {
|
||||
result = result + 2 * Math.PI;
|
||||
}
|
||||
bearing = new RadianBearingImpl(result);
|
||||
}
|
||||
return new RadianBearingImpl(result);
|
||||
return bearing;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,7 +127,7 @@ public class AbstractPosition implements Position {
|
||||
@Override
|
||||
public Distance alongTrackDistance(Position pos2, Bearing bearing) {
|
||||
double direction = Math.signum(Math.cos(pos2.getBearingGreatCircle(this).getRadians() - bearing.getRadians()));
|
||||
// Test if denominator gets ridiculously small; if so, the cross-track error is about 90° central angle.
|
||||
// Test if denominator gets ridiculously small; if so, the cross-track error is about 90� central angle.
|
||||
// This means that the cross-track error is maximized, and that there is no way to determine how far along
|
||||
// the great circle described by pos2 and bearing we should travel. This is an exception which will
|
||||
// surface as a division-by-zero exception or a NaN result
|
||||
|
||||
Reference in new issue
Block a user