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

java.lang.Object
  extended by uk.me.parabola.mkgmap.reader.osm.OsmHandler
Direct Known Subclasses:
Osm5XmlHandler, OsmBinHandler

public class OsmHandler
extends java.lang.Object

Base class for OSM file handlers.

Author:
Steve Ratcliffe

Field Summary
protected  OsmReadingHooks hooks
           
protected  ElementSaver saver
           
 
Constructor Summary
OsmHandler()
           
 
Method Summary
protected  long idVal(java.lang.String id)
          Convert an id as a string to a number.
protected  java.lang.String keepTag(java.lang.String key, java.lang.String val)
          Some tags are dropped at the input stage.
protected  void setBBox(double minlat, double minlong, double maxlat, double maxlong)
          Actually set the bounding box.
 void setElementSaver(ElementSaver elementSaver)
           
 void setHooks(OsmReadingHooks plugin)
           
 void setTagsToDelete(java.util.Map<java.lang.String,java.util.Set<java.lang.String>> deletedTags)
          Set a set of tags with values that are to be deleted on input.
 void setUsedTags(java.util.Set<java.lang.String> used)
          This sets a list of all the tags that are used in the system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

saver

protected ElementSaver saver

hooks

protected OsmReadingHooks hooks
Constructor Detail

OsmHandler

public OsmHandler()
Method Detail

setTagsToDelete

public void setTagsToDelete(java.util.Map<java.lang.String,java.util.Set<java.lang.String>> deletedTags)
Set a set of tags with values that are to be deleted on input. For each key there is a set of values. If the value set is empty then all tags with the given key are deleted. If the value set is not empty then only tags with the given key that has one of the given values are deleted.

Parameters:
deletedTags - A map of tag key, to a set of values to be deleted.

setUsedTags

public void setUsedTags(java.util.Set<java.lang.String> used)
This sets a list of all the tags that are used in the system. Assuming this list is complete, no other tag can have an effect on the output and can therefore be dropped on input. This reduces memory usage, sometimes dramatically if there are many useless tags in the input. We keep a map of tag-name to tag-name. This allows us to keep only a single copy of each string. This also results in a reasonable reduction in memory usage.

Parameters:
used - The complete set of tags that are used to form the output.

keepTag

protected java.lang.String keepTag(java.lang.String key,
                                   java.lang.String val)
Some tags are dropped at the input stage. We drop tags that are not going to be used and there is also an option to provide a file containing tags to be dropped.

Parameters:
key - The tag key.
val - The tag value.
Returns:
Returns the tag key if this tag should be kept. Returns null if the tag should be discarded.

setBBox

protected void setBBox(double minlat,
                       double minlong,
                       double maxlat,
                       double maxlong)
Actually set the bounding box. The boundary values are given.


idVal

protected long idVal(java.lang.String id)
Convert an id as a string to a number. If the id is not a number, then create a unique number instead.

Parameters:
id - The id as a string. Does not have to be a numeric quantity.
Returns:
A long id, either parsed from the input, or a unique id generated internally.

setElementSaver

public void setElementSaver(ElementSaver elementSaver)

setHooks

public void setHooks(OsmReadingHooks plugin)