uk.me.parabola.mkgmap.reader.osm
Interface OsmReadingHooks

All Known Implementing Classes:
HighwayHooks, OsmReadingHooksAdaptor, OsmReadingHooksChain, SeaGenerator

public interface OsmReadingHooks

Allows common code to be called during the reading of OSM files in both their XML and binary formats. You should only use this when you need access to other ways or nodes or the IDs of the individual points that go into a way, which are no longer available during conversion. This is the stage before conversion from the node/way/tag format to the general intermediate format. Most operations should be done during that conversion process, which is accessible from the style file language. We also want access to the other ways/nodes to generate sea polygons, cycle lanes and so on.

Author:
Steve Ratcliffe

Method Summary
 void end()
          Called after the file has been read.
 java.util.Set<java.lang.String> getUsedTags()
          Retrieves the tags that are used by this hook.
 boolean init(ElementSaver saver, EnhancedProperties props)
          Passes in the element saver and the command line options.
 void onAddNode(Node node)
          Called on adding a node to the saver and just before it is added.
 void onAddWay(Way way)
          Add the given way.
 void onCoordAddedToWay(Way way, long coordId, Coord co)
          This is called whenever a node is added to a way.
 

Method Detail

init

boolean init(ElementSaver saver,
             EnhancedProperties props)
Passes in the element saver and the command line options. The hook code can use the options to set itself up if needed. The saver gives access to the previously saved nodes/ways/relations and also allows you to add extra ways.

Parameters:
saver - This is where all the elements are being collected. You can access previously added elements from here by their id. You can also add generated elements. You must not add the element that is being passed in as it will be added automatically.
props - The command line options.
Returns:
If you return false then this set of hooks will not be used. So if they are not needed based on the options supplied you can disable it.

getUsedTags

java.util.Set<java.lang.String> getUsedTags()
Retrieves the tags that are used by this hook. Tags that are used only if they are referenced in the style file should not be added to this list.

Returns:
the tag names used by this hook

onAddNode

void onAddNode(Node node)
Called on adding a node to the saver and just before it is added. You can modify it, create new nodes etc.

Parameters:
node - The node to be added.

onAddWay

void onAddWay(Way way)
Add the given way. The way must be complete, call after the end tag is seen for the XML format.

Parameters:
way - The osm way.

onCoordAddedToWay

void onCoordAddedToWay(Way way,
                       long coordId,
                       Coord co)
This is called whenever a node is added to a way. A node is something with tags, not just a Coord. The way will not have been added via addWay() yet. The node is the node that

Parameters:
way - The incomplete way.
coordId - The coordinate id of the node that is being added.
co - The coordinate.

end

void end()
Called after the file has been read. Can be used to add more elements to the saver based on information stored up.