class Helper extends ErrorAware {

    public static double distanceInMetersBetween(double longitude1, double latitude1, double longitude2, double latitude2) {
        // convert from degree to radial
        double phi1 = deg2rad(latitude1);
        double phi2 = deg2rad(latitude2);
        double lambda1 = deg2rad(longitude1);
        double lambda2 = deg2rad(longitude2);
        // compute the deltas
        double dPhi = phi1 - phi2; // Δφ
        double dLambda = lambda1 - lambda2; // Δλ
        // compute haversine formula
        double dRoh = 2 * Math.asin(Math.sqrt(
                Math.pow(Math.sin(dPhi / 2), 2) +
                        Math.cos(phi1) * Math.cos(phi2) *
                                Math.pow(Math.sin(dLambda / 2), 2)
        ));
        double distance = EARTH_RADIUS_METERS * dRoh;
        return distance;
    }

}