MySQL Forums
Forum List  »  GIS

MBRContains not working?
Posted by: Shivesh Wangrungvichaisri
Date: July 15, 2009 07:01PM

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?

Options: ReplyQuote


Subject
Views
Written By
Posted
MBRContains not working?
6401
July 15, 2009 07:01PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.