Android Question OSMDroid, POI's and now navigation on rivers - but how?

Mark Read

Well-Known Member
Licensed User
Longtime User
I have a relatively good app with offline maps and poi's read from a gpx file. The only thing that is missing is the navigation function.

I would like to either select two points on the map (not necessarily poi's) and calculate the distance between them, 1 as the crow flies and 2 as a route. The second otion is to enter a starting point and a distance and the end point would be shown.

The main problem is that I need to do this for rivers and canals not roads, as I am traveling by canoe and in this area, there are no roads. There does not seem to be any apps for this, why I ask myself? Has anybody any experience here?
 

warwound

Expert
Licensed User
Longtime User
If you research 'routing engines' you'll find that this is quite an advanced subject.

Your code needs access to spatial data that defines paths that can be taken and then needs to choose the best path.

The only possible solution i can think of involves using the android GraphHopper library.
GraphHopper requires open street map data for the area which routes are to be provided for.
You can download osm data for any area, convert the osm data to the format required by GraphHopper and now in your android code you can get routes within the area covered by the osm data.

I've wrapped an older version of GraphHopper into a b4a library and it works pretty well.
Though as with all routing engines there is a disclaimer not to blindly follow suggested routes as there may be errors which could be dangerous if followed.

Now imagine replacing ther osm road data with river and canal data.
Feed your river and canal data into GraphHopper and (hopefully) GraphHopper will tell you the best route to take.

Fisrt thing you'd need to do is understand how open street map data is structured.
There's loads of into to be found on Google, a starting point could be: http://wiki.openstreetmap.org/wiki/OSM_XML.
Also go to OpenStreetMap, select a small area on the map and then choose to Export the osm data for this area.
It'll let you download an .osm file which if you open in a text editor you will see is just an XML document.
Look at the XML - you'll see how various different geographical features are defined.

So can you learn how osm data is structured and then see how to manually create your own 'rivers and canals' data?
You'd probably have to give your rivers and canals tag values in your XML defining them as roads and streets so GraphHopper sees them as possible routes to take.

Once you have your osm formatted rivers and canals data it can be converted from osm format to a binary format used by GraphHopper and you can use my b4a library to test it, see if it can give your routes using your rivers and canals.

Do some research and if you feel like you want to give it a try let me know.

Martin.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Just had an idea...

Open street map data might already contain your rivers and canals as geographical features - but these features are tagged as rivers, canals, waterways etc and GraphHopper will not use them as possible routes.
If you visit the osm website and select and area containing roads, rivers and canals you might be able to modify it.
Modify it removing all roads and other unwanted routes and then update the XML tags for the rivers and canals defining them as roads or footpaths.

This modified data might now be usable in GraphHopper and produce the results you are after.

Martin.
 
Upvote 0

Mark Read

Well-Known Member
Licensed User
Longtime User
You are correct. In OpenStreetMap, Roads are tagged as highways and rivers as waterway/river.

A problem is that I am using your OSMDroid library and have already downloaded 68000 tiles for the map area which I need offline. A tile file has a compressed format which I cannot read. Even if I could read the files in XML format, It would take some real number crunching to rename "Highways" to something else and "waterway" to highways. But the idea is a good one!

I wondered if it would be possible to somehow read the pixel colors on the map and create my own navigation algorithm. What do you think?
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
I wondered if it would be possible to somehow read the pixel colors on the map and create my own navigation algorithm. What do you think?

Build your own routing engine which works without any real spatial data, just using the color of pixels to determine a route?
I think that's impossible BUT don't be put off.

Martin.
 
Upvote 0

Mark Read

Well-Known Member
Licensed User
Longtime User
@warwound: Just had to bump this thread Martin. I was not put off. It has taken me months to get this working. I used the A-Star algorithm and now have a working routing program for rivers. Its not perfect (Still losing the first marker) but here is a screen shot. Using the emulator, this takes about 20 seconds. The impossible we can do, its the miracles which take longer!
 

Attachments

  • route.jpg
    route.jpg
    241.7 KB · Views: 304
Upvote 0
Top