how store latitude and longitude in mongodb collection? and How to use it with Spring? how store latitude and longitude in mongodb collection? and How to use it with Spring? mongodb mongodb

how store latitude and longitude in mongodb collection? and How to use it with Spring?


Before you can execute geospatial queries, you need to create a geospatial index:

db.locationcol.createIndex( { loc : "2dsphere" } )

Also, you need to store your locations as valid GeoJSON objects so MongoDB can parse them properly:

loc : { type: "Point", coordinates: [ -76.703347, 30.710459 ] },