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

Fix the MinimumBoundingCircle farthestPoints method #522

Merged
merged 1 commit into from
Mar 17, 2020
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 @@ -161,8 +161,8 @@ public Geometry getFarthestPoints() {
*/
private static Coordinate[] farthestPoints(Coordinate[] pts) {
double dist01 = pts[0].distance(pts[1]);
double dist12 = pts[0].distance(pts[1]);
if (dist12 > dist01) {
double dist12 = pts[1].distance(pts[2]);
if (dist01 >= dist12) {
return new Coordinate[] { pts[0], pts[1] };
}
return new Coordinate[] { pts[1], pts[2] };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void testMinDiameterLine() {

public void testMinDiameterPolygon() {
doMinDiameterTest("POLYGON ((100 200, 300 150, 110 100, 100 200))", "LINESTRING (300 150, 100 200)");
doMinDiameterTest("POLYGON ((110 200, 300 150, 100 100, 110 200))", "LINESTRING (300 150, 100 100)");
}

static final double TOLERANCE = 1.0e-5;
Expand Down