# Route creation with specific length and elevation change [closed]

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?

## closed as too broad by Andre Silva, xunilk, Jochen Schwarze, LaughU, whyzarFeb 25 at 14:15

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Are you interested in elevation change along a route or on a grid? Or both, it's not entirley clear. There is an algortithm called R2 viewshed that if quite efficient for doing grid based viewsheds. – John Powell Feb 23 at 15:13
• I thought of calculating elevation change along a route. The grid I was talking about is just the way I would set "waypoints", between which I calculate the route (In my opinion a grid would make it easy to write an algorithm that increases the route distance for every point in the grid. I hope that makes it a bit clearer. Otherwise I'll try to explain more :) – Lukas Zbinden Feb 23 at 17:45
• The grid is indeed the best way to do it. R2 viewshed algorithm being one example. – John Powell Feb 25 at 9:54