[osmosis-dev] Android?

Brett Henderson brett at bretth.com
Fri Nov 9 04:55:00 GMT 2012


Hi Adrià,

On 9 November 2012 07:37, Adrià Ribatallada Torelló
<achtungwolf at gmail.com>wrote:

> Thank you Brett, I'v followed your advice and tried to remove the JPF from
> a local clone of the osmosis source, and adapted the plugin I need to use
> the osmosis-plugins.conf.
>
> And all compiles good and fine, and if I execute the command I need using
> the bin/osmosis script in my machine all goes fine.
>
> But in the Android device I need to do it from the code (or so I think),
> calling Osmosis.run(args) or Osmosis.main() I presume, and there is where
> it fails now...
>
> That's the code I'm trying to run:
>
>         File pbfFile = new
> File(Environment.getExternalStorageDirectory()+"/download/"+"in.osm.pbf");
> File outFile = new
> File(Environment.getExternalStorageDirectory()+"/download/"+"out.map");
>
> Osmosis.main(new String[] {
> "--read-pbf file="+pbfFile,
>  "--mapfile-writer file="+outFile
> });
>
> That's my pretty error:
>
> 11-08 19:53:16.148: W/System.err(3090): 2012 11 8 19:53:16
> org.openstreetmap.osmosis.core.Osmosis run
> 11-08 19:53:16.148: W/System.err(3090): INFO: Osmosis Version
> 0.40.1-3-gbd9521a-dirty
> 11-08 19:53:16.638: W/System.err(3090): 2012 11 8 19:53:16
> java.io.BufferedReader <init>
> 11-08 19:53:16.638: W/System.err(3090): INFO: Default buffer size used in
> BufferedReader constructor. It would be better to be explicit if an 8k-char
> buffer is required.
> 11-08 19:53:16.718: W/System.err(3090): 2012 11 8 19:53:16
> org.openstreetmap.osmosis.core.Osmosis run
> 11-08 19:53:16.718: W/System.err(3090): INFO: Preparing pipeline.
> 11-08 19:53:16.758: W/System.err(3090): 2012 11 8 19:53:16
> org.openstreetmap.osmosis.core.Osmosis main
> 11-08 19:53:16.758: W/System.err(3090): SEVERE: Execution aborted.
> 11-08 19:53:16.758: W/System.err(3090): Throwable occurred:
> org.openstreetmap.osmosis.core.OsmosisRuntimeException: Task type read-pbf
> file=/mnt/sdcard/download/in.osm.pbf doesn't exist.
>
> I assume that is thrown because the envirenoment it's not well configured,
> but I don't know how to "do the same" that does the script from my program
> code :P
>
> I'v tried to run the classworlds.Launcher, but I didn't suceed there...
>
> Can some of you help me understand what needs to be done "programatically"
> to setup the environment?
>

Simply calling main should be okay, but you'll need to configure the
classpath beforehand.  That's what the classworlds launcher does for you.
During startup, Osmosis scans the classpath for all instances of
osmosis-plugins.conf and uses them to dynamically register plugins.  If it
doesn't find the pbf plugin (ie. the pbf jar file isn't on the application
classpath) then you'll see the missing task error.

Brett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/osmosis-dev/attachments/20121109/bd9c4b85/attachment.html>


More information about the osmosis-dev mailing list