org.openstreetmap.josm.data.osm.visitor
Class MergeSourceBuildingVisitor

java.lang.Object
  extended by org.openstreetmap.josm.data.osm.visitor.AbstractVisitor
      extended by org.openstreetmap.josm.data.osm.visitor.MergeSourceBuildingVisitor
All Implemented Interfaces:
Visitor

public class MergeSourceBuildingVisitor
extends AbstractVisitor

MergeSourceBuildingVisitor helps to build the "hull" of a collection of OsmPrimitives which shall be merged into another layer. The "hull" is slightly bigger than the original collection. It includes, for instance the nodes of a way in the original collection even though these nodes might not be present explicitly in the original collection. The "hull" also includes incomplete OsmPrimitives which are referred to by relations in the original collection. And it turns OsmPrimitive referred to by Relations in the original collection into incomplete OsmPrimitives in the "hull", if they are not themselves present in the original collection.


Field Summary
private  DataSet hull
           
private  java.util.HashMap<OsmPrimitive,PrimitiveData> mappedPrimitives
           
private  DataSet selectionBase
           
 
Constructor Summary
MergeSourceBuildingVisitor(DataSet selectionBase)
          Creates the visitor.
 
Method Summary
 DataSet build()
           
protected  void buildHull()
           
protected  boolean isAlreadyRemembered(OsmPrimitive primitive)
           
protected  boolean isInSelectionBase(OsmPrimitive primitive)
           
protected  void rememberIncomplete(OsmPrimitive primitive)
           
protected  void rememberNode(Node n)
          Remebers a node in the "hull"
protected  void rememberRelation(Relation r)
          Remembers a relation in the hull
protected  void rememberRelationPartial(Relation r)
           
protected  void rememberWay(Way w)
          remembers a way in the hull
 void visit(Node n)
          Visiting call for points.
 void visit(Relation r)
          Visiting call for relations.
 void visit(Way w)
          Visiting call for lines.
 
Methods inherited from class org.openstreetmap.josm.data.osm.visitor.AbstractVisitor
visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

selectionBase

private DataSet selectionBase

hull

private DataSet hull

mappedPrimitives

private java.util.HashMap<OsmPrimitive,PrimitiveData> mappedPrimitives
Constructor Detail

MergeSourceBuildingVisitor

public MergeSourceBuildingVisitor(DataSet selectionBase)
                           throws java.lang.IllegalArgumentException
Creates the visitor. The visitor starts to build the "hull" from the currently selected primitives in the dataset selectionBase, i.e. from DataSet.getSelected().

Parameters:
selectionBase - the dataset. Must not be null.
Throws:
java.lang.IllegalArgumentException - thrown if selectionBase is null
Method Detail

isInSelectionBase

protected boolean isInSelectionBase(OsmPrimitive primitive)

isAlreadyRemembered

protected boolean isAlreadyRemembered(OsmPrimitive primitive)

rememberNode

protected void rememberNode(Node n)
Remebers a node in the "hull"

Parameters:
n - the node

rememberWay

protected void rememberWay(Way w)
remembers a way in the hull

Parameters:
w - the way

rememberRelation

protected void rememberRelation(Relation r)
Remembers a relation in the hull

Parameters:
r - the relation

rememberRelationPartial

protected void rememberRelationPartial(Relation r)

rememberIncomplete

protected void rememberIncomplete(OsmPrimitive primitive)

visit

public void visit(Node n)
Description copied from interface: Visitor
Visiting call for points.

Parameters:
n - The node to inspect.

visit

public void visit(Way w)
Description copied from interface: Visitor
Visiting call for lines.

Parameters:
w - The way to inspect.

visit

public void visit(Relation r)
Description copied from interface: Visitor
Visiting call for relations.

Parameters:
r - The relation to inspect.

buildHull

protected void buildHull()

build

public DataSet build()


JOSM