org.openstreetmap.osmosis.core.customdb.v0_5.impl
Class DatasetStoreReader

java.lang.Object
  extended by org.openstreetmap.osmosis.core.filter.v0_5.impl.BaseDatasetReader
      extended by org.openstreetmap.osmosis.core.customdb.v0_5.impl.DatasetStoreReader
All Implemented Interfaces:
DatasetReader, Releasable

public class DatasetStoreReader
extends BaseDatasetReader

Provides read-only access to a dataset store. Each thread accessing the store must create its own reader. The reader maintains all references to heavyweight resources such as file handles used to access the store eliminating the need for objects such as object iterators to be cleaned up explicitly.

Author:
Brett Henderson

Constructor Summary
DatasetStoreReader(NodeStorageContainer nodeStorageContainer, WayStorageContainer wayStorageContainer, RelationStorageContainer relationStorageContainer, boolean enableWayTileIndex)
          Creates a new instance.
 
Method Summary
 Node getNode(long id)
          Retrieves a specific node by its identifier.
protected  ReleasableIterator<java.lang.Long> getNodeIdsForTileRange(int minimumTile, int maximumTile)
          Returns all nodes that are contained within the specified tile range.
 Relation getRelation(long id)
          Retrieves a specific relation by its identifier.
protected  ReleasableIterator<java.lang.Long> getRelationIdsOwningNode(long nodeId)
          Returns all relations that contain the specified node.
protected  ReleasableIterator<java.lang.Long> getRelationIdsOwningRelation(long relationId)
          Returns all relations that contain the specified relation.
protected  ReleasableIterator<java.lang.Long> getRelationIdsOwningWay(long wayId)
          Returns all relations that contain the specified way.
 Way getWay(long id)
          Retrieves a specific way by its identifier.
protected  ReleasableIterator<java.lang.Long> getWayIdsForTileRange(int minimumTile, int maximumTile)
          Returns all ways that are contained within the specified tile range.
protected  ReleasableIterator<java.lang.Long> getWayIdsOwningNode(long nodeId)
          Returns all ways that contain the specified node.
protected  boolean isTileWayIndexAvailable()
          Indicates if a tile index is available for ways or if a node to way index must be used instead.
 ReleasableIterator<EntityContainer> iterate()
          Allows the entire dataset to be iterated across.
 void release()
          Performs resource cleanup tasks such as closing files, or database connections.
 
Methods inherited from class org.openstreetmap.osmosis.core.filter.v0_5.impl.BaseDatasetReader
iterateBoundingBox
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatasetStoreReader

public DatasetStoreReader(NodeStorageContainer nodeStorageContainer,
                          WayStorageContainer wayStorageContainer,
                          RelationStorageContainer relationStorageContainer,
                          boolean enableWayTileIndex)
Creates a new instance.

Parameters:
nodeStorageContainer - The node storages.
wayStorageContainer - The way storages.
relationStorageContainer - The relation storages.
enableWayTileIndex - If true a tile index is created for ways, otherwise a node-way index is used.
Method Detail

getNodeIdsForTileRange

protected ReleasableIterator<java.lang.Long> getNodeIdsForTileRange(int minimumTile,
                                                                    int maximumTile)
Returns all nodes that are contained within the specified tile range.

Specified by:
getNodeIdsForTileRange in class BaseDatasetReader
Parameters:
minimumTile - The minimum tile to match.
maximumTile - The maximum tile to match.
Returns:
The list of node ids.

getWayIdsForTileRange

protected ReleasableIterator<java.lang.Long> getWayIdsForTileRange(int minimumTile,
                                                                   int maximumTile)
Returns all ways that are contained within the specified tile range.

Specified by:
getWayIdsForTileRange in class BaseDatasetReader
Parameters:
minimumTile - The minimum tile to match.
maximumTile - The maximum tile to match.
Returns:
The list of way ids.

getWayIdsOwningNode

protected ReleasableIterator<java.lang.Long> getWayIdsOwningNode(long nodeId)
Returns all ways that contain the specified node.

Specified by:
getWayIdsOwningNode in class BaseDatasetReader
Parameters:
nodeId - The node for which to retrieve parent ways.
Returns:
The list of way ids.

getRelationIdsOwningNode

protected ReleasableIterator<java.lang.Long> getRelationIdsOwningNode(long nodeId)
Returns all relations that contain the specified node.

Specified by:
getRelationIdsOwningNode in class BaseDatasetReader
Parameters:
nodeId - The node for which to retrieve parent relations.
Returns:
The list of relation ids.

getRelationIdsOwningWay

protected ReleasableIterator<java.lang.Long> getRelationIdsOwningWay(long wayId)
Returns all relations that contain the specified way.

Specified by:
getRelationIdsOwningWay in class BaseDatasetReader
Parameters:
wayId - The way for which to retrieve parent relations.
Returns:
The list of relation ids.

getRelationIdsOwningRelation

protected ReleasableIterator<java.lang.Long> getRelationIdsOwningRelation(long relationId)
Returns all relations that contain the specified relation.

Specified by:
getRelationIdsOwningRelation in class BaseDatasetReader
Parameters:
relationId - The relation for which to retrieve parent relations.
Returns:
The list of relation ids.

isTileWayIndexAvailable

protected boolean isTileWayIndexAvailable()
Indicates if a tile index is available for ways or if a node to way index must be used instead.

Specified by:
isTileWayIndexAvailable in class BaseDatasetReader
Returns:
True if a tile index is available for ways.

getNode

public Node getNode(long id)
Retrieves a specific node by its identifier.

Parameters:
id - The id of the node.
Returns:
The node.

getWay

public Way getWay(long id)
Retrieves a specific way by its identifier.

Parameters:
id - The id of the way.
Returns:
The way.

getRelation

public Relation getRelation(long id)
Retrieves a specific relation by its identifier.

Parameters:
id - The id of the relation.
Returns:
The relation.

iterate

public ReleasableIterator<EntityContainer> iterate()
Allows the entire dataset to be iterated across.

Returns:
An iterator pointing to the start of the collection.

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.