components/src/main/java/eu/internetofus/common/components/personal_context_builder/UserDistance.java
/**
   * Calculate the distance between two positions. This is calculate with the
   * (<a href="https://www.movable-type.co.uk/scripts/latlong.html">haversine
   * formula</a>.
   *
   * @param sourceLatitude  source location latitude.
   * @param sourceLongitude source location longitude.
   * @param targetLatitude  source location latitude.
   * @param targetLongitude source location longitude.
   *
   * @return the distance in meters between the two locations.
   */
Calculate the distance between two positions. This is calculate with the
(haversine
formula.

@param sourceLatitude  source location latitude.
@param sourceLongitude source location longitude.
@param targetLatitude  source location latitude.
@param targetLongitude source location longitude.

@return the distance in meters between the two locations.
Calculate the distance between two positions . This is calculate with the ( haversine formula . @param sourceLatitude source location latitude . @param sourceLongitude source location longitude . @param targetLatitude source location latitude . @param targetLongitude source location longitude . @return the distance in meters between the two locations .
public static double calculateDistance(final double sourceLatitude, final double sourceLongitude,
      final double targetLatitude, final double targetLongitude) {
    final var R = 6371e3; 
    final var φ1 = sourceLatitude * Math.PI / 180; /
    final var φ2 = targetLatitude * Math.PI / 180;
    final var Δφ = (targetLatitude - sourceLatitude) * Math.PI / 180;
    final var Δλ = (targetLongitude - sourceLongitude) * Math.PI / 180;
    final var a = Math.sin(Δφ / 2) * Math.sin(Δφ / 2)
        + Math.cos(φ1) * Math.cos(φ2) * Math.sin(Δλ / 2) * Math.sin(Δλ / 2);
    final var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
    return R * c; 
  }
public static double calculateDistance ( final double sourceLatitude , final double sourceLongitude , final double targetLatitude , final double targetLongitude ) { final var R = 6371e3 ; final var φ1  ourceLatitude  ath. P I  80; final var φ2  argetLatitude  ath. P I  80; final var Δφ = ( a rgetLatitude - s urceLatitude)  * M th.P I  / 1 0; final var Δλ = ( a rgetLongitude - s urceLongitude)  * M th.P I  / 1 0; final var a = Math . sin ( Δφ / 2 * M th.s i n(Δ φ  / 2 + Math . cos ( φ1) ath. c os( φ 2)  * M th.s i n(Δ λ  / 2 M t .sin ( Δλ  /  2); final var c = 2 * Math . atan2 ( Math . sqrt ( a ) , Math . sqrt ( 1 - a ) ) ; return R * c ; }
Calculate the distance between two positions.
Calculate the distance between two positions .
// metres / φ, λ in radians // in metres