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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| ||||
| 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); |