org.openstreetmap.osmosis.core.filter.v0_6
Class AreaFilter

java.lang.Object
  extended by org.openstreetmap.osmosis.core.filter.v0_6.AreaFilter
All Implemented Interfaces:
EntityProcessor, Completable, Releasable, Task, Sink, SinkSource, Source
Direct Known Subclasses:
BoundingBoxFilter, PolygonFilter

public abstract class AreaFilter
extends java.lang.Object
implements SinkSource, EntityProcessor

A base class for all tasks filter entities within an area.

Author:
Brett Henderson, Karl Newman

Constructor Summary
AreaFilter(IdTrackerType idTrackerType, boolean clipIncompleteEntities, boolean completeWays, boolean completeRelations)
          Creates a new instance.
 
Method Summary
 void complete()
          Ensures that all information is fully persisted.
protected abstract  boolean isNodeWithinArea(Node node)
          Indicates if the node lies within the area required.
 void process(BoundContainer boundContainer)
          Process the bound.
 void process(EntityContainer entityContainer)
          Process the entity.
 void process(NodeContainer container)
          Process the node.
 void process(RelationContainer container)
          Process the relation.
 void process(WayContainer container)
          Process the way.
 void release()
          Performs resource cleanup tasks such as closing files, or database connections.
 void setSink(Sink sink)
          Sets the osm sink to send data to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AreaFilter

public AreaFilter(IdTrackerType idTrackerType,
                  boolean clipIncompleteEntities,
                  boolean completeWays,
                  boolean completeRelations)
Creates a new instance.

Parameters:
idTrackerType - Defines the id tracker implementation to use.
clipIncompleteEntities - If true, entities referring to non-existent entities will be modified to ensure referential integrity. For example, ways will be modified to only include nodes inside the area.
completeWays - Include all nodes for ways which have at least one node inside the filtered area.
completeRelations - Include all relations referenced by other relations which have members inside the filtered area.
Method Detail

process

public void process(EntityContainer entityContainer)
Process the entity.

Specified by:
process in interface Sink
Parameters:
entityContainer - The entity to be processed.

process

public void process(BoundContainer boundContainer)
Process the bound.

Specified by:
process in interface EntityProcessor
Parameters:
boundContainer - The bound to be processed.

isNodeWithinArea

protected abstract boolean isNodeWithinArea(Node node)
Indicates if the node lies within the area required.

Parameters:
node - The node to be checked.
Returns:
True if the node lies within the area.

process

public void process(NodeContainer container)
Process the node.

Specified by:
process in interface EntityProcessor
Parameters:
container - The node to be processed.

process

public void process(WayContainer container)
Process the way.

Specified by:
process in interface EntityProcessor
Parameters:
container - The way to be processed.

process

public void process(RelationContainer container)
Process the relation.

Specified by:
process in interface EntityProcessor
Parameters:
container - The relation to be processed.

complete

public void complete()
Ensures that all information is fully persisted. This includes database commits, file buffer flushes, etc. Implementations must call complete on any nested Completable objects. Where the releasable method of a Releasable class should be called within a finally block, this method should typically be the final statement within the try block.

Specified by:
complete in interface Completable

release

public void release()
Performs resource cleanup tasks such as closing files, or database connections. This must be called after all processing is complete and may be called multiple times. Implementations must call release on any nested Releasable objects. It should be called within a finally block to ensure it is called in exception scenarios.

Specified by:
release in interface Releasable

setSink

public void setSink(Sink sink)
Sets the osm sink to send data to.

Specified by:
setSink in interface Source
Parameters:
sink - The sink for receiving all produced data.