Opened 13 years ago
Closed 13 years ago
#581 closed defect (fixed)
LWGEOM_expand produces inconsistent results
|Reported by:||alexz||Owned by:||mcayland|
# SELECT dropbbox(ST_expand(setsrid(makepoint(-122.50367,37.74189),4326), 0.00004)) && dropbbox(ST_expand(setsrid(makepoint(-122.50376,37.74185),4326), 0.00004)), ST_expand(setsrid(makepoint(-122.50367,37.74189),4326), 0.00004) && ST_expand(setsrid(makepoint(-122.50376,37.74185),4326), 0.00004);
Change History (11)
follow-up: 2 comment:1 by , 13 years ago
comment:2 by , 13 years ago
comment:3 by , 13 years ago
that's not quite what I meant. I meant its the same class of a problem and similar fix applied in #410 would fix this as well.
comment:4 by , 13 years ago
In which case, yes, it sure seems like a similar problem.
comment:5 by , 13 years ago
Okay - Alex, please can you try the attached patch?
The culprit in this scenario appears to be ptarray_compute_box2d() introducing errors into the BOX2DFLOAT4 bounding box cache. Currently the function works by converting each point from double to single precision and then comparing the extents with the current bounding box to expand it as required. Unfortunately this has the side effect of introducing cumulative errors into the bounding box which is why the incorrect answer is given.
The attached patch works by performing the entire calculation using full precision BOX3D and then converting to BOX2DFLOAT4 at the end.
Paul, Regina & Kevin - I've tested this patch against 1.5 and trunk and it appears to pass all regression tests for me. I'd like to get this into 1.5.2 if Alex agrees that this resolves his issue.
by , 13 years ago
comment:6 by , 13 years ago
That patch doesn't change the results of the query in the body of the bug report for me.
Because I had to blow away the database for other reasons I took the following steps:
Patch postgis. Install postgis. Restart postgres. Create new database with SQL files from the postgis install. Run said query. One column is true, one false.
comment:7 by , 13 years ago
The patch works fine here. alexz: make sure to rebuild (make clean).
comment:8 by , 13 years ago
As an aside, 'make clean' fails in one of the documentation directories. Whoops.
So I ran make -k clean, rebuilt, and it passes the query above.
comment:9 by , 13 years ago
comment:10 by , 13 years ago
|Status:||new → closed|
Just a wild guess, but I suspect this is the same issue as we resolved in #410
that the cached box is not being recalculated during st_expand call.