Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-13514

Does $near 2d legacy use degrees or radians as distance measure?

    • Type: Icon: Task Task
    • Resolution: Gone away
    • Priority: Icon: Trivial - P5 Trivial - P5
    • Server_Docs_20231030
    • Affects Version/s: 4.2.3
    • Component/s: Server
    • Labels:
    • Environment:
      windows 10

      Description

      In the below link, I found that $near 2d legacy use radians as distance measure.

      https://docs.mongodb.com/manual/reference/operator/query/near/

      { $near: [ <x>, <y> ], $maxDistance: <distance in radians> }

      However, when I tested queries in the mongo shell, I got confused because it seems like $near 2d legacy use degrees as distance measure.

      1. use degrees

      db.restaurants.find({ 'address.coord' :

      { $near : [ -73.9, 40.7 ], $maxDistance : 2/111.1 }

      } ) #degrees

      2. use radians

      db.restaurants.find({ 'address.coord' :

      { $near : [ -73.9, 40.7 ], $maxDistance : 2/6378.1 }

      } ) #radians

      I checked that the first query with degrees gave correct answer, not the second one with radians.

      Is there anyone who can solve my problem?

       

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

            Assignee:
            Unassigned Unassigned
            Reporter:
            johnjhkim@dbs.snu.ac.kr Juhun Kim
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              1 year, 12 weeks, 1 day ago