locationtech / locationtech/jts

MinimumDiameter.minimumRectangle result is incorrect

Open
#907 0 comments 0 reactions 1 assignee View on GitHub

@dr-jts is already working on this.

Since Sep 15, 2022.

jts-core type-bug
Dominant language
Java
Stars
2.2k
Forks
475
Avg merge
14d 10h
Merged PRs (30d)
1

Description

As reported in https://github.com/libgeos/geos/issues/679, the result computed by the MinimumDiameter.minimumRectangle method is not always correct. This is because the algorithm assumes the minimum diameter is also the height of the minimum-area rectangle. But this is not always the case, since the perpendicular to the diameter may be long enough that another rectangle is smaller in area.

A reproducer is:

POLYGON ((150 300, 200 300, 300 300, 300 250, 280 120, 210 100, 100 100, 100 240, 150 300))

image

The fix is to create a new MinimumRectangle class using the classic Rotating Calipers algorithm.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.