geoNear 拉取不准确的结果 MongoDB

geoNear pulling inacurate results in MongoDB

在我的数据库中有评论,每个评论都有每个国家/地区的 Long Lat,但是 MongoDB 给出的结果不准确,即我提供巴西 [Lon Lat] 作为查询中的输入

 db.posts.aggregate([ { "$geoNear": {

         "near": [-69.7145414,-13.6574511 ],
         "spherical": true,
         "distanceField": "distance",
         "num":1000000,
        "query":{"post_id":"5efc430e25a363375860e842",}
     }},
     {
        "$sort":{"distance":1}
     } ])

我得到的结果是

  1. 玻利维亚(距巴西409.5公里)
  2. 巴拉圭(距巴西1293公里)
  3. 秘鲁(距巴西1645公里)
  4. 圭亚那(距巴西1188公里)

you can see that

Distance calculated using this website: https://www.movable-type.co.uk/scripts/latlong.html

我使用的经纬度如下

"Bolivia" => [
    "latitude" => -16.0705819,
    "longitude" => -72.5931926
],
"Paraguay" => [
    "latitude" => -23.3601858,
    "longitude" => -62.9462413
],
"Peru" => [
    "latitude" => -9.1084506,
    "longitude" => -84.0750546
],
"Guyana" => [
    "latitude" => 4.9392707,
    "longitude" => -63.4541328
],
"Brazil" => [
    "latitude" => -13.6574511,
    "longitude" => -69.7145414
]

These Latitude/Longitude get using with this link: https://www.google.com/maps/place/Brazil/@-13.6574511,-69.7145414,4z/data=!3m1!4b1!4m5!3m4!1s0x9c59c7ebcc28cf:0x295a1506f2293e63!8m2!3d-14.235004!4d-51.92528

我想我明白了为什么我变得不准确 distance/results,虽然这不是我的问题的解决方案,但现在我知道了原因如果有人知道最好的原因或解决方案那么我在等等,谢谢

MongoDB assumes earth is perfect sphere and uses average radius of earth to calculate distance between two points. But as you know earth is not sphere but more sort of Ellipsoid so distance calculation will not be perfect but approximate in MongoDB. However, Google uses a very complex formula to get better results. They do have huge database of radius of the earth at different locations on earth.