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

ConcaveHull for Points #823

Merged
merged 21 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.locationtech.jts.algorithm.MinimumDiameter;
import org.locationtech.jts.algorithm.construct.LargestEmptyCircle;
import org.locationtech.jts.algorithm.construct.MaximumInscribedCircle;
import org.locationtech.jts.algorithm.hull.ConcaveHull;
import org.locationtech.jts.densify.Densifier;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
Expand Down Expand Up @@ -130,4 +131,58 @@ public static Geometry circleByRadiusLine(Geometry radiusLine,
return radiusLine.getFactory().createPolygon(circlePts);
}

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

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

public static Geometry concaveHullByLenFactor(Geometry geom,
@Metadata(title="Length factor")
double maxLen) {
return ConcaveHull.concaveHullByLengthFactor(geom, maxLen);
}

public static Geometry concaveHullWithHolesByLenFactor(Geometry geom,
@Metadata(title="Length factor")
double maxLen) {
return ConcaveHull.concaveHullByLengthFactor(geom, maxLen, true);
}

public static Geometry concaveHullByArea(Geometry geom,
@Metadata(title="Area ratio")
double minAreaPct) {
return ConcaveHull.concaveHullByArea(geom, minAreaPct);
}

public static double concaveHullLenGuess(Geometry geom) {
return ConcaveHull.uniformGridEdgeLength(geom);
}

/**
* A concaveness measure defined in terms of the perimeter length
* relative to the convex hull perimeter.
* <pre>
* C = ( P(geom) - P(CH) ) / P(CH)
* </pre>
* Concaveness values are >= 0.
* A convex polygon has C = 0.
* A higher concaveness indicates a more concave polygon.
* <p>
* Originally defined by Park & Oh, 2012.
*
* @param geom a polygonal geometry
* @return the concaveness measure of the geometry
*/
public static double concaveness(Geometry geom) {
double convexLen = geom.convexHull().getLength();
return (geom.getLength() - convexLen) / convexLen;
}

}
Loading