gpt4 book ai didi

php - 在mysql中使用列名作为POINT几何的参数

转载 作者:行者123 更新时间:2023-11-29 08:31:12 25 4
gpt4 key购买 nike

我正在研究一个查询,该查询获取纬度和经度位于给定多边形内的所有行。我正在使用几何函数来做到这一点。我可以对多边形和点使用包含方法,但是在我的情况下,我在查询中显式使用多边形坐标,并希望使用“纬度”和“经度”列名称作为 POINT 的参数。我尝试使用 concat 方法,但从 contains 方法中得到“false”返回。

查询:

  SELECT 
*
from table
WHERE
contains(
GeomFromText(
'POLYGON(
(32.717399 -117.144126,32.714655 -117.136487,32.710827 -117.145843,32.714005 -117.146444, 32.717399 -117.144126))
'),
GeomFromText(
'POINT(
concate(latitude," ",longitude))
'))

我的表结构是:

property_id                 int(11)
latitude decimal(10,6)
longitude decimal(10,6)
Address_f1365 char(100)
AddressOnTheInternet_f27 char(255)

最佳答案

在实际查询中使用之前尝试这样的操作:

SELECT asWKT(GeomFromText(CONCAT('POINT(', 15, ' ', 26, ')')));

演出:

'POINT(15 26)'

我建议您测试任何内容,这将是使用函数 asWKT()/asText() 进行空间数据查询的一部分。查看 supported formats手册conversion functions .

您错误地使用了CONCAT()。尝试:

SELECT 
*
FROM
`table`
WHERE
CONTAINS(
GeomFromText('POLYGON((32.717399 -117.144126,32.714655 -117.136487,32.710827 -117.145843,32.714005 -117.146444, 32.717399 -117.144126))')
,
GeomFromText(CONCAT('POINT(', latitude, ' ', longitude, ')'))
)

关于php - 在mysql中使用列名作为POINT几何的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16559044/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com