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
[Backport 7.6] PostGIS: fix ST_Intersects() with bounding box that is a point #6355
Conversation
…w-up of fixes MapServer#6181, fixes MapServer#6230) (fixes MapServer#6347 (comment))
Just a FYI. Ran into another regression that seems like it might be related. Will create a ticket when I can isolate the problem more... Ok, a little more. In my case the "shape" that ultimately gets intersected with the bounding box is created using ST_Collect(), so there's a "GROUP BY" and then an aggregation using ST_Collect(). The new bounding box check ST_Intersects("shape", ST_GeomFromText('POLYGON((125000 4785000,125000 5489000,789000 5489000,789000 4785000,125000 4785000))',26915)) fails against that geometry with an error like:
The old bounding box check "shape" && ST_GeomFromText('POLYGON((125000 4785000,125000 5489000,789000 5489000,789000 4785000,125000 4785000))',26915) works as expected. This might not be something that can be addressed in the code but I suspect that other users might be using aggregation functions that might break as a result of the change. --Steve |
Note that if I switch ST_Collect() to ST_Union() the error goes away - but at a performance cost. |
Should we wait to release 7.6.4, for this fix? |
I don't know, but it is a regression. The issue, more generally, is that a GeometryCollection fails. In my case I'm just doing a query to generate a light JSON response so I don't use the resulting geometry for anything (e.g. drawing or outputting geometries) so the actual type (GeometryCollection vs MultiLinestring) doesn't matter. We're using PostGIS 2.4 and it looks like this is no longer an issue in version 2.5. Perhaps a note to -dev to see what folks think. --Steve |
@sdlime Does the following fix your issue ? (it is likely not sufficient if the geometry collection contains heterogenous single geometry types)
|
That said I'm concerned it might prevent PostGIS from using its spatial index... We should probably check if the geometry column is a true geometry column, and if so use ST_Intersects(), and if not probably add a && filter in addition |
Could @pramsey potentially advise what would be a robust & efficient strategy for calling |
Your intuition that wrapping the column in any ST_Function() is going to invalidate the index is correct, so don't do that. The lack of support of geometrycollection in ST_Intersects in some versions is the key issue, and it might be the simplest thing is to just go with && instead of ST_Intersects. You'll get an over-determined result set, however, and that might be another regression. This has other knock-on performance impacts, but |
What about && if < 2.5 and ST_Intersects if >= 2.5? |
Then I'd have to be definitive about what version the behavior changed in :) maybe people with older things running can quickly crowdsource if this runs select st_intersects('POINT(1 1)', 'GEOMETRYCOLLECTION(LINESTRING(2 2, 3 3), POINT(1 1))'); |
Crowd confirms that collections work >= 2.5. |
(follow-up of fixes #6181, fixes #6230) (fixes #6347 (comment))
Backport of PR #6354