Osmosis/Writing Plugins

From OpenStreetMap Wiki

< Osmosis(Redirected from Osmosis/WritingPlugins)
Jump to: navigation, search

Contents

anatomy of a plugin

A plugin for osmosis consists of

  • one zip-file containing:
  • a file plugin.xml
  • the classes of the plugin

content of plugin.xml

(example plugin.xml)

    <?xml version="1.0" ?>
    <!DOCTYPE plugin PUBLIC "-//JPF//Java Plug-in Manifest 1.0" "http://jpf.sourceforge.net/plugin_1_0.dtd">
    <plugin id="LibOSM" version="1.0">

    	<requires>
    	       <import plugin-id="org.openstreetmap.osmosis.core.plugin.Core" plugin-version="0.30.2" reverse-lookup="false"/>
    	</requires>
<!--these are plugins we require. Usualy only org.openstreetmap.osmosis.core.plugin.Core will be required.-->


    	<runtime>
    		<library id="code" path="/" type="code"/>
    	</runtime>
<!--These are library-files we require including our own code. -->


    	<extension plugin-id="org.openstreetmap.osmosis.core.plugin.Core"
    	           point-id="Task" id="LibOSM/writeOsmBin-Task">
    	   <parameter id="name"
    	           value="writeOsmBin"/>
    	   <parameter id="class"
    		       value="org.openstreetmap.osm.data.osmbin.WriteOSMBinPlugin"/>
         </extension>
<!--This is where our plugin plugs into.
    The extension-point 'task' with a subclass of PluginLoader named 'WriteOSMBinPlugin'
    that tells Osmosis what tasks are provided.-->



   </plugin>

where to plug into

Currently there is only one extension-point task

adding tasks

the plugin-loader

To plug into the extension-point task you need to write one factory-class that extends com.bretth.osmosis.core.plugin.PluginLoader (example).

This class is required for historic reasons.

the TaskManagerFactory

This class contains a method loadTaskFactories() that returns a map from command-line-name to instance of TaskManagerFactory.

Obvisiously you need to write one implementation of com.bretth.osmosis.core.pipeline.common.TaskManagerFactory (example) for every task you want to add. This class is tasked with parsing the command-line arguments, instanciating your task and wrapping it in a TaskManager. For example a com.bretth.osmosis.core.pipeline.v0_5.SinkManager for a task that consumes osm-data.

the Task

Last but not least you need to implement the actual task (example).

Personal tools
Recent changes