gpt4 book ai didi

mysql - 我可以将 WGS84 纬度/经度作为空间数据直接存储在 MySQL 中吗?

转载 作者:行者123 更新时间:2023-11-29 00:26:20 27 4
gpt4 key购买 nike

我有一套 WGS84 coordinates .保守的方法是将它们存储为数字 (What datatype to use when storing latitude and longitude data in SQL databases?) 并像此处那样计算距离 (latitude/longitude find nearest latitude/longitude - complex sql or complex calculation)。

一种更高级的方法是为“在范围内”( MySQL User Defined Function for Latitude Longitude Syntax ) 创建一个用户定义的函数

MySQL latitude and Longitude table setup使用 spatial index .但是我不太明白是否可以直接存储WGS坐标,然后根据Point数据类型查询距离?

示例:数据如下所示:"lat"40.7142298"lng"-73.9614669,这就是我要导入的内容。然后像“选择纬度/经度 10 公里范围内的所有图珀尔”这样的查询。

最佳答案

你读过Manual section on the Spatial Extensions吗? ?

要查询,定义一个查询区域(例如矩形),然后通过within过滤

关于mysql - 我可以将 WGS84 纬度/经度作为空间数据直接存储在 MySQL 中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18740149/

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