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 invalid values from CoverageUnionNG #1226

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

mwtoews
Copy link
Contributor

@mwtoews mwtoews commented Jan 14, 2025

This resolves an invalid value message shown in shapely:

>>> import shapely
>>> shapely.geos_version_string
'3.13.0'
>>> shapely.coverage_union_all([])
/home/mtoews/src/shapely/shapely/shapely/set_operations.py:505: RuntimeWarning: invalid value encountered in coverage_union
  return lib.coverage_union(collections, **kwargs)
<GEOMETRYCOLLECTION EMPTY>

This is caused by a division by zero in GEOS' CoverageUnion::geomunion() with coverage inputs that are empty or don't have an area.

Tests 9 to 14 were silently throwing this warning too, as these input coverages don't have an area.

@mwtoews mwtoews requested a review from dr-jts January 14, 2025 11:00
@pramsey pramsey self-requested a review January 14, 2025 16:49
Copy link
Member

@pramsey pramsey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the test case that actually looks at the flags :) should help.

@mwtoews
Copy link
Contributor Author

mwtoews commented Jan 15, 2025

This is probably too minor to add to NEWS, but worth backporting to 3.13 and 3.12.

@mwtoews mwtoews merged commit f74855c into libgeos:main Jan 15, 2025
28 checks passed
@mwtoews mwtoews deleted the fix-coverage-union-div0 branch January 15, 2025 00:17
mwtoews added a commit that referenced this pull request Jan 15, 2025
mwtoews added a commit that referenced this pull request Jan 15, 2025
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.

2 participants