MongoDB find km radius

I have a collection named User and Shop

Collection User

id: 1
name: "Jack"
address: "San Jose, CA"
location: Object
    type: "Point"
    coordinates: [ 11.1111, 11.1111 ] // sample coordinates
hobby: "Tennis"

id: 2
name: "Robert"
address: "San Francisco, CA"
location: Object
    type: "Point"
    coordinates: [ 22.2222, 22.2222 ] // sample coordinates
hobby: "Swimming"

Collection Shop

id: 1
name: "Jollibee"
address: "Los Angeles, CA"
location: Object
    type: "Point"
    coordinates: [ 22.3333, 33.3333 ] // sample coordinates

id: 2
name: "MCDO"
address: "Sacramento, CA"
location: Object
    type: "Point"
    coordinates: [ 22.3333, 33.3333 ] // sample coordinates

id: 3
name: "Burger King"
address: "San Diego, CA"
location: Object
    type: "Point"
    coordinates: [ 33.3333, 22.3333 ] // sample coordinates

I want to query when the user open the app. He/She will only see the shop within 10km radius.

Example. Jack will only see Jollibee and MCDO in his 10km radius. Robert will only see Burger King in his 10km radius.



from Recent Questions - Stack Overflow https://ift.tt/33gr7yn
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations