MySQL Forums
Forum List  »  GIS

Re: Points within polygons
Posted by: Francine Walker
Date: April 30, 2010 04:43PM

Maybe I have been working too many hours. But I am also seing problems with finding points with in polygons.

Here is a very specific example. I have a point in my database table that looks like:
POINT(-80.785128155473 26.347442530646)

I am executing the following SQL:
SELECT id, ASTEXT(location) FROM waypoints_cluster_10 WHERE
WITHIN( location, GEOMFROMTEXT( 'POLYGON(( -81.19171 27.3090129,-81.19171 26.1525330, -80.09308 26.1525330,-80.09308 27.3090129,-81.19171 27.3090129 ))'))

So am I crazy or should this SQL have returned at least this point. I am 100% sure there are many more that are in that polygon but that is a concreate example.
Now if I try this:

SELECT id, COUNT, ASTEXT(location) FROM waypoints_cluster_10
WHERE
WITHIN( GEOMFROMTEXT( 'POINT(-80.785128155473 26.347442530646)' ), GEOMFROMTEXT( 'POLYGON(( -81.19171 27.3090129,-81.19171 26.1525330, -80.09308 26.1525330,-80.09308 27.3090129,-81.19171 27.3090129 ))'))

That returns all the points in the DB. Doesn't that mean that WITHIN( GEOMFROMTEXT( 'POINT(-80.785128155473 26.347442530646)' ), GEOMFROMTEXT( 'POLYGON(( -81.19171 27.3090129,-81.19171 26.1525330, -80.09308 26.1525330,-80.09308 27.3090129,-81.19171 27.3090129 ))'))

Is correct?

What am I overlooking?

Note: I have also tried with polygon verteces in clockwise order and I get the exact same result.

Note: The polygon is supposed to be a simple box.

I am also executing this with many other polygons and most seem to work. But there a few like the one above that don't seem to want to work and I cannot figure out the problem. Is it my code, is it the DB?
The polygons come from a map application where you can zoom and scroll. And most of the time I get the points with in my region correctly. But sometimes I do not.

Any thoughts ?

Mike did you ever resolve your main issu by simply making the polygon counter clockwise. To me that did not seem to make a difference.

Options: ReplyQuote


Subject
Views
Written By
Posted
8167
February 18, 2010 06:50PM
3319
March 27, 2010 04:29AM
4403
April 09, 2010 01:33AM
3156
April 09, 2010 01:50AM
Re: Points within polygons
5457
April 30, 2010 04:43PM
3333
April 30, 2010 06:48PM
2922
April 30, 2010 09:38PM
4350
May 03, 2010 05:33AM
3485
May 06, 2010 08:56AM
4776
May 07, 2010 03:46AM


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.