MongoDB地理距离/半径(以有用单位为单位) [英] MongoDB geo distance/radius to useful units

查看:149
本文介绍了MongoDB地理距离/半径(以有用单位为单位)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MongoDB地理空间查询-$neargeoNear等-并且我想知道如何转换geoNear命令的dis结果以及<$within查询往返于诸如英里或公里之类的可读单位的c4>参数.

I'm using MongoDB geospatial queries -- $near, geoNear, etc. -- and I'd like to know how to turn the dis result of the geoNear command as well as the radius argument for $within queries to/from readable units like miles or kilometers.

推荐答案

如果数据以地理坐标表示(即30.47921 N -121.45724 W),则需要将基础投影转换为所需的单位(选择一个保留距离),或者您需要将坐标中的距离转换为英里.

if your data is in geographic coordinates (i.e. 30.47921 N -121.45724 W) then you need to convert your underlying projection with the units you want (choose a projection that preserves distance) or you need to convert the distance in coordinates to something like miles.

使用Haversine公式进行计算 http://www.movable-type.co.uk/scripts/latlong. html

Use the Haversine formula for calculations http://www.movable-type.co.uk/scripts/latlong.html

这篇关于MongoDB地理距离/半径(以有用单位为单位)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆