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::computeMaximumIterations for small values #1133

Merged
merged 1 commit into from
Jul 27, 2024

Conversation

mwtoews
Copy link
Contributor

@mwtoews mwtoews commented Jul 25, 2024

This fixes an issue with MaximumInscribedCircle::computeMaximumIterations that sometimes returns bogus values.

For example, with this example the number of iterations is needed by LargestEmptyCircle::compute(). The geometry calculates ncells=0.0903549, which would normally have a log value -2.40401. But the early cast to size_t doesn't correctly handle negative values meaning the maxIter is either 0 or 4294965296 (i.e. it's up to the compiler to decide). This fix will re-establish the maxIter to 4000 for small "ncells" values (less than 1). The bug with MSVC 32-bit is that it was zero, meaning no iteration.

Also clean-up one MSVC warning.

Closes #1129

@mwtoews
Copy link
Contributor Author

mwtoews commented Jul 25, 2024

Potentially a similar fix would be good with JTS here too.

Wait, never mind, nothing wrong with JTS here since ints can safely go negative. A counter-fix for GEOS is to set factor to a signed int, similar to JTS. It's also probably not a big deal too.

@dr-jts
Copy link
Contributor

dr-jts commented Jul 26, 2024

Might be nice to keep the codebases more in synch - by using the signed int idea?

@mwtoews mwtoews force-pushed the fix-compute-maximum-iterations branch 2 times, most recently from c4137a6 to ebee570 Compare July 26, 2024 00:18
@mwtoews mwtoews force-pushed the fix-compute-maximum-iterations branch from ebee570 to da7ed5c Compare July 26, 2024 00:58
@mwtoews mwtoews merged commit b17470d into libgeos:main Jul 27, 2024
27 checks passed
@mwtoews mwtoews deleted the fix-compute-maximum-iterations branch July 27, 2024 08:49
@mwtoews
Copy link
Contributor Author

mwtoews commented Jul 27, 2024

Cherry-picked to the 3.12 maintenance branch 8fa289c
Is this NEWS-worthy for 3.12.3? It seems so trivial and specific to me to not.

@dr-jts
Copy link
Contributor

dr-jts commented Jul 27, 2024

Is this NEWS-worthy for 3.12.3? It seems so trivial and specific to me to not.

Agreed, probably no need to add to NEWS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MSVC 32-bit test failure with LargestEmptyCircle
3 participants