Rect { public void expandToInclude(GeoCoordinate gc) { expandToInclude(gc.getLatitudeE6(), gc.getLongitudeE6()); } Rect(GeoCoordinate gc);  Rect(int minLongitudeE6, int maxLongitudeE6, int minLatitudeE6, int maxLatitudeE6);  Rect(double minLongitude, double maxLongitude, double minLatitude, double maxLatitude);  Rect(Rect rect); static boolean overlaps(int minLon1, int maxLon1, int minLat1, int maxLat1, int minLon2, int maxLon2,
			int minLat2, int maxLat2); static Rect fromString(String rectString); int getMinLongitudeE6(); int getMaxLongitudeE6(); int getMinLatitudeE6(); int getMaxLatitudeE6(); GeoCoordinate center(); double distance(Rect otherRect); @Override boolean equals(Object obj); void expandToInclude(GeoCoordinate gc); void expandToInclude(int latE6, int lonE6); void expandToInclude(Rect otherRect); GeoCoordinate getCenter(); @Override int hashCode(); boolean includes(GeoCoordinate c); boolean includes(int latitudeE6, int longitudeE6); boolean overlaps(Rect r); @Override String toString(); public int maxLatitudeE6; public int maxLongitudeE6; public int minLatitudeE6; public int minLongitudeE6; }
@Test public void testExpandToIncludeGeoCoordinate() { Rect r1 = new Rect(0, 1000000, 50000000, 51000000); GeoCoordinate gc1 = new GeoCoordinate(50000000, 0); GeoCoordinate gc2 = new GeoCoordinate(50500000, 500000); GeoCoordinate gc3 = new GeoCoordinate(50500000, -1000000); GeoCoordinate gc4 = new GeoCoordinate(50500000, 2000000); GeoCoordinate gc5 = new GeoCoordinate(52000000, 500000); GeoCoordinate gc6 = new GeoCoordinate(49000000, 500000); r1.expandToInclude(gc1); assertEquals(new Rect(0, 1000000, 50000000, 51000000), r1); r1.expandToInclude(gc2); assertEquals(new Rect(0, 1000000, 50000000, 51000000), r1); r1.expandToInclude(gc3); assertEquals(new Rect(-1000000, 1000000, 50000000, 51000000), r1); r1.expandToInclude(gc4); assertEquals(new Rect(-1000000, 2000000, 50000000, 51000000), r1); r1.expandToInclude(gc5); assertEquals(new Rect(-1000000, 2000000, 50000000, 52000000), r1); r1.expandToInclude(gc6); assertEquals(new Rect(-1000000, 2000000, 49000000, 52000000), r1); }
@Test public void testExpandToIncludeRect() { Rect r1 = new Rect(0, 1000000, 50000000, 51000000); Rect r2 = new Rect(-1000000, 1000000, 55000000, 56000000); Rect r3 = new Rect(250000, 750000, 50250000, 50750000); Rect r4 = new Rect(0, 1000000, 50000000, 51000000); Rect r5 = new Rect(-2000000, -1000000, 45000000, 49000000); r2.expandToInclude(r1); assertEquals(new Rect(-1000000, 1000000, 50000000, 56000000), r2); r3.expandToInclude(r1); assertEquals(r1, r3); r4.expandToInclude(r1); assertEquals(r1, r3); r5.expandToInclude(r1); assertEquals(new Rect(-2000000, 1000000, 45000000, 51000000), r5); }