在 mongoDB 中有一个名为 geoNear 的命令,它返回数据库中地理空间点存储的距离。此外,当我在 mongoDB 中使用 find 函数时,我可以使用一个 near 过滤器来返回数据库中位于 maxDistance 范围内的寄存器,例如:
db.collection.find( { localizacion:{ $near: { $geometry: { type: "Point", coordinates: [lng, lat]}}, $maxDistance: 1000}}).
该语句返回 DB 中距离 [lng, lat] 1000 米内的寄存器。
那么,MySQL中有类似的吗?
谢谢。
最佳答案
SELECT * WHERE st_distance_sphere(point_column, POINT(lng, lat)) < 1000
引用资料:
https://dev.mysql.com/doc/refman/en/spatial-convenience-functions.html#function_st-distance-sphere
https://dev.mysql.com/doc/refman/en/gis-mysql-specific-functions.html#function_point
关于mysql - 在 MySQL 中从 mongoDB 模拟 geoNear 或 near,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19335439/