@Test public void calculateBoundingBox() { BBox bbox3D = GeomUtility.calculateBoundingBox(pointList3D); BBox bbox2D = GeomUtility.calculateBoundingBox(pointList2D); BBox bbox_fallback = GeomUtility.calculateBoundingBox(emptyPointList); Assert.assertEquals(-35.507813,bbox3D.minLon, 0.000009); Assert.assertEquals(38.408203,bbox3D.maxLon, 0.0000009); Assert.assertEquals(-12.897489,bbox3D.minLat, 0.000009); Assert.assertEquals(50.958427,bbox3D.maxLat, 0.0000009); Assert.assertEquals(113.0,bbox3D.minEle, 0.09); Assert.assertEquals(409.0,bbox3D.maxEle, 0.09); Assert.assertEquals(-35.507813,bbox2D.minLon, 0.000009); Assert.assertEquals(38.408203,bbox2D.maxLon, 0.000009); Assert.assertEquals(-12.897489,bbox2D.minLat, 0.000009); Assert.assertEquals(50.958427,bbox2D.maxLat, 0.000009); Assert.assertEquals(0f,bbox_fallback.minLon, 0.000009); Assert.assertEquals(0f,bbox_fallback.maxLon, 0.000009); Assert.assertEquals(0f,bbox_fallback.minLat, 0.000009); Assert.assertEquals(0f,bbox_fallback.maxLat, 0.000009); }
public static BBox calculateBoundingBox(PointList pointList) { if (pointList == null || pointList.getSize() <= 0) { return new BBox(0, 0, 0, 0); } else { double minLon = Double.MAX_VALUE; double maxLon = -Double.MAX_VALUE; double minLat = Double.MAX_VALUE; double maxLat = -Double.MAX_VALUE; double minEle = Double.MAX_VALUE; double maxEle = -Double.MAX_VALUE; for (int i = 0; i < pointList.getSize(); ++i) { minLon = Math.min(minLon, pointList.getLon(i)); maxLon = Math.max(maxLon, pointList.getLon(i)); minLat = Math.min(minLat, pointList.getLat(i)); maxLat = Math.max(maxLat, pointList.getLat(i)); if (pointList.is3D()) { minEle = Math.min(minEle, pointList.getEle(i)); maxEle = Math.max(maxEle, pointList.getEle(i)); } } if (pointList.is3D()) { return new BBox(minLon, maxLon, minLat, maxLat, minEle, maxEle); } else { return new BBox(minLon, maxLon, minLat, maxLat); } } }
GeomUtility { public static BBox calculateBoundingBox(PointList pointList) { if (pointList == null || pointList.getSize() <= 0) { return new BBox(0, 0, 0, 0); } else { double minLon = Double.MAX_VALUE; double maxLon = -Double.MAX_VALUE; double minLat = Double.MAX_VALUE; double maxLat = -Double.MAX_VALUE; double minEle = Double.MAX_VALUE; double maxEle = -Double.MAX_VALUE; for (int i = 0; i < pointList.getSize(); ++i) { minLon = Math.min(minLon, pointList.getLon(i)); maxLon = Math.max(maxLon, pointList.getLon(i)); minLat = Math.min(minLat, pointList.getLat(i)); maxLat = Math.max(maxLat, pointList.getLat(i)); if (pointList.is3D()) { minEle = Math.min(minEle, pointList.getEle(i)); maxEle = Math.max(maxEle, pointList.getEle(i)); } } if (pointList.is3D()) { return new BBox(minLon, maxLon, minLat, maxLat, minEle, maxEle); } else { return new BBox(minLon, maxLon, minLat, maxLat); } } } }
GeomUtility { public static BBox calculateBoundingBox(PointList pointList) { if (pointList == null || pointList.getSize() <= 0) { return new BBox(0, 0, 0, 0); } else { double minLon = Double.MAX_VALUE; double maxLon = -Double.MAX_VALUE; double minLat = Double.MAX_VALUE; double maxLat = -Double.MAX_VALUE; double minEle = Double.MAX_VALUE; double maxEle = -Double.MAX_VALUE; for (int i = 0; i < pointList.getSize(); ++i) { minLon = Math.min(minLon, pointList.getLon(i)); maxLon = Math.max(maxLon, pointList.getLon(i)); minLat = Math.min(minLat, pointList.getLat(i)); maxLat = Math.max(maxLat, pointList.getLat(i)); if (pointList.is3D()) { minEle = Math.min(minEle, pointList.getEle(i)); maxEle = Math.max(maxEle, pointList.getEle(i)); } } if (pointList.is3D()) { return new BBox(minLon, maxLon, minLat, maxLat, minEle, maxEle); } else { return new BBox(minLon, maxLon, minLat, maxLat); } } } private  GeomUtility(); }
GeomUtility { public static BBox calculateBoundingBox(PointList pointList) { if (pointList == null || pointList.getSize() <= 0) { return new BBox(0, 0, 0, 0); } else { double minLon = Double.MAX_VALUE; double maxLon = -Double.MAX_VALUE; double minLat = Double.MAX_VALUE; double maxLat = -Double.MAX_VALUE; double minEle = Double.MAX_VALUE; double maxEle = -Double.MAX_VALUE; for (int i = 0; i < pointList.getSize(); ++i) { minLon = Math.min(minLon, pointList.getLon(i)); maxLon = Math.max(maxLon, pointList.getLon(i)); minLat = Math.min(minLat, pointList.getLat(i)); maxLat = Math.max(maxLat, pointList.getLat(i)); if (pointList.is3D()) { minEle = Math.min(minEle, pointList.getEle(i)); maxEle = Math.max(maxEle, pointList.getEle(i)); } } if (pointList.is3D()) { return new BBox(minLon, maxLon, minLat, maxLat, minEle, maxEle); } else { return new BBox(minLon, maxLon, minLat, maxLat); } } } private  GeomUtility(); static LineString createLinestring(Coordinate[] coords); static BBox calculateBoundingBox(PointList pointList); static BBox generateBoundingFromMultiple(BBox[] boundingBoxes); static double getLength(Geometry geom, boolean inMeters); static double metresToDegrees(double metres); static double getArea(Geometry geom, boolean inMeters); static double calculateMaxExtent(Geometry geom); }
GeomUtility { public static BBox calculateBoundingBox(PointList pointList) { if (pointList == null || pointList.getSize() <= 0) { return new BBox(0, 0, 0, 0); } else { double minLon = Double.MAX_VALUE; double maxLon = -Double.MAX_VALUE; double minLat = Double.MAX_VALUE; double maxLat = -Double.MAX_VALUE; double minEle = Double.MAX_VALUE; double maxEle = -Double.MAX_VALUE; for (int i = 0; i < pointList.getSize(); ++i) { minLon = Math.min(minLon, pointList.getLon(i)); maxLon = Math.max(maxLon, pointList.getLon(i)); minLat = Math.min(minLat, pointList.getLat(i)); maxLat = Math.max(maxLat, pointList.getLat(i)); if (pointList.is3D()) { minEle = Math.min(minEle, pointList.getEle(i)); maxEle = Math.max(maxEle, pointList.getEle(i)); } } if (pointList.is3D()) { return new BBox(minLon, maxLon, minLat, maxLat, minEle, maxEle); } else { return new BBox(minLon, maxLon, minLat, maxLat); } } } private  GeomUtility(); static LineString createLinestring(Coordinate[] coords); static BBox calculateBoundingBox(PointList pointList); static BBox generateBoundingFromMultiple(BBox[] boundingBoxes); static double getLength(Geometry geom, boolean inMeters); static double metresToDegrees(double metres); static double getArea(Geometry geom, boolean inMeters); static double calculateMaxExtent(Geometry geom);  }