I'm currently working on a project for my computer science study. The goal is to make a service that allows the user to enter a distance and elevation change which will then result in a random route (either with the starting point being the endpoint at the same time or not).
Our "stakeholder" wants the routes to always be different so it doesn't get boring while he's jogging / biking haha.
My current progress:
- I wrote a small library in golang to calculate the elevation at a certain gps coordinate (with SRTM data). -> It's not relevant right now, just FYI :)
- I loaded the OSM file of switzerland into a local postgres DB, which is working. (I'm using the SRID 21781 for switzerland). --> I was able to calculate a distance between two points but it's just a direct line without respecting streets etc.
My idea is to make some kind of a grid with a distance of 20 - 50 meters between all the points (looking like a chess board haha). Then I calculate the distance between those points by choosing different lines (I'm thinking of the table planet_osm_line). Like that I can slowly build up a route. Since the elevation change in those 20-50 meters isn't rapidly growing, I could take the average elevation between A and B to get an overall elevation difference.
I saw that there is a tool called pgRouting. But as far as I've seen, it calculates a route between two points with Dijkstras algorithm (which wouldn't help me get a route with length x, but the shortest one).
I'm not sure if this is a good approach and how I should actually realize it with the PostGIS tool.
Do you guys have some tips that can guide me in the right direction?