Lately I’ve been getting questions about why, in Scenic, it’s sometimes necessary to manually edit a route to make it match the GPX track. In order to explain this I need to first lay out how Scenic imports GPX files and why it works the way it does. So, here we go.
Hard to get it right
First of all, Scenic is currently the only app of its kind that can make any GPX track navigable. There is a reason why none of the other apps have attempted this so far. It’s hard to get it right!
What is a GPX track really?
A GPX track (or GPX route for that matter) is, in essence, just an ordered list of coordinates. There is no knowledge of the underlying road network in a GPX. A coordinate can be on a paved road, on a hiker trail or even somewhere in the middle of the ocean. GPX doesn’t know and doesn’t care. With just the GPX you can only connect all the coordinates with a straight line and draw that line on the screen.
In 200 feet turn right…or… in 200 feet take the exit?
To give correct turn by turn (and voice) instructions, knowledge of the underlying road network is required. For example. If the line on screen bends right, you need to know if this is a roundabout, a highway exit, a right turn at a crossing or the road just makes a bend, otherwise you can’t give the correct turn instruction. So, somehow the ordered list of coordinates needs to be ‘snapped’ to the underlying road network. This ‘snapping’ is part of ’calculating’ the route. There is more to the calculation though. Roughly, these are the steps:
- Determine for each point on which road it is located
- Determine the route parts (fastest/shortest roads to get from one point to the next)
- Connect all those route parts together to get the full route
Crash, choke and freeze
As you can imagine, this calculation is not an easy task and requires a lot of performance. So much performance in fact that navigation apps limit the number of via points. For example, at the moment of writing, Google Maps on iOS limits the number of via points (they call it stops) to 10. Sygic limits it to 48 and Navigon to 24.
Scenic currently supports up to 100 via points and I’m working on increasing this to 200, but still a limitation remains. This limitation is the key to the difficulty in making a GPX track navigable. A GPX track typically contains hundreds, often thousands of coordinates. Simply feeding all those coordinates to the route calculation would cause apps to crash, choke or freeze.
The Scenic Trick
So, how does Scenic do it then? Well, Scenic uses a ‘trick’. Before feeding the GPX coordinates to the route calculation Scenic reduces them. This sounds simple, but it really is not. For example you can’t just feed it point number 1, 10, 20, etc. Well, you could, but more often than not this will result in a calculated route that differs a lot from the actual GPX track. Who can guarantee that the calculated route between point 1 and 10 actually passes points 2 through 9 along the way? After all, these ‘intermediate’ points were not fed to the route calculation. So, you need to choose the reduced points carefully in order to ‘force’ the route calculation to take the ‘right’ roads.
Unfortunately, there is no full proof way to do this, but, you can get very close by reducing the points in a ‘smart’ way. In other words, by selectively choosing which points to feed (and which points not to feed) to the route calculation. Scenic does this through, what I call, its ’Scenify’ algorithm. It’s quite complicated but to say it simple, Scenic leaves more points where the line bends and less points where the line is straight (without knowledge of the underlying road network). However, no matter how smart I can make the Scenify algorithm the fact remains that there can never be a 100% guarantee that the route calculation chooses the roads where the intermediate (left out) points are on. And this is what can cause differences between the calculated route and the GPX track. And this is why, if necessary, Scenic allows you to manually add, move or delete via points to make the calculated route match the GPX track exactly.
There is another way of snapping the GPX to the existing road network, without reducing the points, but for that you need to have deep access to the underlying map data. Because Scenic uses a third party map framework this is not possible, but I do imagine this is the method that GPS units like the Garmin’s and TomTom’s use.
I totally get it
Having said all this, I want to emphasise that I totally get why people are asking me about the calculated route not matching the GPX. All the above is not something you should be worried about (or even know about). GPX import should just work!
As we speak I’m working on improving the ‘Scenify’ algorithm and eventually hope to reach a match for nearly 100% of all GPX tracks.
Should you have any questions, feedback or suggestions… they are more than welcome. Feel free to leave a comment below.