[osmosis-dev] Maven artifacts, using Osmosis as a library, OSMembrane
Igor Podolskiy
igor.podolskiy at vwi-stuttgart.de
Mon Nov 28 14:37:45 GMT 2011
Hi Andrew, hi everybody,
> I see that there has also been some discussion on the list about using
> Osmosis as a library (quoted message below). Igor, based on a quick look
> at PipelineExecutor in the head revision of OSMembrane, it looks like
> you are calling Osmosis as an external program.
yes, OSMembrane spawns off an external process. This is partly the
heritage of OSMembrane being a student project, partly it's a deliberate
decision. For example, Osmosis can potentially consume lots of memory,
and you don't want your pipeline chewing off large chunks of the
pipeline designer process' memory. You might want to control how much
memory Osmosis gets (-Xmx...), which is not necessarily the same amount
you want OSMembrane to have. So while the whole roundtrip of generating
a command line just to feed it back to the Osmosis command line parser
can (and probably should) be avoided, OSMembrane will always spawn a new
Java VM with an Osmosis pipeline, independent of the degree of
integration. That being said, it's no requirement imposed by Osmosis,
it's an OSMembrane thing - so if you want an Osmosis pipeline in your
OTP process, just do it :)
> Are you still planning
> to tighten the integration with Osmosis? What has been your experience
> using Osmosis in this way?
Yes, planning... unfortunately, I have not nearly as much time for it as
I would like to :(
In any case, using Osmosis as a library is fairly easy - although
there's no complete tutorial for that, the Osmosis' very own unit tests
are basically a blueprint of what you should be doing. For example, look
at [1].
At the very basic level, you instantiate the entity processors you need
(objects implementing Sink, Source and SinkSource interfaces) and feed
them the EntityContainers somehow. If you read from an XML/PBF/etc. data
source already supported by Osmosis, you can use the reader Sources
shipped with Osmosis; if you want to feed it data directly from your
code, you'll have to write your own Source or RunnableSource. Similarly,
at the other end of the pipeline, you'll need to install a Sink of some
kind. For an example of this, take a look at the SinkEntityInspector
which simply buffers up every EntityContainer it gets in a
List<EntityContainer> [2].
I hope I could tip you off in the right direction - if you have
questions about Osmosis integration or OSMembrane, just ask them here,
I'll try to help.
Greetings from Stuttgart,
Igor
[1]
https://github.com/openstreetmap/osmosis/blob/master/set/src/test/java/org/openstreetmap/osmosis/set/v0_6/MergeBoundTest.java
[2]
https://github.com/openstreetmap/osmosis/blob/master/set/src/test/java/org/openstreetmap/osmosis/test/task/v0_6/SinkEntityInspector.java
More information about the osmosis-dev
mailing list