コード例 #1
0
 public Double calculateAngle(NavigationPosition other) {
   if (hasCoordinates() && other.hasCoordinates()) {
     Bearing bearing =
         calculateBearing(
             getLongitude(), getLatitude(), other.getLongitude(), other.getLatitude());
     return bearing.getAngle();
   }
   return null;
 }
コード例 #2
0
 public Double calculateSpeed(NavigationPosition other) {
   if (getTime() != null && other.getTime() != null) {
     double interval =
         abs(getTime().getTimeInMillis() - other.getTime().getTimeInMillis()) / 1000.0;
     Double distance = calculateDistance(other);
     if (distance != null && interval > 0.0) return distance / interval * 3.6;
   }
   return null;
 }
コード例 #3
0
 public Double calculateOrthogonalDistance(NavigationPosition pointA, NavigationPosition pointB) {
   if (hasCoordinates() && pointA.hasCoordinates() && pointB.hasCoordinates()) {
     Bearing bearingAD =
         calculateBearing(
             pointA.getLongitude(), pointA.getLatitude(), getLongitude(), getLatitude());
     Double distanceAtoD = bearingAD.getDistance();
     if (distanceAtoD != null) {
       double courseAtoD = toRadians(bearingAD.getAngle());
       double courseAtoB = toRadians(pointA.calculateAngle(pointB));
       return asin(sin(distanceAtoD / EARTH_RADIUS) * sin(courseAtoD - courseAtoB)) * EARTH_RADIUS;
     }
   }
   return null;
 }
コード例 #4
0
 public Long calculateTime(NavigationPosition other) {
   if (getTime() != null && other.getTime() != null) {
     return other.getTime().getTimeInMillis() - getTime().getTimeInMillis();
   }
   return null;
 }
コード例 #5
0
 public Double calculateElevation(NavigationPosition other) {
   if (getElevation() != null && other.getElevation() != null) {
     return other.getElevation() - getElevation();
   }
   return null;
 }
コード例 #6
0
 public Double calculateDistance(NavigationPosition other) {
   return other.hasCoordinates()
       ? calculateDistance(other.getLongitude(), other.getLatitude())
       : null;
 }