How to calculate the distance between many points of GeoJSON in MongoDB? Can I get a database query that sorts items by date field, then calculates the distance between points and finally sums everything to calculate the total distance?
Here are some examples of my data:
{ _id: 599cfc236ed0d81c98007f66 tracerId: 59a07ea26ed0d81d78001acd loc { type: "2dsphere", coordinates: [ 159.9, -37.92 ] }, date: 2017-08-26 00:16:42, speed: 58, } { _id: 59a074d46ed0d81d78001acc tracerId: 59a07ea26ed0d81d78001acd loc { type: "2dsphere", coordinates: [ 160, -38.20 ] }, date: 2017-08-26 00:18:42, speed: 75, } { _id: 59a074d46ed0d81d78ac11cc tracerId: 59a07ea26ed0d81d78001acd loc { type: "2dsphere", coordinates: [ 160.222, -38.92 ] }, date: 2017-08-26 00:20:42, speed: 60, }
source share