@Test public void extendDegreesTest() { BoundingBox boundingBox1 = new BoundingBox(MIN_LATITUDE, MIN_LONGITUDE, MAX_LATITUDE, MAX_LONGITUDE); BoundingBox boundingBox2 = new BoundingBox(MIN_LATITUDE - 1, MIN_LONGITUDE - 1, MAX_LATITUDE, MAX_LONGITUDE); BoundingBox boundingBox3 = new BoundingBox(MIN_LATITUDE, MIN_LONGITUDE, MAX_LATITUDE + 1, MAX_LONGITUDE + 1); Assert.assertEquals(boundingBox1, boundingBox1.extendDegrees(0, 0)); Assert.assertEquals(boundingBox2, boundingBox2.extendDegrees(0, 0)); Assert.assertEquals(boundingBox3, boundingBox3.extendDegrees(0, 0)); Assert.assertTrue(boundingBox1.extendDegrees(1, 1).contains(new LatLong(MIN_LATITUDE - 1, MAX_LONGITUDE + 1))); Assert.assertTrue(boundingBox1.extendDegrees(1, 1).contains(new LatLong(MAX_LATITUDE + 1, MAX_LONGITUDE + 1))); Assert.assertTrue(boundingBox1.extendDegrees(1, 1).contains(new LatLong(MAX_LATITUDE + 1, MIN_LONGITUDE - 1))); Assert.assertTrue(boundingBox1.extendDegrees(1, 1).contains(new LatLong(MIN_LATITUDE - 1, MIN_LONGITUDE - 1))); }
public BoundingBox extendDegrees(double verticalExpansion, double horizontalExpansion) { if (verticalExpansion == 0 && horizontalExpansion == 0) { return this; } else if (verticalExpansion < 0 || horizontalExpansion < 0) { throw new IllegalArgumentException("BoundingBox extend operation does not accept negative values"); } double minLat = Math.max(MercatorProjection.LATITUDE_MIN, this.minLatitude - verticalExpansion); double minLon = Math.max(-180, this.minLongitude - horizontalExpansion); double maxLat = Math.min(MercatorProjection.LATITUDE_MAX, this.maxLatitude + verticalExpansion); double maxLon = Math.min(180, this.maxLongitude + horizontalExpansion); return new BoundingBox(minLat, minLon, maxLat, maxLon); }
BoundingBox implements Serializable { public BoundingBox extendDegrees(double verticalExpansion, double horizontalExpansion) { if (verticalExpansion == 0 && horizontalExpansion == 0) { return this; } else if (verticalExpansion < 0 || horizontalExpansion < 0) { throw new IllegalArgumentException("BoundingBox extend operation does not accept negative values"); } double minLat = Math.max(MercatorProjection.LATITUDE_MIN, this.minLatitude - verticalExpansion); double minLon = Math.max(-180, this.minLongitude - horizontalExpansion); double maxLat = Math.min(MercatorProjection.LATITUDE_MAX, this.maxLatitude + verticalExpansion); double maxLon = Math.min(180, this.maxLongitude + horizontalExpansion); return new BoundingBox(minLat, minLon, maxLat, maxLon); } }
BoundingBox implements Serializable { public BoundingBox extendDegrees(double verticalExpansion, double horizontalExpansion) { if (verticalExpansion == 0 && horizontalExpansion == 0) { return this; } else if (verticalExpansion < 0 || horizontalExpansion < 0) { throw new IllegalArgumentException("BoundingBox extend operation does not accept negative values"); } double minLat = Math.max(MercatorProjection.LATITUDE_MIN, this.minLatitude - verticalExpansion); double minLon = Math.max(-180, this.minLongitude - horizontalExpansion); double maxLat = Math.min(MercatorProjection.LATITUDE_MAX, this.maxLatitude + verticalExpansion); double maxLon = Math.min(180, this.maxLongitude + horizontalExpansion); return new BoundingBox(minLat, minLon, maxLat, maxLon); } BoundingBox(double minLatitude, double minLongitude, double maxLatitude, double maxLongitude);  BoundingBox(List<LatLong> latLongs); }
BoundingBox implements Serializable { public BoundingBox extendDegrees(double verticalExpansion, double horizontalExpansion) { if (verticalExpansion == 0 && horizontalExpansion == 0) { return this; } else if (verticalExpansion < 0 || horizontalExpansion < 0) { throw new IllegalArgumentException("BoundingBox extend operation does not accept negative values"); } double minLat = Math.max(MercatorProjection.LATITUDE_MIN, this.minLatitude - verticalExpansion); double minLon = Math.max(-180, this.minLongitude - horizontalExpansion); double maxLat = Math.min(MercatorProjection.LATITUDE_MAX, this.maxLatitude + verticalExpansion); double maxLon = Math.min(180, this.maxLongitude + horizontalExpansion); return new BoundingBox(minLat, minLon, maxLat, maxLon); } 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 BoundingBox extendDegrees(double verticalExpansion, double horizontalExpansion) { if (verticalExpansion == 0 && horizontalExpansion == 0) { return this; } else if (verticalExpansion < 0 || horizontalExpansion < 0) { throw new IllegalArgumentException("BoundingBox extend operation does not accept negative values"); } double minLat = Math.max(MercatorProjection.LATITUDE_MIN, this.minLatitude - verticalExpansion); double minLon = Math.max(-180, this.minLongitude - horizontalExpansion); double maxLat = Math.min(MercatorProjection.LATITUDE_MAX, this.maxLatitude + verticalExpansion); double maxLon = Math.min(180, this.maxLongitude + horizontalExpansion); return new BoundingBox(minLat, minLon, maxLat, maxLon); } 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; }