I have a problem with finding routes that are near (in range X km) the passed points (for e.x. A and B) in PostgreSQL PostGIS.
The point A denotes Source point and The point B denotes the Destination.
Tn system there are routes represented as LineString. I am also able to consider another ways to represent the routes.
Phere is no problem to find routes contains the points A and B in specific range (for e.x. 5 km):
SELECT * FROM routes WHERE ST_Distance_Spheroid(route.lineString, 'POINT (long_A lat_A)', 'SPHEROID["GRS 1980",6378137,298.257222101]') < 5000 AND ST_Distance_Spheroid(route.lineString, 'POINT (long_B lat_B)', 'SPHEROID["GRS 1980",6378137,298.257222101]') < 5000
But there is the problem, that this query considers the path regardless its direction. It is insensitive to order the points that describes the linestring.
So there is a question. How select the routes contains points in specific range and consider order of points.
BTW: There is possible to represent routes as points and store in database the POINT and order number. So I can look for nearest points.