I have a car trip data with different car trips. The relevant columns are
- id - varchar(32)
- sequence - integer - resets to 1 for a new car trip
- timestamp - time at which device recorded gps data. It is shown as date in the below pic but assume it as timestamp
- Latitude - numeric
- Longitude
I am trying to find out car trips that are between a particular origin and destination point. If I enter origin as 40.34, 23.5 and destination as 40.75, 23.9 then the output would be as shown in second picture.
The first picture contains 2 car trips namely abc & def. 'abc' took place on December 18th while 'def' took on December 15th so def appears first in the output. The output table is ordered by timestamp column and sequence column and grouped by id. The output should also contain intermediate points between origin and destination.
I am unable to figure out how to find first trips that pass through particular points.
Input:
Output:

