Exemplo n.º 1
0
    int compareWith(const GeographyPointValue& rhs) const {

        // Caller guarantees that neither side is null
        assert(! isNull());
        assert(! rhs.isNull());

        Coord lhsLong = getLongitude();
        Coord rhsLong = rhs.getLongitude();
        if (lhsLong < rhsLong) {
            return VALUE_COMPARE_LESSTHAN;
        }

        if (lhsLong > rhsLong) {
            return VALUE_COMPARE_GREATERTHAN;
        }

        // latitude is equal; compare longitude
        Coord lhsLat = getLatitude();
        Coord rhsLat = rhs.getLatitude();
        if (lhsLat < rhsLat) {
            return VALUE_COMPARE_LESSTHAN;
        }

        if (lhsLat > rhsLat) {
            return VALUE_COMPARE_GREATERTHAN;
        }

        return VALUE_COMPARE_EQUAL;
    }
Exemplo n.º 2
0
template<> NValue NValue::callUnary<FUNC_VOLT_POINT_LONGITUDE>() const {
    if (isNull()) {
        return NValue::getNullValue(VALUE_TYPE_DOUBLE);
    }
    const GeographyPointValue point = getGeographyPointValue();
    NValue retVal(VALUE_TYPE_DOUBLE);
    retVal.getDouble() = point.getLongitude();
    return retVal;
}
Exemplo n.º 3
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;
}