Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

optimize BaseNavigationPosition#calculateOrthogonalDistance

  • Loading branch information...
commit 48d7369779ccdc133a9b41be7aa28b99ee8880bc 1 parent 6faf263
Christian Pesch authored
5 navigation-formats/src/main/java/slash/navigation/base/BaseNavigationPosition.java
View
@@ -219,9 +219,10 @@ public Double calculateAngle(BaseNavigationPosition other) {
*/
public Double calculateOrthogonalDistance(BaseNavigationPosition pointA, BaseNavigationPosition pointB) {
if (hasCoordinates() && pointA.hasCoordinates() && pointB.hasCoordinates()) {
- Double distanceAtoD = calculateDistance(pointA);
+ Bearing bearingAD = calculateBearing(pointA.getLongitude(), pointA.getLatitude(), getLongitude(), getLatitude());
+ Double distanceAtoD = bearingAD.getDistance();
if (distanceAtoD != null) {
- double courseAtoD = toRadians(pointA.calculateAngle(this));
+ double courseAtoD = toRadians(bearingAD.getAngle());
double courseAtoB = toRadians(pointA.calculateAngle(pointB));
return asin(sin(distanceAtoD / EARTH_RADIUS) *
sin(courseAtoD - courseAtoB)) * EARTH_RADIUS;
Please sign in to comment.
Something went wrong with that request. Please try again.