Sector { public Sector union(double latitude, double longitude) { if (this.minLatitude < this.maxLatitude && this.minLongitude < this.maxLongitude) { this.maxLatitude = Math.max(this.maxLatitude, latitude); this.minLatitude = Math.min(this.minLatitude, latitude); this.maxLongitude = Math.max(this.maxLongitude, longitude); this.minLongitude = Math.min(this.minLongitude, longitude); } else if (!Double.isNaN(this.minLatitude) && !Double.isNaN(this.minLongitude)) { this.maxLatitude = Math.max(this.minLatitude, latitude); this.maxLongitude = Math.max(this.minLongitude, longitude); this.minLatitude = Math.min(this.minLatitude, latitude); this.minLongitude = Math.min(this.minLongitude, longitude); } else { this.minLatitude = latitude; this.minLongitude = longitude; this.maxLatitude = Double.NaN; this.maxLongitude = 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 testUnion() throws Exception { double latOxr = 34.2; double lonOxr = -119.2; double latLax = 33.94; double lonLax = -118.4; Sector a = new Sector(); Sector b = a.union(latOxr, lonOxr); assertTrue(a.isEmpty()); a.union(latLax, lonLax); assertFalse(a.isEmpty()); assertEquals("min lat", latLax, a.minLatitude(), 0); assertEquals("min lon", lonOxr, a.minLongitude(), 0); assertEquals("max lat", latOxr, a.maxLatitude(), 0); assertEquals("max lon", lonLax, a.maxLongitude(), 0); assertSame(a, b); }