Mysql select where polygon contains point always f

2019-05-14 21:01发布

I have tried various functions like MBRWithin, MBRContains, Intersects, Contains (all of them found in a plenty of posts around here) but no luck yet. This is the simplified query:

SELECT * FROM  users
WHERE Intersects( GeomFromText( 'POINT(50 50)' ), GeomFromText( 'POLYGON(0 0, 100 0, 100 100, 0 100, 0 0)' ) );

I expected it to evaluate that condition as true (like 1=1) and return all users, however this did not happen. Please tell me, what am I doing wrong?

I am running MySql 5.5

1条回答
smile是对你的礼貌
2楼-- · 2019-05-14 21:25

This worked for me:

SELECT
    *
FROM 
    users
WHERE
    MBRContains(
        GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))'),
        GeomFromText('Point(50 50)')) = 1;
查看更多
登录 后发表回答