@Test public void compareToTest() { GeoPoint geoPoint1 = new GeoPoint(LATITUDE, LONGITUDE); GeoPoint geoPoint2 = new GeoPoint(LATITUDE, LONGITUDE); GeoPoint geoPoint3 = new GeoPoint(0, 0); Assert.assertEquals(0, geoPoint1.compareTo(geoPoint2)); Assert.assertNotEquals(0, geoPoint1.compareTo(geoPoint3)); Assert.assertNotEquals(0, geoPoint3.compareTo(geoPoint1)); }
@Override public int compareTo(GeoPoint geoPoint) { if (this.longitude > geoPoint.longitude) { return 1; } else if (this.longitude < geoPoint.longitude) { return -1; } else if (this.latitude > geoPoint.latitude) { return 1; } else if (this.latitude < geoPoint.latitude) { return -1; } return 0; }
GeoPoint implements Comparable<GeoPoint>, Serializable { @Override public int compareTo(GeoPoint geoPoint) { if (this.longitude > geoPoint.longitude) { return 1; } else if (this.longitude < geoPoint.longitude) { return -1; } else if (this.latitude > geoPoint.latitude) { return 1; } else if (this.latitude < geoPoint.latitude) { return -1; } return 0; } }
GeoPoint implements Comparable<GeoPoint>, Serializable { @Override public int compareTo(GeoPoint geoPoint) { if (this.longitude > geoPoint.longitude) { return 1; } else if (this.longitude < geoPoint.longitude) { return -1; } else if (this.latitude > geoPoint.latitude) { return 1; } else if (this.latitude < geoPoint.latitude) { return -1; } return 0; } GeoPoint(double latitude, double longitude); }
GeoPoint implements Comparable<GeoPoint>, Serializable { @Override public int compareTo(GeoPoint geoPoint) { if (this.longitude > geoPoint.longitude) { return 1; } else if (this.longitude < geoPoint.longitude) { return -1; } else if (this.latitude > geoPoint.latitude) { return 1; } else if (this.latitude < geoPoint.latitude) { return -1; } return 0; } GeoPoint(double latitude, double longitude); static GeoPoint fromString(String geoPointString); static double latitudeDistance(int meters); static double longitudeDistance(int meters, double latitude); @Override int compareTo(GeoPoint geoPoint); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
GeoPoint implements Comparable<GeoPoint>, Serializable { @Override public int compareTo(GeoPoint geoPoint) { if (this.longitude > geoPoint.longitude) { return 1; } else if (this.longitude < geoPoint.longitude) { return -1; } else if (this.latitude > geoPoint.latitude) { return 1; } else if (this.latitude < geoPoint.latitude) { return -1; } return 0; } GeoPoint(double latitude, double longitude); static GeoPoint fromString(String geoPointString); static double latitudeDistance(int meters); static double longitudeDistance(int meters, double latitude); @Override int compareTo(GeoPoint geoPoint); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); final double latitude; final double longitude; }