I'm currently in the process of developing a carsharing app, and when it comes to setting up rides, I have this kind of data structure stored in my database:
{
"_id": "YyPpkCDhTKStGw6CL",
"authorId": "W6zvbcqit4Mw6a2iK",
"stages": [
{
"caption": "Paris, France",
"type": "Point",
"coordinates": [
2.3522219000000177,
48.856614
]
},
{
"caption": "Lyon, France",
"type": "Point",
"coordinates": [
4.835659,
45.764043
]
},
{
"caption": "Toulouse, France",
"type": "Point",
"coordinates": [
1.4442090000000007,
43.604652
]
}
],
}
The stages are arranged in the required sequence (Paris -> Lyon -> Toulouse). I have a basic form with two input fields (start and end). My query is: How can I identify the closest ride?
It appears that I need to do something along these lines:
Identify rides where:
- stages.X close to start
- stages.Y close to end
- X < Y
Do you have any thoughts on how I can execute such a search?