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 MaximumInscribedCircle and LargestEmptyCircle performance and memory issues #978

Merged
merged 4 commits into from
Apr 27, 2023

Conversation

dr-jts
Copy link
Contributor

@dr-jts dr-jts commented Apr 27, 2023

This PR adds heuristics to MaximumInscribedCircle and LargestEmptyCircle to prevent long-running (and memory-intensive) processing for nearly flat and very thin inputs.

There are two problems solved:

  1. if the input extent is very small in one dimension (i.e. almost flat), the cell grid was initialized with cells of very small size, causing a memory explosion. This is avoided by using a single initial grid cell covering the extent.
  2. Very thin (low-area) geometries (or LEC boundaries) cause a long search to find a cell with a centre inside the geometry (since very few cells in the search space satisfy this condition). A heuristic is used to determine a maximum number of iterations permitted. This means that the computed result may lie outside the input geometry. This can be mitigated by using a smaller tolerance distance; but there is no way to guarantee the centre will lie inside.

This fixes the issue reported in libgeos/geos#875.

Signed-off-by: Martin Davis <mtnclimb@gmail.com>
Signed-off-by: Martin Davis <mtnclimb@gmail.com>
Signed-off-by: Martin Davis <mtnclimb@gmail.com>
Signed-off-by: Martin Davis <mtnclimb@gmail.com>
@dr-jts dr-jts merged commit 333afbc into locationtech:master Apr 27, 2023
@dr-jts dr-jts deleted the fix-mic-lic-thin-geom branch April 27, 2023 02:54
@dr-jts dr-jts changed the title Fix MIC and LEC for thin geometries Avoid long looping in MaximumInscribedCircle and LargestEmptyCircle Apr 28, 2023
@dr-jts dr-jts changed the title Avoid long looping in MaximumInscribedCircle and LargestEmptyCircle Fix MaximumInscribedCircle and LargestEmptyCircle performance and memory issues Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant