/** * Get distance between this point and another {@code ParseGeoPoint} in kilometers. * * @param point {@code ParseGeoPoint} describing the other point being measured against. */ public double distanceInKilometersTo(ParseGeoPoint point) { return distanceInRadiansTo(point) * EARTH_MEAN_RADIUS_KM; }
/** * Get distance between this point and another {@code ParseGeoPoint} in kilometers. * * @param point {@code ParseGeoPoint} describing the other point being measured against. */ public double distanceInMilesTo(ParseGeoPoint point) { return distanceInRadiansTo(point) * EARTH_MEAN_RADIUS_MILE; }
/** * Matches $nearSphere constraints. */ private static boolean matchesNearSphereConstraint(Object constraint, Object value, Double maxDistance) { if (value == null || value == JSONObject.NULL) { return false; } if (maxDistance == null) { return true; } ParseGeoPoint point1 = (ParseGeoPoint) constraint; ParseGeoPoint point2 = (ParseGeoPoint) value; return point1.distanceInRadiansTo(point2) <= maxDistance; }
double lhsDistance = lhsPoint.distanceInRadiansTo(nearSphereValue); double rhsDistance = rhsPoint.distanceInRadiansTo(nearSphereValue); if (lhsDistance != rhsDistance) { return (lhsDistance - rhsDistance > 0) ? 1 : -1;