MBRContains not working?
I'm using MySQL 5.1 Community edition, and I am trying to make use of MBRContains.
Here's a set of SQL query that will demonstrate a problem:
create database test_db;
use test_db;
create table test_table (g polygon not null);
insert into test_table (g) values (geomfromtext('Polygon((0 5,5 10,7 8,2 3,0 5))'));
insert into test_table (g) values (geomfromtext('Polygon((2 3,7 8,9 6,4 1,2 3))'));
select
X(PointN(ExteriorRing(g),1)), Y(PointN(ExteriorRing(g),1)),
X(PointN(ExteriorRing(g),2)), Y(PointN(ExteriorRing(g),2)),
X(PointN(ExteriorRing(g),3)), Y(PointN(ExteriorRing(g),3)),
X(PointN(ExteriorRing(g),4)), Y(PointN(ExteriorRing(g),4))
from test_table where MBRContains(g,GeomFromText('Point(3 6)'));
Basically we are creating 2 Polygons, and we are trying to use MBRContains to determine whether a Point is within either of the two polygons.
Surprisingly, it returns both polygons! Point 3,6 should only exist in the first inserted polygon.
Note that both polygons are tilted (once you draw the polygons on a piece of paper, you will see)
How come MySql returns both polygons?