Bug #53744 intersects returns false for a point on a vertex of polygon
Submitted: 18 May 2010 10:24 Modified: 9 Jan 2014 12:57
Reporter: John Powell Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: GIS Severity:S3 (Non-critical)
Version:5.1 GIS OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: gis, intersection, spatial

[18 May 2010 10:24] John Powell
Description:
Intersects returns false when the enclosing polygon shares a point with the point being tested or when the point is on one of the polygon's line segments.

mbrintersects returns true, correctly.

How to repeat:
set @point=geomfromtext('POINT(0 0)');
set @poly=geomfromtext('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))');

select intersects(@geom,@point);
+--------------------------+
| intersects(@geom,@point) |
+--------------------------+
|                        0 |
+--------------------------+

Or for a point on one of the polygon's line segments

set @point=geomfromtext('POINT(0.5,0)');
select intersects(@geom,@point);
+--------------------------+
| intersects(@geom,@point) |
+--------------------------+
|                        0 |
+--------------------------+

However, mbrintersects returns correct value

select mbrintersects(@geom,@point);
+-----------------------------+
| mbrintersects(@geom,@point) |
+-----------------------------+
|                           1 |
+-----------------------------+
[18 May 2010 18:35] MySQL Verification Team
Thank you for the bug report. Which source are you using?. I tried the regular mysql-5.1 and mysql-5.1-wl1326 with differents results than yours:

iguel@tikal:~/dbs/5.1GS/var$ cd
miguel@tikal:~$ dbs/5.1GS/bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.43 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set @point=geomfromtext('POINT(0 0)');
Query OK, 0 rows affected (0.00 sec)

mysql> set @poly=geomfromtext('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))');
Query OK, 0 rows affected (0.00 sec)

mysql> 
mysql> select intersects(@geom,@point);
+--------------------------+
| intersects(@geom,@point) |
+--------------------------+
|                     NULL |
+--------------------------+
1 row in set (0.00 sec)

mysql> set @point=geomfromtext('POINT(0 0)');
Query OK, 0 rows affected (0.00 sec)

mysql> set @poly=geomfromtext('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))');
Query OK, 0 rows affected (0.00 sec)

mysql> 
mysql> select intersects(@geom,@point);
+--------------------------+
| intersects(@geom,@point) |
+--------------------------+
|                     NULL |
+--------------------------+                                                                                                                                                     
1 row in set (0.00 sec)                                                                                                                                                          
                                                                                                                                                                                 
mysql> select mbrintersects(@geom,@point);                                                                                                                                       
+-----------------------------+                                                                                                                                                  
| mbrintersects(@geom,@point) |                                                                                                                                                  
+-----------------------------+
|                        NULL |
+-----------------------------+
1 row in set (0.00 sec)

mysql> exit
Bye

Thanks in advance.
[18 May 2010 21:05] John Powell
My apologies. @geom got substituted for @poly in the initial report.

set @point=geomfromtext('POINT(0 0)');
set @poly=geomfromtext('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))');
select intersects(@poly, @point);
+--------------------------+
| intersects(@geom,@point) |
+--------------------------+
|                        0 |
+--------------------------+
[27 May 2010 1:57] MySQL Verification Team
Thank you for the feedback. Verified as described:

mysql> set @point=geomfromtext('POINT(0 0)');
Query OK, 0 rows affected (0.00 sec)

mysql> set @poly=geomfromtext('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))');
Query OK, 0 rows affected (0.00 sec)

mysql> select intersects(@poly, @point);
+---------------------------+
| intersects(@poly, @point) |
+---------------------------+
|                         0 |
+---------------------------+
1 row in set (0.00 sec)

mysql> exit
Bye
miguel@tikal:~$
[9 Jan 2014 12:57] Erlend Dahl
This isn't repeatable on recent 5.1/5.5/5.6 or trunk.