OsmAnd script

121 views
Skip to first unread message

Werner Horsch

unread,
Apr 6, 2013, 5:48:28 PM4/6/13
to osm...@googlegroups.com
Does someone has a script which creates an osmand map out of a .pbf file?
thanks

Harry van der Wolf

unread,
Apr 7, 2013, 5:11:37 AM4/7/13
to osm...@googlegroups.com
When you ask for a script I assume you are on Mac OS X, Linux, {free}{net}{open}bsd, solaris or some other linux/unix like OS.

I have two scripts: One that downloads and converts a whole bunch of osm.pbf files and one that specifically only downloads and converts netherlands.osm.pbf, as the first ran for days on a lot of osm.pbf files.

<code>
#!/bin/sh

WORK_FOLDER="/opt/OpenStreetMap"

# First download all the data
cd "$WORK_FOLDER/osm_files"
echo "Now in `pwd`\n"
rm *
wget -v -O Netherlands_europe_2.osm.pbf "http://download.geofabrik.de/europe/netherlands-latest.osm.pbf"
#wget -v -O Luxembourg_europe_2.osm.pbf "http://download.geofabrik.de/europe/luxembourg-latest.osm.pbf"
#wget -v -O Belgium_europe_2.osm.pbf "http://download.geofabrik.de/europe/belgium-latest.osm.pbf"

cd $WORK_FOLDER
echo `date` > starttime.txt
echo "Now converting from osm.pbf to osmand obf\n"
cd "$WORK_FOLDER/OsmAndMapCreator"

java -Djava.util.logging.config.file=logging.properties -Xms256M -Xmx2560M -cp "./OsmAndMapCreator.jar:./lib/OsmAnd-core.jar:./lib/*.jar" net.osmand.data.index.IndexBatchCreator ./batch.xml

cd $WORK_FOLDER
echo `date` > endtime.txt

echo "And finally moving the obf files from the index folder to the osmandmaps folder\n"
mv index_files/*.obf osmandmaps/
</code>


I have a work folder (variable in the top of the script) which contains the subfolders "osm_files", "index_files", "osmandmaps" and OsmAndMapCreator. The last contains of course the osmandmapcreator software.
You really need to run osmandmapcreator from it's own folder (unless you want to set all things in your environment which I don't want).
The luxembourg and belgium remarks give you other options as well, replace for your maps (Germany?, Austria?).
I use wget -O to give the downloaded file another name as I download the latest osm.pbf from geofabrik and want the name to be the same as OsmAnd likes it to have.

Make sure that your batch.xml contains the correct folder paths. It is the line:
        <process directory_for_osm_files="/opt/OpenStreetMap/osm_files" directory_for_index_files="/opt/OpenStreetMap/index_files" directory_for_generation="/opt/OpenStreetMap/osmandmap"
If you want to leave the original batch.xml as it is your can also create a copy and modify that, e.g. mybatch.xml and specify that one in the script.

The starttime.txt and endtime.txt are just created as I want to know how long the process took.

Harry



2013/4/6 Werner Horsch <werner...@gmail.com>
Does someone has a script which creates an osmand map out of a .pbf file?
thanks

--
You received this message because you are subscribed to the Google Groups "Osmand" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osmand+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Victor Shcherb

unread,
Apr 7, 2013, 11:09:42 AM4/7/13
to osmand
Hi,

This is very nice response! I guess this question becomes more and more popular and it is worth to mention it in our wiki pages https://code.google.com/p/osmand/wiki/. Probably as new technical article. 
@Harry
If you don't mind please copy & polish it a bit to our wiki pages ( I added you as a contributor with your gmail account).

Thanks,
Victor

Harry van der Wolf

unread,
Apr 7, 2013, 3:37:36 PM4/7/13
to osm...@googlegroups.com
I will do that early next week: Monday or Tuesday.

Harry

2013/4/7 Victor Shcherb <victor....@gmail.com>

Harry van der Wolf

unread,
Apr 9, 2013, 10:35:47 AM4/9/13
to osm...@googlegroups.com
Hi,
 
I wanted to start this but I also came upon http://code.google.com/p/osmand/wiki/HowToPrepareYourOwnDataToUseOffline. As such this is fine. It needs an extra link to the "command line" article.
Another article however is the <http://code.google.com/p/osmand/wiki/OsmandMapUpdates> under "Technical Articles".
Do you want a small article within this article?
or a separate article where both articles point towards each other for reference?
 
Harry

2013/4/7 Harry van der Wolf <hvd...@gmail.com>

Victor Shcherb

unread,
Apr 9, 2013, 11:37:26 AM4/9/13
to osm...@googlegroups.com
I think it is worth to update OsmandMapUpdates because it contains some information about General System setup and it would be useful to have it there.


Regards,
Victor
Reply all
Reply to author
Forward
0 new messages