-
Notifications
You must be signed in to change notification settings - Fork 442
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
CoverageUnion - improve performance for huge amount of geometries #1100
Comments
Thanks for pointing this out. Even the little things can hurt performance, and it's sometimes surprising where they lurk. This was an issue in RelateNG as well (but worse there, since I agree that caching the dimension in OverlayNG.InputGeometry is a good idea. It's also possible to add a short-circuit in GeometryCollection.getDimension when a dim 2 geometry has been found. I'll add both of these optimizations. |
Would it make sense to cache all of has0, has1, has2, hasZ, hasM in |
That occurred to me too. Not sure about this - seems like a lot of extra machinery. But then again, it's being built anyway in client classes. An intermediate option is to create a helper class which caches Geometry dimension information. Then that can be used only where it is critical (so far, this has only been an issue in OverlayNG and RelateNG). |
It doesn't seem too painful...see dbaston/libgeos@8a447c1 |
There's storage overhead, though. And the storage cost is incurred by every collection object, even homogeneous collections which don't need the cache. On balance I prefer a separate cache, which is only needed by the algorithms where the overhead is significant. |
Input: 1M of rectangular polygons
org.locationtech.jts.coverage.CoverageUnion is slow because it internally calls GeometryCollection::getDimension multiple times. GeometryCollection::getDimension process all internal polygons O(n).
Simple test.
current code:
CoverageUnion.union(factory.createGeometryCollection(coverage))
improved performance:
CoverageUnion.union(factory.buildGeometry(coverage))
Suggested fix:
Thank you
The text was updated successfully, but these errors were encountered: