I am a newbie in MongoDB. Can anyone tell me how I can create a simple GeoJSON object ? I will be working with GeoSpatial queries hence I need some basic help with creating a GeoJSON object using Java Mongo driver.
2 Answers
Try the SpringData Mongo driver. It has methods in the Criteria object to create the kind of query you want:
The official Java driver for MongoDB is really not very good. The equivalent JavaScript commands are distributed unevenly across the Java API, and sometimes you're required to do what @Sambhav-Sharma says: just pass MongoDB operators as strings.
2 Comments
user3559051
The Mongo doc refers to "legacy coordinate pairs" a lot. Is it not correct to use them with Lat and Long replacing x and y?
mttdbrd
The "legacy coordinate pairs" refers to the format of point coordinates before Mongo 2.4. It was a planar system. Mongo now supports spherical and 2d. Legacy is version 1 of the "2dsphere."