From e4b89b013ba5a6aaee77ecce7f9bfa99ff75846f Mon Sep 17 00:00:00 2001 From: Martin Davis <mtnclimb@gmail.com> Date: Sun, 21 Feb 2021 16:38:09 -0800 Subject: [PATCH 1/2] Add a check for MaximumInscribedCircle invalid tolerance Signed-off-by: Martin Davis <mtnclimb@gmail.com> --- .../jts/algorithm/construct/MaximumInscribedCircle.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/core/src/main/java/org/locationtech/jts/algorithm/construct/MaximumInscribedCircle.java b/modules/core/src/main/java/org/locationtech/jts/algorithm/construct/MaximumInscribedCircle.java index 8d6b1bde60..3402c47a82 100644 --- a/modules/core/src/main/java/org/locationtech/jts/algorithm/construct/MaximumInscribedCircle.java +++ b/modules/core/src/main/java/org/locationtech/jts/algorithm/construct/MaximumInscribedCircle.java @@ -104,6 +104,9 @@ public static LineString getRadiusLine(Geometry polygonal, double tolerance) { * @param tolerance the distance tolerance for computing the centre point */ public MaximumInscribedCircle(Geometry polygonal, double tolerance) { + if (tolerance <= 0) { + throw new IllegalArgumentException("Tolerance must be positive"); + } if (! (polygonal instanceof Polygon || polygonal instanceof MultiPolygon)) { throw new IllegalArgumentException("Input geometry must be a Polygon or MultiPolygon"); } From 29b747e5b7261e7b7bddf310d3a9176b97daaf46 Mon Sep 17 00:00:00 2001 From: Martin Davis <mtnclimb@gmail.com> Date: Sun, 21 Feb 2021 16:42:42 -0800 Subject: [PATCH 2/2] Add Javadoc Signed-off-by: Martin Davis <mtnclimb@gmail.com> --- .../jts/algorithm/construct/MaximumInscribedCircle.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/locationtech/jts/algorithm/construct/MaximumInscribedCircle.java b/modules/core/src/main/java/org/locationtech/jts/algorithm/construct/MaximumInscribedCircle.java index 3402c47a82..0f5757a36b 100644 --- a/modules/core/src/main/java/org/locationtech/jts/algorithm/construct/MaximumInscribedCircle.java +++ b/modules/core/src/main/java/org/locationtech/jts/algorithm/construct/MaximumInscribedCircle.java @@ -101,7 +101,8 @@ public static LineString getRadiusLine(Geometry polygonal, double tolerance) { * Creates a new instance of a Maximum Inscribed Circle computation. * * @param polygonal an areal geometry - * @param tolerance the distance tolerance for computing the centre point + * @param tolerance the distance tolerance for computing the centre point (must be positive) + * @throws IllegalArgumentException if the tolerance is non-positive, or the input geometry is non-polygonal or empty. */ public MaximumInscribedCircle(Geometry polygonal, double tolerance) { if (tolerance <= 0) {