Bug #24563 MBROverlaps does not seem to function propertly.
Submitted: 23 Nov 2006 22:52 Modified: 10 Apr 2007 16:03
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.21, 5.0.27, 5.1.12 OS:Microsoft Windows (Windows XP)
Assigned to: Timothy Smith
Tags: gis

[23 Nov 2006 22:52] [ name withheld ]
Description:
It appears the MBROverlaps() method does not function quite as it should (from what I can tell anyway).  In some cases it seems to return the correct result but others it appears to return the incorrect result.

I have used the JTS Test Builder to test these functions as well to confirm that my tests are correct.

I create two rectangles (using rectangles because the methods only work for the MBR), and in one case it works like it should but in the other it doesn't.

How to repeat:
mysql> set @g1 = GeomFromText('POLYGON ((0 0, 0 3, 3 3, 3 0, 0 0))');
mysql> set @g2 = GeomFromText('POLYGON ((1 0, 1 3, 4 3, 4 0, 1 0))');
mysql> set @g3 = GeomFromText('POLYGON ((1 1, 1 4, 4 4, 4 1, 1 1))');

mysql> select MBROverlaps(@g1,@g2);
+----------------------+
| MBROverlaps(@g1,@g2) |
+----------------------+
|                    0 |
+----------------------+
1 row in set (0.00 sec)

mysql> select MBROverlaps(@g1,@g3);
+----------------------+
| MBROverlaps(@g1,@g3) |
+----------------------+
|                    1 |
+----------------------+
1 row in set (0.00 sec)

When I take the same polygons and use JTS's suite to test them with both come up as Overlapping (which if I understand spatially overlapping they should).
[26 Jan 2007 1:46] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/18820

ChangeSet@1.2391, 2007-01-25 18:46:29-07:00, tsmith@siva.hindu.god +8 -0
  Bug #24563: MBROverlaps does not seem to function propertly
  
  MBROverlaps() returned false for overlapping rectangles that were
  only shifted along either the x- or the y-axis. It also returned
  true for "A overlaps B" but false for "B overlaps A" in some cases.
  
  Tests added for all MBR* functions and their non-MBR-prefixed aliases.
[7 Feb 2007 16:46] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/19497

ChangeSet@1.2391, 2007-02-07 09:46:01-07:00, tsmith@siva.hindu.god +8 -0
  Bug #24563: MBROverlaps does not seem to function propertly.
  
  Fix is to rewrite the MBR::overlaps() function, to compute the dimension of both arguments, and the dimension of the intersection; test that all three dimensions are the same (e.g., all are Polygons).
  
  Add tests for all MBR* functions for various combinations of shapes, lines and points.
[23 Mar 2007 22:28] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/22845

ChangeSet@1.2413, 2007-03-23 16:28:07-06:00, tsmith@siva.hindu.god +8 -0
  Bug #24563: MBROverlaps does not seem to function propertly.
  
  Fix is to rewrite the MBR::overlaps() function, to compute the dimension of both
  arguments, and the dimension of the intersection; test that all three dimensions are the
  same (e.g., all are Polygons).
  
  Add tests for all MBR* functions for various combinations of shapes, lines and points.
[28 Mar 2007 23:41] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/23221

ChangeSet@1.2427, 2007-03-28 17:40:42-06:00, tsmith@siva.hindu.god +5 -0
  Update test for bug #24563 (MBROverlaps does not seem to function propertly.):
  - Add primary key to test table, so NDB with binlog doesn't complain
  - Add extra results for bdb_gis.result
[29 Mar 2007 1:40] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/23227

ChangeSet@1.2429, 2007-03-28 19:39:43-06:00, tsmith@siva.hindu.god +5 -0
  Update test for bug #24563 (MBROverlaps does not seem to function propertly.); ARCHIVE doesn't support AUTO_INCREMENT, so specify PK values explicitly
[6 Apr 2007 17:22] Bugs System
Pushed into 5.0.40
[6 Apr 2007 17:24] Bugs System
Pushed into 5.1.18-beta
[7 Apr 2007 18:57] Paul Dubois
Noted in 5.1.18, 5.0.40 changelog.

MBROverlaps() returned incorrect values in some cases.

Leaving bug report in Documenting pending additional
explanation of MBR*() function operation in Spatial
Extensions chapter.
[10 Apr 2007 16:03] Paul Dubois
I have added some explanation of intersects,
overlaps, touches in the MBR functions chapter.