@Test public void intersectsTest() { BoundingBox boundingBox1 = new BoundingBox(MIN_LATITUDE, MIN_LONGITUDE, MAX_LATITUDE, MAX_LONGITUDE); BoundingBox boundingBox2 = new BoundingBox(MIN_LATITUDE, MIN_LONGITUDE, MAX_LATITUDE, MAX_LONGITUDE); BoundingBox boundingBox3 = new BoundingBox(0, 0, MIN_LATITUDE, MIN_LONGITUDE); BoundingBox boundingBox4 = new BoundingBox(MIN_LATITUDE - 1, MIN_LONGITUDE - 1, MAX_LATITUDE + 1, MAX_LONGITUDE + 1); BoundingBox boundingBox5 = new BoundingBox(0, 0, 0, 0); BoundingBox boundingBox6 = new BoundingBox(-4, -3, -2, -1); assertIntersection(boundingBox1, boundingBox1); assertIntersection(boundingBox1, boundingBox2); assertIntersection(boundingBox1, boundingBox3); assertIntersection(boundingBox1, boundingBox4); assertNoIntersection(boundingBox1, boundingBox5); assertNoIntersection(boundingBox1, boundingBox6); assertNoIntersection(boundingBox5, boundingBox6); }
public boolean intersects(BoundingBox boundingBox) { if (this == boundingBox) { return true; } return this.maxLatitude >= boundingBox.minLatitude && this.maxLongitude >= boundingBox.minLongitude && this.minLatitude <= boundingBox.maxLatitude && this.minLongitude <= boundingBox.maxLongitude; }
BoundingBox implements Serializable { public boolean intersects(BoundingBox boundingBox) { if (this == boundingBox) { return true; } return this.maxLatitude >= boundingBox.minLatitude && this.maxLongitude >= boundingBox.minLongitude && this.minLatitude <= boundingBox.maxLatitude && this.minLongitude <= boundingBox.maxLongitude; } }
BoundingBox implements Serializable { public boolean intersects(BoundingBox boundingBox) { if (this == boundingBox) { return true; } return this.maxLatitude >= boundingBox.minLatitude && this.maxLongitude >= boundingBox.minLongitude && this.minLatitude <= boundingBox.maxLatitude && this.minLongitude <= boundingBox.maxLongitude; } BoundingBox(double minLatitude, double minLongitude, double maxLatitude, double maxLongitude);  BoundingBox(List<LatLong> latLongs); }
BoundingBox implements Serializable { public boolean intersects(BoundingBox boundingBox) { if (this == boundingBox) { return true; } return this.maxLatitude >= boundingBox.minLatitude && this.maxLongitude >= boundingBox.minLongitude && this.minLatitude <= boundingBox.maxLatitude && this.minLongitude <= boundingBox.maxLongitude; } BoundingBox(double minLatitude, double minLongitude, double maxLatitude, double maxLongitude);  BoundingBox(List<LatLong> latLongs); static BoundingBox fromString(String boundingBoxString); boolean contains(double latitude, double longitude); boolean contains(LatLong latLong); @Override boolean equals(Object obj); BoundingBox extendBoundingBox(BoundingBox boundingBox); BoundingBox extendCoordinates(double latitude, double longitude); BoundingBox extendCoordinates(LatLong latLong); BoundingBox extendDegrees(double verticalExpansion, double horizontalExpansion); BoundingBox extendMargin(float margin); BoundingBox extendMeters(int meters); LatLong getCenterPoint(); double getLatitudeSpan(); double getLongitudeSpan(); Rectangle getPositionRelativeToTile(Tile tile); @Override int hashCode(); boolean intersects(BoundingBox boundingBox); boolean intersectsArea(LatLong[][] latLongs); @Override String toString(); }
BoundingBox implements Serializable { public boolean intersects(BoundingBox boundingBox) { if (this == boundingBox) { return true; } return this.maxLatitude >= boundingBox.minLatitude && this.maxLongitude >= boundingBox.minLongitude && this.minLatitude <= boundingBox.maxLatitude && this.minLongitude <= boundingBox.maxLongitude; } BoundingBox(double minLatitude, double minLongitude, double maxLatitude, double maxLongitude);  BoundingBox(List<LatLong> latLongs); static BoundingBox fromString(String boundingBoxString); boolean contains(double latitude, double longitude); boolean contains(LatLong latLong); @Override boolean equals(Object obj); BoundingBox extendBoundingBox(BoundingBox boundingBox); BoundingBox extendCoordinates(double latitude, double longitude); BoundingBox extendCoordinates(LatLong latLong); BoundingBox extendDegrees(double verticalExpansion, double horizontalExpansion); BoundingBox extendMargin(float margin); BoundingBox extendMeters(int meters); LatLong getCenterPoint(); double getLatitudeSpan(); double getLongitudeSpan(); Rectangle getPositionRelativeToTile(Tile tile); @Override int hashCode(); boolean intersects(BoundingBox boundingBox); boolean intersectsArea(LatLong[][] latLongs); @Override String toString(); final double maxLatitude; final double maxLongitude; final double minLatitude; final double minLongitude; }