GeoPoint extends GeoShapeBase implements Comparable<GeoPoint> { public double distanceFrom(GeoPoint geoPoint) { return GeoUtils.distanceBetween( this.getLatitude(), this.getLongitude(), geoPoint.getLatitude(), geoPoint.getLongitude() ); } protected  GeoPoint();  GeoPoint(double latitude, double longitude, Double altitude, Double accuracy, String description);  GeoPoint(double latitude, double longitude, Double altitude, String description);  GeoPoint(double latitude, double longitude, Double altitude);  GeoPoint(double latitude, double longitude);  GeoPoint(double latitude, double longitude, String description);  GeoPoint(double latitude, double longitude, Double altitude, Double accuracy); double getLatitude(); double getLongitude(); Double getAltitude(); Double getAccuracy(); @Override String toString(); @Override boolean intersects(GeoShape geoShape); @Override int hashCode(); @Override boolean equals(Object obj); static double distanceBetween(GeoPoint geoPoint1, GeoPoint geoPoint2); double distanceFrom(GeoPoint geoPoint); @Override int compareTo(GeoPoint other); static GeoPoint parse(String str); boolean isSouthEastOf(GeoPoint pt); boolean isSouthOf(GeoPoint pt); boolean isNorthWestOf(GeoPoint pt); double longitudinalDistanceTo(GeoPoint pt); boolean isNorthOf(GeoPoint pt); static GeoPoint calculateCenter(List<GeoPoint> geoPoints); static final double EQUALS_TOLERANCE_KM; }
@Test public void testDistanceFrom() { GeoPoint p1 = new GeoPoint(38.6270, -90.1994); GeoPoint p2 = new GeoPoint(39.0438, -77.4874); assertEquals(1101.13d, p1.distanceFrom(p2), 0.01d); }
@Test public void testDistanceFromOppositeSidesOfEarth() { GeoPoint p1 = new GeoPoint(0.0, 0.0); GeoPoint p2 = new GeoPoint(0.0, 180.0); assertEquals(GeoUtils.EARTH_CIRCUMFERENCE / 2.0, p1.distanceFrom(p2), 0.01d); }