在MongoDB中如何测量$ maxDistance? [英] How is $maxDistance measured in MongoDB?

查看:155
本文介绍了在MongoDB中如何测量$ maxDistance?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎找不到此信息.但是,使用地理搜索可以指定$maxDistance,但是对于我自己的生命,我找不到这是英里,公里等.

I can't seem to find this information. But using a geo search you can specify $maxDistance but for the life of me, I can't find if that is miles, kilometers, etc.

这是我正在使用的示例查询:

Here is a sample query I'm using:

db.hotels.find( { location: { $near : [18.74255, 99.03523], $maxDistance : 0.05 } } ).count()

从我的酒店数据库中返回15.

Returns 15 (from my hotels database).

感谢您提供任何信息.

推荐答案

除非您要进行球形查询(例如$nearSphere),否则MongoDB实际上并不关心单位,它只是将您的位置视为笛卡尔坐标.

Unless you're doing a spherical query (like $nearSphere), MongoDB doesn't actually care about units, it just treats your locations as Cartesian coordinates.

因此,无论您输入的单位是多少,计算出的距离都将是.由于您的$near点看起来像标准的经度/纬度,因此在这种情况下,$maxDistance将以度为单位.

So, the calculated distance is going to be in whatever your input units were. Since your $near point looks like standard lat/long, the $maxDistance in this case will be in units of degrees.

这篇关于在MongoDB中如何测量$ maxDistance?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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