Skip to content

Commit 071d12b

Browse files
committed
Add compactness function
1 parent fe20b8e commit 071d12b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

modules/app/src/main/java/org/locationtech/jtstest/function/MetricFunctions.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,11 @@ public boolean isGeometryChanged() {
8484

8585
return geom.getFactory().createLineString(pts);
8686
}
87+
88+
public static double compactness(Geometry poly) {
89+
double perimeter = poly.getLength();
90+
double area = poly.getArea();
91+
if (perimeter <= 0) return 0;
92+
return Math.abs(area) * Math.PI * 4 / (perimeter * perimeter);
93+
}
8794
}

0 commit comments

Comments
 (0)