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

Add GeometryCollection dimension cache #1103

Merged

Conversation

dr-jts
Copy link
Contributor

@dr-jts dr-jts commented Dec 19, 2024

Heterogeneous (mixed) GeometryCollections have to use an O(n) algorithm to determine the dimensions of the elements. This causes performance issues in algorithms which use the dimension of the collection (see #1100).

This PR solves this problem by caching the computed dimensions of a GeometryCollection. It adds a single reference to each collection object, but the actual cache is lazily created when dimension information is accessed.

For example, for a CoverageUnion of a grid of 1M rectangles this improves the performance from 17 s to 370 ms (45x).

Fixes #1100

@dr-jts dr-jts merged commit 47b52bd into locationtech:master Dec 19, 2024
2 checks passed
@dr-jts dr-jts deleted the add-geometrycollection-dimension-cache branch December 19, 2024 21:15
@dr-jts
Copy link
Contributor Author

dr-jts commented Jan 3, 2025

@dbaston are you able to port this to GEOS?

@dbaston
Copy link
Contributor

dbaston commented Jan 4, 2025

@dbaston are you able to port this to GEOS?

Yes, libgeos/geos#1220

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.

CoverageUnion - improve performance for huge amount of geometries
2 participants