MySql Geospatial bug..?

Posted by ShaChris23 on Stack Overflow See other posts from Stack Overflow or by ShaChris23
Published on 2009-07-16T00:58:40Z Indexed on 2010/06/11 1:32 UTC
Read the original article Hit count: 376

This question is for Mysql geospatial-extension experts.

The following query doesn't the result that I'm expecting:

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? I'm using MySql Community Edition 5.1.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about geospatial