本文介绍了MySQL 几何函数、点和多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表名polygon_csa",它有两列element_id"作为整数,poly"作为四点多边形

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);

这会返回错误 1054 'unknown column Poly.polygons_csa in where 子句'.我正在运行 MySQL 5.7,这是一个错误,还是我误解了语法?

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?

我也试过:

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

这也会返回错误 1054

this also returns error 1054

推荐答案

MRBContains 函数只能返回 1 或 0 结果,因此不适用于此应用程序,需要带有 if 语句的过程.

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.

这篇关于MySQL 几何函数、点和多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 23:24