问题
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