Sector { public Sector set(double minLatitude, double minLongitude, double deltaLatitude, double deltaLongitude) { this.minLatitude = minLatitude; this.minLongitude = minLongitude; this.maxLatitude = Location.clampLatitude(minLatitude + (deltaLatitude > 0 ? deltaLatitude : Double.NaN)); this.maxLongitude = Location.clampLongitude(minLongitude + (deltaLongitude > 0 ? deltaLongitude : Double.NaN)); return this; } Sector();  Sector(double minLatitude, double minLongitude, double deltaLatitude, double deltaLongitude);  Sector(Sector sector); static Sector fromDegrees(double latitudeDegrees, double longitudeDegrees,
                                     double deltaLatitudeDegrees, double deltaLongitudeDegrees); static Sector fromRadians(double latitudeRadians, double longitudeRadians,
                                     double deltaLatitudeRadians, double deltaLongitudeRadians); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean isEmpty(); boolean isFullSphere(); double minLatitude(); double maxLatitude(); double minLongitude(); double maxLongitude(); double deltaLatitude(); double deltaLongitude(); double centroidLatitude(); double centroidLongitude(); Location centroid(Location result); Sector set(double minLatitude, double minLongitude, double deltaLatitude, double deltaLongitude); Sector set(Sector sector); Sector setEmpty(); Sector setFullSphere(); boolean intersects(double minLatitude, double minLongitude, double deltaLatitude, double deltaLongitude); boolean intersects(Sector sector); boolean intersectsOrNextTo(Sector sector); boolean intersect(double minLatitude, double minLongitude, double deltaLatitude, double deltaLongitude); boolean intersect(Sector sector); boolean contains(double latitude, double longitude); boolean contains(double minLatitude, double minLongitude, double deltaLatitude, double deltaLongitude); boolean contains(Sector sector); Sector union(double latitude, double longitude); Sector union(float[] array, int count, int stride); Sector union(double minLatitude, double minLongitude, double deltaLatitude, double deltaLongitude); Sector union(Sector sector); Sector translate(double deltaLatitude, double deltaLongitude);  }
@Test public void testSet() throws Exception { double lat = 34.2; double lon = -119.2; double dLat = 1.0; double dLon = 2.0; Sector a = new Sector(); Sector b = a.set(new Sector(lat, lon, dLat, dLon)); assertEquals("minLatitude", lat, a.minLatitude(), TOLERANCE); assertEquals("minLongitude", lon, a.minLongitude(), TOLERANCE); assertEquals("deltaLatitude", dLat, a.deltaLatitude(), TOLERANCE); assertEquals("deltaLongitude", dLon, a.deltaLongitude(), TOLERANCE); assertSame(a, b); }
@Test(expected = IllegalArgumentException.class) public void testSet_WithNull() throws Exception { Sector a = new Sector(); a.set(null); fail("Expected IllegalArgumentException"); }