Obtain the distance from the geonear command of MongoDB's Geospatial Index

Source: Internet
Author: User

Previously, I wrote down the search method based on the index. For details, see MongoDB's Geospatial index. I haven't completed this yet. I just finished the overall search here.Code, Hitting the ground and writing this article. The find query can only sort poi points by distance based on 2D coordinates. After querying the list, you have to calculate the distance yourself. Actually, developers will definitely think about this, now that the sorting function is available, there must be data at a distance. Refer to these two videos, pretty good, English is not good, listen to many times watching the document, understand: http://www.10gen.com/presentations/mongosf-2011/geospatial-indexing-mongodb http://www.10gen.com/presentations/mongosf2011/wordsquared geonear command, is based on DB command, rather than based on collection of find, that is, it needs to be executed through runcommand. The specific syntax is as follows: DB. runcommand ({geonear: "collectionname", near: [120.123456, 30.654321], num: 10}) explains this command: query the collection of geonear, 10 records closest to the specified point in near, is it easy? Results: {"NS": "POI. collectionname", "near": "1100110000001111110000001111110000001111110000001111", "results": [{"DIS "... Continue reading→

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.