I'm trying to develop an android app to work with offline maps. Thanks to some help, i've created the map, and i've been able to load the maps offline.
Now i'm trying to create routes, but i havent understood quite well how to do it.
If i'm correct, i have to use an osm file that has node's, way's and relation's like described here.
My question is, how can i load this file's data to my app? I haven't been able to find any example of how to load this data to an app. All i've discovered is that this osm file can be converted to a smaller pbf file.
Can anyone explain me how to use this osm data? Can anyone give me an example? Or am i taking a wrong approach?
This code loads a OSM file with 700kb, but it doenst load mine because it has 99MB.
// create the factory
SAXParserFactory factory = SAXParserFactory.newInstance();
// create a parser
SAXParser parser = factory.newSAXParser();
// create the reader (scanner)
XMLReader xmlreader = parser.getXMLReader();
// assign our handler
xmlreader.setContentHandler(osmHandler);
xmlInputStream = context.getResources().openRawResource(R.raw.lisboa);
//xmlInputStream = context.getResources().openRawResource(R.raw.milano);
//xmlInputStream = new FileInputStream(new File(Environment.getExternalStorageDirectory()+File.separator+"MyMaps","Lissabon.osm"));
xmlreader.parse(new InputSource(xmlInputStream));
osmHandler.isLoaded=true;
I'm using osmbonuspack_v3.4 and osmdroid_3.0.10.
Thanks
Take a look at Graphhopper library. As of now this seems to be the best library available for routing of OSM data in android.
https://github.com/graphhopper/graphhopper/blob/master/docs/android/index.md