#2084 closed defect (fixed)
ST_Within and ST_CoveredBy producing bad results after fix for #547
Reported by: | darkpanda | Owned by: | pramsey |
---|---|---|---|
Priority: | critical | Milestone: | PostGIS 1.5.8 |
Component: | postgis | Version: | 1.5.X |
Keywords: | Cc: |
Description
It appears that the patch that closed off #547 (ST_contains memory problem when used between polygon and mixed geometry) in r10186 causes ST_Within and ST_CoveredBy to produce incorrect results. This can sometimes lead to true values being returned when false values are the correct results.
The lines in postgis/lwgeom_geos.c that populate the cache with polygons seem to be inserting the wrong geometries into the cache. In both of the function definitions for within
and
coveredby
, the lines read
poly_cache = GetRtreeCache(fcinfo, lwgeom, SERIALIZED_FORM(geom1));
but geom1 refers to the point, not the polygon. The lines should read
poly_cache = GetRtreeCache(fcinfo, lwgeom, SERIALIZED_FORM(geom2));
The problem was never noticed before because the cache wasn't being used effectively, but the patch to #547 enabled the cache and thus the unexpected results.
Attached is a patch for the 1.5 branch that should fix these lines and includes some regression tests for regress/tickets.sql
. The geometries used for the tests are variations on the ones we happened to be using when we noticed this behaviour on one of our servers but could be replaced with simpler tests if desired.
Attachments (1)
Change History (4)
by , 12 years ago
Attachment: | 0001-2084-ST_Within-and-ST_CoveredBy-producing-bad-result.patch added |
---|
comment:1 by , 12 years ago
comment:3 by , 12 years ago
Milestone: | PostGIS 1.5.7 → PostGIS 1.5.8 |
---|
Patch makes sense, the logic of the calls is reversed, but the cache uses the polygon-in-arg1 logic of other functions. Checking against my local regression now.