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

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

    XMLWordPrintable

Details

    • Feedback
    • Status: Open
    • Trivial - P5
    • Resolution: Unresolved
    • 4.2.3
    • None
    • Code Examples
    • windows 10

    Description

      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.)

      Attachments

        Activity

          People

            Unassigned Unassigned
            johnjhkim@dbs.snu.ac.kr Juhun Kim
            Ravind Kumar Ravind Kumar (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              2 years, 15 weeks, 4 days ago