DE:Osmosis/Writing Plugins

From OpenStreetMap Wiki
Jump to: navigation, search
Verfügbare Sprachen
Deutsch English


Contents

Aufbau eines Plugins

Ein Osmosis-Plugin besteht aus:

  • einem Zip-Archiv
    • einer Datei plugin.xml
    • den Klassen des Plugins

Inhalt von 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="2.5.2.0"
    class="org.openstreetmap.osm.Plugins.LibOSMOsmosisPlugin">
    <requires>
           <import plugin-id="org.openstreetmap.osmosis.core.plugin.Core" plugin-version="0.32" reverse-lookup="false"/>
    </requires>
    <runtime>
        <library id="mycode" path="/" type="code"/>
 	</runtime>
    <extension plugin-id="org.openstreetmap.osmosis.core.plugin.Core"
               point-id="Task" id="LibOSM/OsmBin-Tasks/writeOsmBin">
       <parameter id="name"
               value="writeOsmBin"/>
       <parameter id="class"
               value="org.openstreetmap.osm.data.osmbin.OSMBinPlugin"/>
        </extension>
<!--	<extension plugin-id="org.openstreetmap.osmosis.core.plugin.Core"
               point-id="Task" id="LibOSM/OsmBin-Tasks/writeOsmBin-0.6">
       <parameter id="name"
               value="writeOsmBin-0.6"/>
       <parameter id="class"
               value="org.openstreetmap.osm.data.osmbin.OSMBinPlugin"/>
        </extension>-->
</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
Namespaces

Variants
Actions
site
Toolbox