[osmosis-dev] Android?

Adrià Ribatallada Torelló achtungwolf at gmail.com
Fri Nov 23 12:09:28 GMT 2012


Hi folks!

I forgot to thank you all for your help!

At the end I got it working in the phone.

The last problem i commented was my mistake (a shamefully idiotic one)
when passing the parameters to the run method I wasn't separating the
strings correctly and the commandline parser complained to that (as
natural).

So in resume, if the JPF (as Brett suggested) is "deactivated" the
osmosis tool is able to run on an android device (at least some of the
tasks/plugins).

Provided that some minor modifications are done to the lib jar's to
avoid repeated files in the final apk. That's basically removing the
repeated osmosis-plugin.conf file present in the plugins jars, and
then, of course, force the loading of that plugins via the run args
(using -plugin option).

That's probably not a very good solution, because it demands to modify
the source of osmosis, and at the end the idea of running osmosis in
the phone is not very useful to anyone, since processing the data in
the phone is really slow and has plenty of limitations (due to android
limitations I presume), and most of the time prforming the task on a
server or on a local computer  is the smartest way to do it.

But just to let you know, it works.

Thanks!

Sincerely,

Adrià Ribatallada i Torelló.

2012/11/9 Brett Henderson <brett at bretth.com>
>
> 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
>



-- 
    _____   _______   ________
   / ಠ_ಠ | |  ಠ_ಠ  \ |__ ಠ_ಠ__|
  / /    | |  |    /    |  |
 /  __   | |   _   \    |  |   _
/__/  |__| |__|  \ _\   |__|  |_|



More information about the osmosis-dev mailing list