Ejemplo n.º 1
0
// function computes distance between two non-null points
// function computes distance using Haversine formula
static double getDistance(const GeographyPointValue &point1,
                          const GeographyPointValue &point2)
{
    assert(!point1.isNull());
    assert(!point2.isNull());

    const S2LatLng latLng1 = S2LatLng(point1.toS2Point()).Normalized();
    const S2LatLng latLng2 = S2LatLng(point2.toS2Point()).Normalized();
    S1Angle distance = latLng1.GetDistance(latLng2);
    return distance.radians() * SPHERICAL_EARTH_MEAN_RADIUS_M;
}