How to populate a Tree with flat JSON?

How can I query this JSON tree in MongoDB?

  • {     "_id" : "4f316a0e29d7f51720b03251",     "totalTime" : 1717000,     "totalDistance" : 13246.551,     "segments" :     [         {             "totalTime" : 1717000,             "totalDistance" : 13246.551,             "wayPoints" : [                                 {                                     "type" : "",                                     "time" : 1326171013000,                                     "latitude" : 17.41122,                                     "longitude" : 89.48969                                 }                             ]         }     ] } 1.I'm using the above JSON doc to store a gps track. 2.I'm using MongoDB to store all the tracks. 3.A single track will have multilple segments. 4.Each segment will have hundreads of GPS waypoints. 5.Then I want to go for a specific segment of a track and get waypoints between a time range. 6. Finally, I would like to know your opinion on using MongoDB/NoSql for saving JSON tracks like above, assuming the in future there will be huge number of tracks to be saved in to DB. Thanks

  • Answer:

    You might consider using GeoJSON to define your waypoints. You can use a LineString GeoJSON encoding to define your track & waypoints. http://docs.mongodb.org/manual/core/2dsphere/ Note that GeoJSON support is new in 2.4, and earlier versions only support point types.

Jared Rosoff at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.