-
Notifications
You must be signed in to change notification settings - Fork 369
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
Delegate Geometry::intersects to PreparedGeometry::intersects #775
Conversation
Nice!
Does `contains` show a similar performance boost?
|
I would expect an improvement, but I need to put together some suitable geometries for testing. Will do as a separate PR. |
|
57a1399
to
8b42258
Compare
You should test with Points and small (2-point) LineStrings as well, to ensure there is no performance regression in those cases (or if there is, that it's acceptable). In JTS using PreparedPolygon against points is slightly slower than the
|
@dbaston In JTS I'm seeing that
I'm pretty sure that I carried out this kind of analysis a while ago, and decided that the tradeoff was a difficult call to make. Perhaps what's required is a switch based on the size of the target geometry. |
Also, I expect that a new implementation of That in itself probably doesn't weigh against this PR, since this change can be backed out when |
Can you point me to those benchmarks? Disregard - I see they're in https://github.com/locationtech/jts/tree/0911609ba8e7d7ce0cacaaccb3216bc5576b8516/modules/core/src/test/java/test/jts/perf/geom/prep |
I ported your benchmark and I see the same trend in GEOS, although RelateOp doesn't become faster there are until around 3,000 points in the sine star. |
An "incrementally prepared geometry" resolves the issue. Too hacky?
|
Very clever! Looks good to me. A line or two of explanatory doco would be nice. |
Followed up (with some benchmarking) in #777 |
This PR changes
Geometry::intersects
andGeometry::disjoint
to usePreparedGeometry
instead ofRelateOp
. Relative to theRelateOp
implementation, the prepared intersection is more robust (e.g., #766) and is faster for both complex and simple polygons, even if the object is only used a single time.A quick benchmark shows the performance difference in cases of relatively complex polygons (left) and triangles (right), using the GEOS
perf_intersection
, which combines index querying, intersects testing, and intersection overlay.