1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

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.


mysql-test/include/gis_generic.inc:
  Add tests & checks for bug #24563 and bug #24588 - some GIS functions missing in
  5.1; many GIS functions not tested; Overlaps() function was incorrect when MBR shifted
  only along one axis; Overlaps() needs to take dimension of shape into account.
mysql-test/r/archive_gis.result:
  Update test results.
mysql-test/r/bdb_gis.result:
  Update test results.
mysql-test/r/gis.result:
  Update test results.
mysql-test/r/innodb_gis.result:
  Update test results.
mysql-test/r/ndb_gis.result:
  Update test results.
mysql-test/t/gis.test:
  Add tests & checks for bug #24563 and bug #24588 - some GIS functions missing in
  5.1; many GIS functions not tested; Overlaps() function was incorrect when MBR shifted
  only along one axis; Overlaps() needs to take dimension of shape into account.
sql/spatial.h:
  Add MBR::dimension() (map MBR to integral dimension: point -> 0, line -> 1,
  polygon -> 2, invalid -> -1)
  
  Fix MBR::overlaps() to handle MBRs which are shifted on one dimension only, and to
  take MBR dimension into account.  Also, test both within() and contains() predicates (so
  that overlaps(a, b) == overlaps(b, a)).
This commit is contained in:
unknown
2007-03-23 16:28:07 -06:00
parent 2b52bc2a8e
commit eee28a267d
8 changed files with 671 additions and 13 deletions

View File

@@ -144,15 +144,46 @@ struct MBR
return (xmin<x) && (xmax>x) && (ymin<y) && (ymax>y);
}
/**
The dimension maps to an integer as:
- Polygon -> 2
- Horizontal or vertical line -> 1
- Point -> 0
- Invalid MBR -> -1
*/
int dimension() const
{
int d= 0;
if (xmin > xmax)
return -1;
else if (xmin < xmax)
d++;
if (ymin > ymax)
return -1;
else if (ymin < ymax)
d++;
return d;
}
int overlaps(const MBR *mbr)
{
int lb= mbr->inner_point(xmin, ymin);
int rb= mbr->inner_point(xmax, ymin);
int rt= mbr->inner_point(xmax, ymax);
int lt= mbr->inner_point(xmin, ymax);
/*
overlaps() requires that some point inside *this is also inside
*mbr, and that both geometries and their intersection are of the
same dimension.
*/
int d = dimension();
int a = lb+rb+rt+lt;
return (a>0) && (a<4) && (!within(mbr));
if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
return 0;
MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
min(xmax, mbr->xmax), min(ymax, mbr->ymax));
return (d == intersection.dimension());
}
};