Opened 8 years ago

Closed 8 years ago

#1160 closed enhancement (fixed)

operator = returns wrong results checking two POINTS

Reported by: gabrimonfa Owned by: pramsey
Priority: medium Milestone: PostGIS 1.5.4
Component: documentation Version: 1.5.X
Keywords: Cc:

Description

The query

SELECT '0101000000EC51B85E200D3A4114AE47318E635241'::geometry = '010100000052B81E45200D3A417B14AE378E635241'::geometry;

should return false since the two POINTS are different.

I have tried on 1.5.3 (current stable).

The problem is probably present also on older releases (I've tried on 1.5.2 compiled by source and on 1.3.3)

In current (2011-08-16) 2.0.0SVN the query returns the correct result (confirmed by strk on IRC)

Change History (4)

comment:1 Changed 8 years ago by robe

Milestone: PostGIS 2.0.0PostGIS 1.5.4
Resolution: wontfix
Status: newclosed

gabrimonfa,

I don't think this is a bug. First of all you are using = instead the hex compare or ST_Equals. The = operator just compares float4 bounding boxes in prior versions.

In 2.0 this is a double precision box so its not a surprise 2.0 gives a more correct answer.

If you get true with ST_Equals, then there is an issue, otherwise I'll just dismiss this as a limitation for float4 boxes. Paul can confirm.

comment:2 Changed 8 years ago by gabrimonfa

robe,

it's ok for me to close the bug.

I would suggest. however, to add a word of caution to the doc of current stable version to point out that float4 is used for bounding boxes.

SELECT ST_AsText('0101000000EC51B85E200D3A4114AE47318E635241'::geometry),ST_AsText('010100000052B81E45200D3A417B14AE378E635241'::geometry);
          st_astext           |          st_astext      
------------------------------------------------------------     
 POINT(1707296.37 4820536.77) | POINT(1707296.27 4820536.87)

As you can see the 2 points are not so close and one would think that the bounding box of a point is the point itself.

Without knowing that float4 is used for bounding boxes the result may indeed appear to be wrong.

comment:3 Changed 8 years ago by robe

Resolution: wontfix
Status: closedreopened

comment:4 Changed 8 years ago by robe

Component: postgisdocumentation
Resolution: fixed
Status: reopenedclosed
Type: defectenhancement

Okay I've changed this to a documentation enhancement and clarified the behavior in r7756 for PostGIS 1.5

and r7755 for PostGIS 2.0 as a change in behavior.

In both I have put in your example as a demonstration of the behavior.

Note: See TracTickets for help on using tickets.