return (new ConvexHull(this)).getConvexHull();
public static JavaPairRDD<Integer, Geometry> generateHullsRDD( final JavaPairRDD<Integer, Iterable<Vector>> groupedPoints) { // Create the convex hull for each kmeans centroid final JavaPairRDD<Integer, Geometry> hullRDD = groupedPoints.mapValues(point -> { final Iterable<Coordinate> coordIt = Iterables.transform(point, new com.google.common.base.Function<Vector, Coordinate>() { @Override public Coordinate apply(final Vector input) { if (input != null) { return new Coordinate(input.apply(0), input.apply(1)); } return new Coordinate(); } }); final Coordinate[] coordArray = Iterables.toArray(coordIt, Coordinate.class); return new ConvexHull(coordArray, GeometryUtils.GEOMETRY_FACTORY).getConvexHull(); }); return hullRDD; } }
private static <T> Geometry compress( final GeoWaveInputKey key, final List<Coordinate> batchCoords) { final Coordinate[] actualCoords = batchCoords.toArray(new Coordinate[batchCoords.size()]); // generate convex hull for current batch of points final ConvexHull convexHull = new ConvexHull(actualCoords, new GeometryFactory()); final Geometry hullGeometry = convexHull.getConvexHull(); final Coordinate[] hullCoords = hullGeometry.getCoordinates(); batchCoords.clear(); for (final Coordinate hullCoord : hullCoords) { batchCoords.add(hullCoord); } return hullGeometry; }
private void computeConvexHull() { GeometryFactory fact = new GeometryFactory(); Coordinate[] coords = getPointArray(); ConvexHull hull = new ConvexHull(coords, fact); convexHull = hull.getConvexHull(); }
private void computeMinimumDiameter() { // check if computation is cached if (minWidthPt != null) return; if (isConvex) computeWidthConvex(inputGeom); else { Geometry convexGeom = (new ConvexHull(inputGeom)).getConvexHull(); computeWidthConvex(convexGeom); } }
@Override public <P extends C2D> Geometry<P> convexHull(final Geometry<P> geometry) { final ConvexHull convexHull = new ConvexHull(JTS.to(geometry)); return JTS.from(convexHull.getConvexHull(), geometry.getCoordinateReferenceSystem()); }
public void testAllIdenticalPoints() throws Exception { Coordinate[] pts = new Coordinate[100]; for (int i = 0; i < 100; i++) pts[i] = new Coordinate(0,0); ConvexHull ch = new ConvexHull(pts, geometryFactory); Geometry actualGeometry = ch.getConvexHull(); Geometry expectedGeometry = reader.read("POINT (0 0)"); assertTrue(expectedGeometry.equalsExact(actualGeometry)); }
public void testManyIdenticalPoints() throws Exception { Coordinate[] pts = new Coordinate[100]; for (int i = 0; i < 99; i++) pts[i] = new Coordinate(0,0); pts[99] = new Coordinate(1,1); ConvexHull ch = new ConvexHull(pts, geometryFactory); Geometry actualGeometry = ch.getConvexHull(); Geometry expectedGeometry = reader.read("LINESTRING (0 0, 1 1)"); assertTrue(expectedGeometry.equalsExact(actualGeometry)); }