Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ConcaveHullOfPolygons class #870

Merged
merged 14 commits into from
May 16, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,36 @@
package org.locationtech.jtstest.function;

import org.locationtech.jts.algorithm.hull.ConcaveHull;
import org.locationtech.jts.algorithm.hull.ConcaveHullOfPolygons;
import org.locationtech.jts.algorithm.hull.PolygonHull;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jtstest.geomfunction.Metadata;

public class HullFunctions {
public static Geometry convexHull(Geometry g) { return g.convexHull(); }

public static Geometry concaveHullByLen(Geometry geom,
@Metadata(title="Length")
public static Geometry concaveHullPoints(Geometry geom,
@Metadata(title="Max Edge Length")
double maxLen) {
return ConcaveHull.concaveHullByLength(geom, maxLen);
}

public static Geometry concaveHullWithHolesByLen(Geometry geom,
@Metadata(title="Length")
public static Geometry concaveHullPointsWithHoles(Geometry geom,
@Metadata(title="Max Edge Length")
double maxLen) {
return ConcaveHull.concaveHullByLength(geom, maxLen, true);
}

public static Geometry concaveHullByLenRatio(Geometry geom,
public static Geometry concaveHullPointsByLenRatio(Geometry geom,
@Metadata(title="Length Ratio")
double maxLen) {
return ConcaveHull.concaveHullByLengthRatio(geom, maxLen);
double maxLenRatio) {
return ConcaveHull.concaveHullByLengthRatio(geom, maxLenRatio);
}

public static Geometry concaveHullWithHolesByLenRatio(Geometry geom,
public static Geometry concaveHullPointsWithHolesByLenRatio(Geometry geom,
@Metadata(title="Length Ratio")
double maxLen) {
return ConcaveHull.concaveHullByLengthRatio(geom, maxLen, true);
double maxLenRatio) {
return ConcaveHull.concaveHullByLengthRatio(geom, maxLenRatio, true);
}

public static double concaveHullLenGuess(Geometry geom) {
Expand Down Expand Up @@ -79,5 +80,46 @@ public static Geometry polygonHullByAreaDelta(Geometry geom,
return PolygonHull.hullByAreaDelta(geom, areaFrac);
}


public static Geometry concaveHullPolygons(Geometry geom,
@Metadata(title="Max Edge Length")
double maxEdgeLen) {
return ConcaveHullOfPolygons.concaveHullByLength(geom, maxEdgeLen);
}

public static Geometry concaveHullPolygonsWithHoles(Geometry geom,
@Metadata(title="Max Edge Length")
double maxEdgeLen) {
return ConcaveHullOfPolygons.concaveHullByLength(geom, maxEdgeLen, false, true);
}

public static Geometry concaveHullPolygonsTight(Geometry geom,
@Metadata(title="Max Edge Length")
double maxEdgeLen) {
return ConcaveHullOfPolygons.concaveHullByLength(geom, maxEdgeLen, true, false);
}

public static Geometry concaveHullPolygonsByLenRatio(Geometry geom,
@Metadata(title="Edge Length Ratio")
double maxEdgeLenRatio) {
return ConcaveHullOfPolygons.concaveHullByLengthRatio(geom, maxEdgeLenRatio);
}

public static Geometry concaveHullPolygonsTightByLenRatio(Geometry geom,
@Metadata(title="Edge Length Ratio")
double maxEdgeLenRatio) {
return ConcaveHullOfPolygons.concaveHullByLengthRatio(geom, maxEdgeLenRatio, true, false);
}

public static Geometry concaveFill(Geometry geom,
@Metadata(title="Max Edge Length")
double maxEdgeLen) {
return ConcaveHullOfPolygons.concaveFillByLength(geom, maxEdgeLen);
}

public static Geometry concaveFillByLenRatio(Geometry geom,
@Metadata(title="Edge Length Ratio")
double maxEdgeLenRatio) {
return ConcaveHullOfPolygons.concaveFillByLengthRatio(geom, maxEdgeLenRatio);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@

/**
* Constructs a concave hull of a set of points.
* The hull is constructed by removing the longest outer edges
* of the Delaunay Triangulation of the points
* until a target criterion is reached.
* A concave hull is a possibly non-convex polygon containing all the input points.
* A given set of points has a sequence of hulls of increasing concaveness,
* determined by a numeric target parameter.
* <p>
* The concave hull is constructed by removing the longest outer edges
* of the Delaunay Triangulation of the points,
* until the target criterion parameter is reached.
* <p>
* The target criteria are:
* <ul>
Expand Down Expand Up @@ -77,7 +81,7 @@ public static double uniformGridEdgeLength(Geometry geom) {
}

/**
* Computes the concave hull of the vertices in a geometry
* Computes a concave hull of the vertices in a geometry
* using the target criterion of maximum edge length.
*
* @param geom the input geometry
Expand All @@ -89,7 +93,7 @@ public static Geometry concaveHullByLength(Geometry geom, double maxLength) {
}

/**
* Computes the concave hull of the vertices in a geometry
* Computes a concave hull of the vertices in a geometry
* using the target criterion of maximum edge length,
* and optionally allowing holes.
*
Expand All @@ -106,7 +110,7 @@ public static Geometry concaveHullByLength(Geometry geom, double maxLength, bool
}

/**
* Computes the concave hull of the vertices in a geometry
* Computes a concave hull of the vertices in a geometry
* using the target criterion of maximum edge length ratio.
* The edge length ratio is a fraction of the length difference
* between the longest and shortest edges
Expand All @@ -121,7 +125,7 @@ public static Geometry concaveHullByLengthRatio(Geometry geom, double lengthRati
}

/**
* Computes the concave hull of the vertices in a geometry
* Computes a concave hull of the vertices in a geometry
* using the target criterion of maximum edge length factor,
* and optionally allowing holes.
* The edge length factor is a fraction of the length difference
Expand Down
Loading