MySQL geometry function, points and polygons

心不动则不痛 提交于 2020-03-04 18:49:47

问题


I have a table name 'polygon_csa', which has two columns 'element_id' as an integer and 'poly' as a four point polygon

I am trying to find which polygons enclose a point of my choice. I have tired the following code:

    Set @x = -60;
    Set @y = 10;

    set @xy=ST_geomfromtext(concat('Point (',@x, ' ', @y,')'));
    Select element_id from polygon_csa where ST_Contains(poly.polygons_csa,@xy);

This returns error 1054 'unknown column Poly.polygons_csa in where clause'. I am running MySQL 5.7, is this a bug, or have I misunderstood the syntax?

I have also tried:

    set @xy=ST_geomfromtext(concat('Point (',@x, ' ', @y,')'));
    Select element_id from polygon_csa where (MRBContains(poly.polygons_csa,@xy));

this also returns error 1054


回答1:


MRBContains function can only return a 1 or 0 result so it is not suitable for this application, a procedure with an if statement is what is needed.



来源:https://stackoverflow.com/questions/60265289/mysql-geometry-function-points-and-polygons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!