Opened 5 years ago

Closed 5 years ago

#2605 closed defect (fixed)

armel: _ST_Covers() returns true for point in hole

Reported by: mwanner Owned by: pramsey
Priority: medium Milestone: PostGIS 2.1.4
Component: postgis Version: 2.1.x
Keywords: Cc:

Description

I tracked down an issue in the topology test suite (test addpolygon) to the following (on ARM, little-endian):

test=# SELECT _ST_Covers('POLYGON((9 28, 16 29, 16 23, 10 23, 9 28),
                                  (15 25, 13 27, 11 24, 15 25))'::geometry,
                         'POINT(13 25)'::geometry); 
 _st_covers 
------------
 t
(1 row)

The point in question in excluded by the hole, so _ST_Covers() should return false. It works properly if you use a small polygon, instead:

test=# SELECT _ST_Covers('POLYGON((9 28, 16 29, 16 23, 10 23, 9 28),
                                  (15 25, 13 27, 11 24, 15 25))'::geometry,
                         'POLYGON((13 25, 13.1 25, 13 25.1, 13 25))'::geometry);
 _st_covers 
------------
 f
(1 row)

Attachments (1)

fix-armel (4.9 KB) - added by mwanner 5 years ago.
patch to fix armel, where char is unsigned

Download all attachments as: .zip

Change History (6)

comment:1 Changed 5 years ago by mwanner

The corresponding _ST_CoveredBy() call fails in the same way, which is the reason for test 'tickets' failing on #2084. The following is a simplified version that mistakenly returns true:

test=# SELECT _ST_CoveredBy('POINT(13 25)'::geometry, 'POLYGON((9 28, 16 29, 16 23, 10 23, 9 28),(15 25, 13 27, 11 24, 15 25))'::geometry);
 _st_coveredby 
---------------
 t
(1 row)

However, I guess this runs through the same code path.

Changed 5 years ago by mwanner

Attachment: fix-armel added

patch to fix armel, where char is unsigned

comment:2 Changed 5 years ago by mwanner

An 'int' return value gets casted to 'char' in several places. The latter isn't necessarily signed, so a '(int) -1' value may well be converted to a positive 'char' value on architectures where 'char' is unsigned.

The attached patch fixes this issue by clearly separating the 'int' and 'char' (or 'bool') values.

comment:3 Changed 5 years ago by robe

strk or pramsey -- see any issue with this patch?

comment:4 Changed 5 years ago by pramsey

Milestone: PostGIS 2.1.2PostGIS 2.1.3

comment:5 Changed 5 years ago by pramsey

Resolution: fixed
Status: newclosed

Commtited to 2.1 at r12895, trunk at r12896

Note: See TracTickets for help on using tickets.