Unix Technical Forum

contains(g1, g2)

This is a discussion on contains(g1, g2) within the MySQL forums, part of the Database Server Software category; --> Hi, I have encountered a strange problem in mysql: The spatial function Contains(g1, g2) works fine, when using it ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 11:25 AM
korcs
 
Posts: n/a
Default contains(g1, g2)

Hi,

I have encountered a strange problem in mysql:

The spatial function Contains(g1, g2) works fine, when using it on
it's own, but when I put it into a query as a WHERE Condition, I get
an error message:

The query:

SELECT id, X(pt) AS x, Y(pt) AS y, timestamp FROM points WHERE
Contains(GeomFromText('POLYGON(7 10, 15 10, 15 2, 7 2)'), pt);

The error:

FUNCTION test_routes.GeomFromText does not exist

Does somebody know the solution for this problem?

Thx,

korcs

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 11:25 AM
korcs
 
Posts: n/a
Default Re: contains(g1, g2)

I found the solution:

If you define a POLYGON, you have to enter the first point always
twice, as the polygon is not a LINESTRING, so it should be closed. It
is actually quite obvious, but If you don't know it, then it can cost
you an afternoon or so...

The brackets should be doubled even if you don't want to define an
interior ring!

The right query is:

SELECT id, X(pt) AS x, Y(pt) AS y, timestamp FROM points WHERE
Contains(GeomFromText('POLYGON((7 10, 15 10, 15 2, 7 2, 7 10))'),
pt);


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:36 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com