GeoPoint extends GeoShapeBase implements Comparable<GeoPoint> { public double longitudinalDistanceTo(GeoPoint pt) { double me = getLongitude(); double them = pt.getLongitude(); double result = Math.abs(me - them) > 180.0 ? (them - me) : (me - them); if (result > 180.0) { result -= 360.0; } if (result < -180.0) { result += 360.0; } return result; } 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 testLongitudinalDistanceTo() { GeoPoint topLeft = new GeoPoint(10.0, 0.0); GeoPoint bottomRight = new GeoPoint(0.0, 10.0); assertEquals(-10.0, topLeft.longitudinalDistanceTo(bottomRight), 0.01); assertEquals(10.0, bottomRight.longitudinalDistanceTo(topLeft), 0.01); topLeft = new GeoPoint(10.0, -170); bottomRight = new GeoPoint(0.0, 170); assertEquals(-20.0, topLeft.longitudinalDistanceTo(bottomRight), 0.01); assertEquals(20.0, bottomRight.longitudinalDistanceTo(topLeft), 0.01); }