Android Question OpenStreetMap using .PBF?

adrianstanescu85

Active Member
Licensed User
Longtime User
Hello,

I'd like to ask if there's a solution to use the maps from OpenStreetMap project using directly the .PBF files (offline) that are freely available for download.

For instance, http://download.geofabrik.de/europe.html has every country in Europe being updated daily in that vector format so using such a file would give an immense advantage over the OsmDroid tiles approach, which may be downloaded or generated but take up a huge amount of space and time.

I would also like to ask if using the alternative SHP or OSM formats is possible in a similar way, if PBF is not (which I would expect).

Any info over this please?

Thank you!
Adrian
 
Last edited:

Spinter

Active Member
Licensed User
Longtime User
C:\osmosis\bin\osmosis --rb file=friuli-venezia-giulia.osm --mapfile-writer file=friuli-venezia-giulia.map type=hd


B4X:
C:\Users\Spinter>C:\osmosis\bin\osmosis --rb file=friuli-venezia-giulia.osm --ma
pfile-writer file=friuli-venezia-giulia.map type=hd
mar 09, 2014 2:49:11 PM org.openstreetmap.osmosis.core.Osmosis run
Informazioni: Osmosis Version 0.43.1
mar 09, 2014 2:49:11 PM org.java.plugin.registry.xml.ManifestParser <init>
Informazioni: got SAX parser factory - org.apache.xerces.jaxp.SAXParserFactoryIm
pl@93837b
mar 09, 2014 2:49:11 PM org.java.plugin.registry.xml.PluginRegistryImpl configur
e
Informazioni: configured, stopOnError=false, isValidating=true
mar 09, 2014 2:49:11 PM org.java.plugin.registry.xml.PluginRegistryImpl register

Informazioni: plug-in and fragment descriptors registered - 1
mar 09, 2014 2:49:11 PM org.java.plugin.standard.StandardPluginManager activateP
lugin
Informazioni: plug-in started - [email protected]
.42-6-gf39a160-dirty
mar 09, 2014 2:49:11 PM org.openstreetmap.osmosis.core.Osmosis run
Informazioni: Preparing pipeline.
java.io.FileNotFoundException: friuli-venezia-giulia.osm (Impossibile trovare il
file specificato)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(Unknown Source)
        at crosby.binary.osmosis.OsmosisReaderFactory.createTaskManagerImpl(Osmo
sisReaderFactory.java:39)
        at org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory.cre
ateTaskManager(TaskManagerFactory.java:60)
        at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.buildTasks(Pi
peline.java:50)
        at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.prepare(Pipel
ine.java:112)
        at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:86)
        at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Laun
cher.java:329)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:239)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
mar 09, 2014 2:49:11 PM org.openstreetmap.osmosis.core.Osmosis main
Grave: Execution aborted.
org.openstreetmap.osmosis.core.OsmosisRuntimeException: Task type mapfile-writer
doesn't exist.
        at org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactoryRegi
ster.getInstance(TaskManagerFactoryRegister.java:60)
        at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.buildTasks(Pi
peline.java:50)
        at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.prepare(Pipel
ine.java:112)
        at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:86)
        at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Laun
cher.java:329)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:239)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:47)








I always generates an error that can not find the source file!
and what is the position you want to copy the file italy.osm
 
Upvote 0

adrianstanescu85

Active Member
Licensed User
Longtime User
Do you have your friuli-venezia-giulia.osm file inside your C:\osmosis\bin\osmosis folder? Because that's where it looks for that file...
 
Upvote 0

Spinter

Active Member
Licensed User
Longtime User
Do you have your friuli-venezia-giulia.osm file inside your C:\osmosis\bin\osmosis folder? Because that's where it looks for that file...
Yes!!


C:\osmosis\bin\osmosis --rb file=albania-latest.osm.pbf --mapfile-writer file=test.map type=hd
for test I also tried to download albania-latest.osm.pbf but I always return the same error!
 
Upvote 0

Spinter

Active Member
Licensed User
Longtime User
C:\osmosis\bin\osmosis --rb file=albania-latest.osm.pbf --mapfile-writer file=test.map type=hd
for test I also tried to download albania-latest.osm.pbf but I always return the same error!
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
C:\osmosis\bin\osmosis --rb file=friuli-venezia-giulia.osm --mapfile-writer file=friuli-venezia-giulia.map type=hd

In your original post you have an error.
You're trying to convert an XML file friuli-venezia-giulia.osm but using the osmosis --rb parameter which is the read binary file parameter.
To read an XML file you need to use the --rx parameter:

B4X:
C:\osmosis\bin\osmosis --rx file=friuli-venezia-giulia.osm --mapfile-writer file=friuli-venezia-giulia.map type=hd

Look here, the list of 'Built in tasks' documents the available command line parameters.

Martin.
 
Upvote 0

Spinter

Active Member
Licensed User
Longtime User
Windows 7 osmosis 0.43.1


1)osmosis installed in C:\osmosis
2)Friuli-Venezia-copied files in the bin folder giulia.osm
3)copied the file mapsforge-map-writer-0.3.0.jar and mapsforge-map-writer-0.3.0-jar-with-dependencies.jar in the folder created C:\Users\Spinter\Application Data\OpenStreetMap\Osmosis\Plugins


4)cmd: C:\osmosis\bin\osmosis --rx file=friuli-venezia-giulia.osm --mapfile-writer file=friuli-venezia-giulia.map type=hd

B4X:
Microsoft Windows [Versione 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Tutti i diritti riservati.

C:\Users\Spinter>C:\osmosis\bin\osmosis --rx file=friuli-venezia-giulia.osm --ma
pfile-writer file=friuli-venezia-giulia.map type=hd
mar 12, 2014 5:18:03 PM org.openstreetmap.osmosis.core.Osmosis run
Informazioni: Osmosis Version 0.43.1
mar 12, 2014 5:18:03 PM org.java.plugin.registry.xml.ManifestParser <init>
Informazioni: got SAX parser factory - org.apache.xerces.jaxp.SAXParserFactoryIm
pl@10cc730
mar 12, 2014 5:18:03 PM org.java.plugin.registry.xml.PluginRegistryImpl configur
e
Informazioni: configured, stopOnError=false, isValidating=true
mar 12, 2014 5:18:03 PM org.java.plugin.registry.xml.PluginRegistryImpl register

Informazioni: plug-in and fragment descriptors registered - 1
mar 12, 2014 5:18:03 PM org.java.plugin.standard.StandardPluginManager activateP
lugin
Informazioni: plug-in started - [email protected]
.42-6-gf39a160-dirty
mar 12, 2014 5:18:03 PM org.openstreetmap.osmosis.core.Osmosis run
Informazioni: Preparing pipeline.
mar 12, 2014 5:18:03 PM org.openstreetmap.osmosis.core.Osmosis main
Grave: Execution aborted.
org.openstreetmap.osmosis.core.OsmosisRuntimeException: Task type mapfile-writer
doesn't exist.
        at org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactoryRegi
ster.getInstance(TaskManagerFactoryRegister.java:60)
        at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.buildTasks(Pi
peline.java:50)
        at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.prepare(Pipel
ine.java:112)
        at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:86)
        at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Laun
cher.java:329)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:239)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:47)


where am I doing wrong missing anything?
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
It's can't find the mapwriter plugin i think:

org.openstreetmap.osmosis.core.OsmosisRuntimeException: Task type mapfile-writer
doesn't exist.

Not sure why, the path you say you have the plugin installed to looks ok according to the documentation.

Martin.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User

Shame on Windows - it can't even be easily set up to use osmosis and the mapfile-writer!
Here on Ubuntu the conversion originally failed...

Osmosis required a bbox parameter as the friuli-venezia-giulia.osm.bz2 data doesn't contain that data.
If you visit: http://www.openstreetmap.org/export#map=9/46.1170/13.1204 and click the Export you'll see the min and max latitude and longitude values i used in the osmosis command line.

With the bbox parameters added to the command line it soon converted your data to a mapsforge database.

Here's the mapsforge database: http://b4a.martinpearman.co.uk/mapsforge/friuli-venezia-giulia.map.

Martin.
 
Upvote 0

PABLO2013

Well-Known Member
Licensed User
Longtime User
Greetings Martin

is possibility combining .map with a shapefile ... how i could make, or programs can be used.

only through osmosis i can edit a .map or there are programs for Windows, .... in terms how I convert pbf to .map

i download my map from http://download.bbbike.org/osm/ , but i can not get cycle map .

do you have a another place similar to the previous http to download .map

i can combining data from wms server whith . map or convert wms rester maps to vectorial maps

thx
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
I seem to remember that Osmosis can be used to combine various vector map files into a single new vector map file but can't be sure.
Take a look here: http://wiki.openstreetmap.org/wiki/Category:Osmosis
Look through the various links and examples and see if you can see any 'combine' options.

You could look for a .map download here: http://www.androidmaps.co.uk/
The map downloads available on that link have the 'coastline fix' - when rendered they properly display the coast instead of displaying some coastal areas as blank.
 
Upvote 0

PABLO2013

Well-Known Member
Licensed User
Longtime User
Martin regards
Might publish your mapsforge samples apk in b4a code, because I tried to check on different devices and falls ... would be very helpful to learn some new techniques on this topic maps and others ... thanks
 
Upvote 0

PABLO2013

Well-Known Member
Licensed User
Longtime User
regards

i contact you to consult about osmosis and mapsforge-write plugin:

1. how this osmosis and plugin is installed in windows.

2. how installed the plugin in osmosis for Acknowledge this within your command line ... i not understand.

3. how I can convert .pbf to . map ... if you have a command line osmosis that works.

I have reviewed many forums and nothing even B4A ... and the information is unclear, there are also maps that let you trim from the internet and save in .map but I need to edit and then save (this is my big problem)

thank you advanced
 
Upvote 0

PABLO2013

Well-Known Member
Licensed User
Longtime User
Greetings




After reading several forums this is what I think works:

1. Download: osmosis-latest


2. Unzip eg: C:\osmosis


3. copy a plugin such as: mapsforge-map-writer-0.5.0-jar-with-dependencies.jar in c: \ osmosis \ lib \ default \, at this point one should copy a version of this plugin **once**, but osmosis give an error.


4. verify that C: \ osmosis \ config \ plexus.conf:

......................................................................................
main is org.openstreetmap.osmosis.core.Osmosis from osmosis.core
[Osmosis.core]
app.home load $ {} / lib / default / *. jar
app.home load $ {} / config
.................................................. .......................................
This is place where osmosis will read our plugin ((load app.home} $ {/ lib / default / *. jar))

5. No do this because it gives an error or overload osmosis:
..................................................................................................................
Put the jar plugin into the $ OSMOSIS_HOME / lib / default directory and add the org.openstreetmap.osmosis.plugin.elasticsearch.elasticsearchWriterPluginLoader (full namespace of your plugin loader) line into the $ OSMOSIS_HOME / config / osmosis-plugins.conf file ( create it if Necessary).
.................................................................................................................
or
.................................................................................................................
Also You can edit the $ OSMOSIS_HOME / config / plexus.conf and add it to load line: such as $ {app.home} / lib / plugins / *. Jar with $ {app.home} / lib / plugins / directory container containing your plugin.
..................................................................................................................

6. Use a .bat file to indicate something like this:
.................................................................................................................
osmosis ^

--read-pbf file="/C:/osmosis/bin/mapa.pbf" outPipe.0=1 ^

--bounding-box left=-83 right=-84 top=9.5 bottom=9 completeWays=true completeRelations=true clipIncompleteEntities=true inPipe.0=1 outPipe.0=2 ^

--mapfile-writer file="/C:/osmosis/bin/mapa.map" inPipe.0=2

..............................................................................................................
or
...............................................................................................................
osmosis ^

--read-pbf file="/C:/osmosis/bin/mapa.pbf" outPipe.0=1 ^

--bounding-box left=-85.5 right=-81 top=10.5 bottom=8.5 inPipe.0=1 outPipe.0=2 ^

--mapfile-writer file="/C:/osmosis/bin/mapa.map" inPipe.0=2

................................................................................................................

6. Import is: --bounding-box, but osmosis and plugin fails, it can also be ... --read-pbf or --read-xml....

I hope it serves
 
Upvote 0

PABLO2013

Well-Known Member
Licensed User
Longtime User
GREETINGS MARTIN
AS I DO TO GET A COPY OF A MAP " mapcycle " .
AS I UNDERSTAND " mapcycle " IS THE SAME INFORMATION TO OSM, AND WHAT MAY VARY IS rendering, IS THIS SO OR NOT AND HOW CAN I HAVE THIS " mapcycle " .
THANKS
 
Upvote 0

PABLO2013

Well-Known Member
Licensed User
Longtime User
GREETINGS MARTIN
CAN BE CONVERTED TO A FILE Garmin .IMG TO OSM ( return it ) ... I SAY BECAUSE I CAN DOWNLOAD FROM www.geofabrik.de A MAP " mapcycle ", BUT IN GARMIN FORMAT IMG.

THANKS
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Why are you screaming????
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
PABLO,
CAN YOU EXACTLY DESCRIBE WHAT YOUR WANT TO DO? may be there are other solutions then to download the osm data?

stefan
 
Upvote 0
Top