My understanding is that following shell command will create the offline file for germany using germany-latest.osm.pbf from graphhoper-ios-sample.
FILE=germany-latest.osm.pbf JAVA_OPTS="-Xmx4096m -Xms1000m -server" ./graphhopper-ios-sample/import-sample.sh
# if a large file is imported, JAVA_OPTS may need to be changed
When I run
./graphhopper-ios-sample/import-sample.sh
This created default romanian graph-data.osm-gh and corresponding actual map file at graph-data.osm.pbf.
How do I make import different country files to standalone zip files with graph-data.osm-gh folder and corresponding osm.pbf? Above germany command did not create a germany-data.osm.pbf file and germany-data.osm-gh folder. Can graphhoper support switching between different maps at runtime? If so, can someone show the code for it?
Take a look at ./graphhopper-ios-sample/import-sample.sh (doesn’t let me post links for some reason). Basically this script downloads the files from http://download.geofabrik.de/europe/$FILE.
To import files from a different source you can do a git checkout 0.6.0 (or a different branch), run the ./graphhopper.sh import $GRAPH_FILE command and bring back graphhopper with git checkout ios-compat.
However you can import the graph from the main GraphHopper repo, the import script is just a sample to give you a starting point.
The graph folder gets created in ./graphhopper/graph-data.osm-gh, from where it is included in the Xcode project of the sample app, if you look.
The import-sample.sh it’s just a sample script, you can (and should) create your own to do the import. Just remember to checkout a different branch if you use the ./graphhopper/ project since it’s checked out on ios-compat branch, which doesn’t allow you to do imports.
#!/usr/bin/env bash
cd graphhopper
if [ -z ${FILE+x} ]; then
FILE="romania-latest.osm.pbf"
fi
GRAPH_FILE="graph-data.osm.pbf"
if [ ! -e $FILE ] && [ ! -e $GRAPH_FILE ]; then
echo "Downloading http://download.geofabrik.de/europe/$FILE"
curl -O http://download.geofabrik.de/europe/$FILE
fi
if [ ! -e $GRAPH_FILE ]; then
mv $FILE $GRAPH_FILE
fi
rm -rf $(expr $GRAPH_FILE : '\([^\.]*\)\.')".osm-gh"
git checkout 0.6.0-RC1
./graphhopper.sh import $GRAPH_FILE
git checkout alternate_route2
cd ..
touch class.list
I use above code with alternate_route2 instead of ios-compat branch as you recommended. However this does not download the default albenia file graph-data.osm.pbf but it updates graph-data.osm-gh folder. Can I zip those two files into a folder and make standalone map by each different country?
By the way this is the only place I found out refering to the both folder graph-data.osm-gh and graph-data.osm.pdf file in Directions.m code:
For Offline predownloaded maps mode, should I concentrate only on the Offline Map Viewer code? What I am not understanding is where offlineMapDatabases points to above graph-data folder and osm-gh file?
Two maps is currently not supported (although you could merge two areas) or was your intend to switch between two GraphHopper instances? (That should work)
Hi, Karussell,
How would I merge two areas to support switching between different maps at run-time? Can please explain to us what is the difference between case 7 in ViewController.m and case 6 ?
Create two GraphHopper instances e.g. load from two maps and then decide per request which to query. There is no inbuilt mechanism or something. Still I recommend to merge while import as with two separate areas you cannot search across boundaries. Also see: https://github.com/graphhopper/graphhopper/issues/293
Are you refering to graph-data.osm-gh folder where the routing query database reside which this hopper uses? By the way, does the .map file just used for getting lat long coordinates that is passed via annotation in route method:
Yes, this is where you would init multiple instances of GraphHopper.
Note that _mapView is an instance of mbxmapkit used only for allowing the sample app to display a map easily. In the sample app description, it says that the only interesting code related to GraphHopper is in Directions.m.