uk.me.parabola.mkgmap.reader.osm
Class ElementSaver

java.lang.Object
  extended by uk.me.parabola.mkgmap.reader.osm.ElementSaver
Direct Known Subclasses:
CoastlineElementSaver

public class ElementSaver
extends java.lang.Object

This is where we save the elements read from any of the file formats that are in OSM format. OSM format means that there are nodes, ways and relations and they have tags. Both the XML format and the binary format use this. In the early days of mkgmap, the nodes and ways were converted as soon as they were encountered in the input file. After relations that is not possible, you have to save up all the nodes and ways as they might be needed for relations. We also want access to the other ways/nodes to generate sea polygons, prepare for routing etc.

Author:
Steve Ratcliffe

Field Summary
static java.lang.String MKGMAP_REMOVE_TAG
          name of the tag that contains a ;-separated list of tagnames that should be removed after all elements have been processed
static java.lang.String MKGMAP_REMOVE_TAG_ALL_KEY
          tagvalue of the MKGMAP_REMOVE_TAG if all tags should be removed
 
Constructor Summary
ElementSaver(EnhancedProperties args)
           
 
Method Summary
 void addNode(Node node)
          Add the given node and save it.
 void addPoint(long id, Coord co)
           We use this to calculate a bounding box in the situation where none is given.
 void addRelation(Relation rel)
          Add the given relation.
 void addWay(Way way)
          Add the given way.
 void convert(OsmConverter converter)
          After the input file is read, this is called to convert the saved information into the general intermediate format.
 Relation createMultiPolyRelation(Relation rel)
          Create a multipolygon relation.
 SeaPolygonRelation createSeaPolyRelation(Relation rel)
           
 void deferRelation(long id, Relation rel, java.lang.String role)
           
 void finishLoading()
           
 Area getBoundingBox()
          Get the bounding box.
 Coord getCoord(long id)
           
 Node getNode(long id)
           
 Relation getRelation(long id)
           
 Way getWay(long id)
           
 java.util.Map<java.lang.Long,Way> getWays()
           
 void setBoundingBox(Area bbox)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MKGMAP_REMOVE_TAG

public static final java.lang.String MKGMAP_REMOVE_TAG
name of the tag that contains a ;-separated list of tagnames that should be removed after all elements have been processed

See Also:
Constant Field Values

MKGMAP_REMOVE_TAG_ALL_KEY

public static final java.lang.String MKGMAP_REMOVE_TAG_ALL_KEY
tagvalue of the MKGMAP_REMOVE_TAG if all tags should be removed

See Also:
Constant Field Values
Constructor Detail

ElementSaver

public ElementSaver(EnhancedProperties args)
Method Detail

addPoint

public void addPoint(long id,
                     Coord co)
We use this to calculate a bounding box in the situation where none is given. In the usual case where there is a bounding box, then nothing is done.

Parameters:
co - The point.

addNode

public void addNode(Node node)
Add the given node and save it. The node should have tags.

Parameters:
node - The osm node.

addWay

public void addWay(Way way)
Add the given way.

Parameters:
way - The osm way.

addRelation

public void addRelation(Relation rel)
Add the given relation.

Parameters:
rel - The osm relation.

createMultiPolyRelation

public Relation createMultiPolyRelation(Relation rel)
Create a multipolygon relation. Has to be here as they use shared maps. Would like to change how the constructor works so that was not needed.

Parameters:
rel - The original relation, that the result will replace.
Returns:
A new multi polygon relation, based on the input relation.

createSeaPolyRelation

public SeaPolygonRelation createSeaPolyRelation(Relation rel)

setBoundingBox

public void setBoundingBox(Area bbox)

getCoord

public Coord getCoord(long id)

getNode

public Node getNode(long id)

getWay

public Way getWay(long id)

getRelation

public Relation getRelation(long id)

finishLoading

public void finishLoading()

convert

public void convert(OsmConverter converter)
After the input file is read, this is called to convert the saved information into the general intermediate format.

Parameters:
converter - The Converter to use.

getWays

public java.util.Map<java.lang.Long,Way> getWays()

getBoundingBox

public Area getBoundingBox()
Get the bounding box. This is either the one that was explicitly included in the input file, or if none was given, the calculated one.


deferRelation

public void deferRelation(long id,
                          Relation rel,
                          java.lang.String role)