I've written code in Java using the Osmosis framework and specifically OsmosisReader for Java, for OSM processing.
As far as I understand, OsmosisReader can only work with *.pbf
files, which means I need to convert .osm
files before using them (which I'm currently doing with osmconvert).
Is there a way to use other OSM formats with OsmosisReader? And if not, is there a way to convert the file format through the code (preferably with Osmosis)?
The osmosis-xml
package offers the XmlReader
class. It can be used to read OSM data in XML-based formats (.osm, .osm.bz2 and .osm.gz).
Both OsmosisReader
and XmlReader
implement the RunnableSource
interface, so you can go through that interface if you want your code to support multiple input formats.