@Test public void testBounds1() { List<Geometry> geometries = new ArrayList<Geometry>(); Geometry upperLeft = new Geometry(Geometry.LINE_STRING, 2, 0); upperLeft.setCoordinates(new Coordinate[] { new Coordinate(0, 200), new Coordinate(50, 300) }); geometries.add(upperLeft); Geometry upperRight = new Geometry(Geometry.POINT, 3, 0); upperRight.setCoordinates(new Coordinate[] { new Coordinate(500, 500) }); geometries.add(upperRight); Geometry lowerRight = new Geometry(Geometry.POINT, 3, 0); lowerRight.setCoordinates(new Coordinate[] { new Coordinate(500, -150) }); geometries.add(lowerRight); Geometry lowerLeft = new Geometry(Geometry.POLYGON, 1, 0); Geometry linearRing = new Geometry(Geometry.LINEAR_RING, 1, 0); linearRing.setCoordinates(new Coordinate[] { new Coordinate(-30, 0), new Coordinate(0, 10), new Coordinate(5, 10), new Coordinate(-30, 0) }); lowerLeft.setGeometries(new Geometry[] { linearRing }); geometries.add(lowerLeft); service.bounds(geometries, new Callback<Bbox, Throwable>() { public void onSuccess(Bbox result) { Assert.assertEquals(-30d, result.getX()); Assert.assertEquals(-150d, result.getY()); Assert.assertEquals(500d, result.getMaxX()); Assert.assertEquals(500d, result.getMaxY()); } public void onFailure(Throwable reason) { } }); }
@Override public void bounds(List<Geometry> geometries, Callback<Bbox, Throwable> callback) { try { Bbox result = GeometryService.getBounds(geometries.get(0)); double minX = result.getX(); double minY = result.getY(); double maxX = result.getMaxX(); double maxY = result.getMaxY(); for (int i = 1; i < geometries.size(); i++) { Bbox bounds = GeometryService.getBounds(geometries.get(i)); double boundsX = bounds.getX(); minX = boundsX < minX ? boundsX : minX; double boundsY = bounds.getY(); minY = boundsY < minY ? boundsY : minY; double boundsMaxX = bounds.getMaxX(); maxX = boundsMaxX > maxX ? boundsMaxX : maxX; double boundsMaxY = bounds.getMaxY(); maxY = boundsMaxY > maxY ? boundsMaxY : maxY; } result.setX(minX); result.setY(minY); result.setMaxX(maxX); result.setMaxY(maxY); callback.onSuccess(result); } catch (Exception e) { callback.onFailure(e); } }
GeometryOperationServiceImpl implements GeometryOperationService { @Override public void bounds(List<Geometry> geometries, Callback<Bbox, Throwable> callback) { try { Bbox result = GeometryService.getBounds(geometries.get(0)); double minX = result.getX(); double minY = result.getY(); double maxX = result.getMaxX(); double maxY = result.getMaxY(); for (int i = 1; i < geometries.size(); i++) { Bbox bounds = GeometryService.getBounds(geometries.get(i)); double boundsX = bounds.getX(); minX = boundsX < minX ? boundsX : minX; double boundsY = bounds.getY(); minY = boundsY < minY ? boundsY : minY; double boundsMaxX = bounds.getMaxX(); maxX = boundsMaxX > maxX ? boundsMaxX : maxX; double boundsMaxY = bounds.getMaxY(); maxY = boundsMaxY > maxY ? boundsMaxY : maxY; } result.setX(minX); result.setY(minY); result.setMaxX(maxX); result.setMaxY(maxY); callback.onSuccess(result); } catch (Exception e) { callback.onFailure(e); } } }
GeometryOperationServiceImpl implements GeometryOperationService { @Override public void bounds(List<Geometry> geometries, Callback<Bbox, Throwable> callback) { try { Bbox result = GeometryService.getBounds(geometries.get(0)); double minX = result.getX(); double minY = result.getY(); double maxX = result.getMaxX(); double maxY = result.getMaxY(); for (int i = 1; i < geometries.size(); i++) { Bbox bounds = GeometryService.getBounds(geometries.get(i)); double boundsX = bounds.getX(); minX = boundsX < minX ? boundsX : minX; double boundsY = bounds.getY(); minY = boundsY < minY ? boundsY : minY; double boundsMaxX = bounds.getMaxX(); maxX = boundsMaxX > maxX ? boundsMaxX : maxX; double boundsMaxY = bounds.getMaxY(); maxY = boundsMaxY > maxY ? boundsMaxY : maxY; } result.setX(minX); result.setY(minY); result.setMaxX(maxX); result.setMaxY(maxY); callback.onSuccess(result); } catch (Exception e) { callback.onFailure(e); } }  }
GeometryOperationServiceImpl implements GeometryOperationService { @Override public void bounds(List<Geometry> geometries, Callback<Bbox, Throwable> callback) { try { Bbox result = GeometryService.getBounds(geometries.get(0)); double minX = result.getX(); double minY = result.getY(); double maxX = result.getMaxX(); double maxY = result.getMaxY(); for (int i = 1; i < geometries.size(); i++) { Bbox bounds = GeometryService.getBounds(geometries.get(i)); double boundsX = bounds.getX(); minX = boundsX < minX ? boundsX : minX; double boundsY = bounds.getY(); minY = boundsY < minY ? boundsY : minY; double boundsMaxX = bounds.getMaxX(); maxX = boundsMaxX > maxX ? boundsMaxX : maxX; double boundsMaxY = bounds.getMaxY(); maxY = boundsMaxY > maxY ? boundsMaxY : maxY; } result.setX(minX); result.setY(minY); result.setMaxX(maxX); result.setMaxY(maxY); callback.onSuccess(result); } catch (Exception e) { callback.onFailure(e); } }  @Override void buffer(Geometry geometry, BufferInfo bufferInfo, final Callback<Geometry, Throwable> callback); @Override void buffer(List<Geometry> geometries, BufferInfo bufferInfo,
			final Callback<List<Geometry>, Throwable> callback); @Override void union(List<Geometry> geometries, UnionInfo unionInfo, final Callback<Geometry, Throwable> callback); @Override void convexHull(Geometry geometry, final Callback<Geometry, Throwable> callback); @Override void convexHull(List<Geometry> geometries, final Callback<List<Geometry>, Throwable> callback); @Override void bounds(List<Geometry> geometries, Callback<Bbox, Throwable> callback); }
GeometryOperationServiceImpl implements GeometryOperationService { @Override public void bounds(List<Geometry> geometries, Callback<Bbox, Throwable> callback) { try { Bbox result = GeometryService.getBounds(geometries.get(0)); double minX = result.getX(); double minY = result.getY(); double maxX = result.getMaxX(); double maxY = result.getMaxY(); for (int i = 1; i < geometries.size(); i++) { Bbox bounds = GeometryService.getBounds(geometries.get(i)); double boundsX = bounds.getX(); minX = boundsX < minX ? boundsX : minX; double boundsY = bounds.getY(); minY = boundsY < minY ? boundsY : minY; double boundsMaxX = bounds.getMaxX(); maxX = boundsMaxX > maxX ? boundsMaxX : maxX; double boundsMaxY = bounds.getMaxY(); maxY = boundsMaxY > maxY ? boundsMaxY : maxY; } result.setX(minX); result.setY(minY); result.setMaxX(maxX); result.setMaxY(maxY); callback.onSuccess(result); } catch (Exception e) { callback.onFailure(e); } }  @Override void buffer(Geometry geometry, BufferInfo bufferInfo, final Callback<Geometry, Throwable> callback); @Override void buffer(List<Geometry> geometries, BufferInfo bufferInfo,
			final Callback<List<Geometry>, Throwable> callback); @Override void union(List<Geometry> geometries, UnionInfo unionInfo, final Callback<Geometry, Throwable> callback); @Override void convexHull(Geometry geometry, final Callback<Geometry, Throwable> callback); @Override void convexHull(List<Geometry> geometries, final Callback<List<Geometry>, Throwable> callback); @Override void bounds(List<Geometry> geometries, Callback<Bbox, Throwable> callback);  }