Opened 14 years ago
Closed 14 years ago
#581 closed defect (fixed)
LWGEOM_expand produces inconsistent results
Reported by: | alexz | Owned by: | mcayland |
---|---|---|---|
Priority: | high | Milestone: | PostGIS 1.5.2 |
Component: | postgis | Version: | 1.5.X |
Keywords: | Cc: |
Description
# 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);
?column? | ?column? |
t | f |
(1 row)
See also:
http://postgis.refractions.net/pipermail/postgis-users/2010-September/027614.html http://archives.postgresql.org/pgsql-bugs/2010-08/msg00361.php
Attachments (1)
Change History (11)
follow-up: 2 comment:1 by , 14 years ago
comment:2 by , 14 years ago
comment:3 by , 14 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:5 by , 14 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.
Mark.
by , 14 years ago
Attachment: | postgis-ptarray-compute-box2d.patch added |
---|
comment:6 by , 14 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:8 by , 14 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 , 14 years ago
Owner: | changed from | to
---|
comment:10 by , 14 years ago
Resolution: | → fixed |
---|---|
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.