【问题标题】:mysql: using st_distance_sphere giving OK but no resultsmysql:使用 st_distance_sphere 给出 OK 但没有结果
【发布时间】:2018-12-11 09:39:11
【问题描述】:

我有带有列 ID、名称、位置的表格区域。列位置是 POINT 类型,存储地点的(纬度、经度)。

我在 MySQL here 中阅读了使用点数据类型和 st_distance_sphere 查找最近地点的解决方案。但是当我在 mysql 工作台中运行以下查询时,我收到消息:好的。我想查看所有符合此条件的行。

select
    id,name,
    st_distance_sphere(`position`, st_geomfromtext('Point(77.058210 28.632955)', 4326)) as distance
from areas
order by distance asc;

【问题讨论】:

  • 请参考您在哪里找到的,以便我们查看您的基本信息,其中应包括 SHOW CREATE TABLE xxxx。

标签: mysql gis spatial


【解决方案1】:

您可能需要检查构建 POINT 的方式。 POINT 构造函数的第一个参数是经度。

POINT(longitude, latitude)

如果您将其反转,那么您将不会得到任何结果,因为它无法计算。 但是查询本身并没有错,因此返回消息 OK。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-26
    • 2018-11-30
    相关资源
    最近更新 更多