com.bretth.osmosis.core.customdb.v0_6.impl
Class DatasetStoreReader

java.lang.Object
  extended by com.bretth.osmosis.core.filter.v0_6.impl.BaseDatasetReader
      extended by com.bretth.osmosis.core.customdb.v0_6.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(RandomAccessObjectStoreReader<Node> nodeObjectReader, IndexStoreReader<java.lang.Long,LongLongIndexElement> nodeObjectOffsetIndexReader, RandomAccessObjectStoreReader<Way> wayObjectReader, IndexStoreReader<java.lang.Long,LongLongIndexElement> wayObjectOffsetIndexReader, RandomAccessObjectStoreReader<Relation> relationObjectReader, IndexStoreReader<java.lang.Long,LongLongIndexElement> relationObjectOffsetIndexReader, TileCalculator tileCalculator, java.util.Comparator<java.lang.Integer> tileOrdering, IndexStoreReader<java.lang.Integer,IntegerLongIndexElement> nodeTileIndexReader, WayTileAreaIndexReader wayTileIndexReader, IndexStoreReader<java.lang.Long,LongLongIndexElement> nodeWayIndexReader, IndexStoreReader<java.lang.Long,LongLongIndexElement> nodeRelationIndexReader, IndexStoreReader<java.lang.Long,LongLongIndexElement> wayRelationIndexReader, IndexStoreReader<java.lang.Long,LongLongIndexElement> relationRelationIndexReader, 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 com.bretth.osmosis.core.filter.v0_6.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(RandomAccessObjectStoreReader<Node> nodeObjectReader,
                          IndexStoreReader<java.lang.Long,LongLongIndexElement> nodeObjectOffsetIndexReader,
                          RandomAccessObjectStoreReader<Way> wayObjectReader,
                          IndexStoreReader<java.lang.Long,LongLongIndexElement> wayObjectOffsetIndexReader,
                          RandomAccessObjectStoreReader<Relation> relationObjectReader,
                          IndexStoreReader<java.lang.Long,LongLongIndexElement> relationObjectOffsetIndexReader,
                          TileCalculator tileCalculator,
                          java.util.Comparator<java.lang.Integer> tileOrdering,
                          IndexStoreReader<java.lang.Integer,IntegerLongIndexElement> nodeTileIndexReader,
                          WayTileAreaIndexReader wayTileIndexReader,
                          IndexStoreReader<java.lang.Long,LongLongIndexElement> nodeWayIndexReader,
                          IndexStoreReader<java.lang.Long,LongLongIndexElement> nodeRelationIndexReader,
                          IndexStoreReader<java.lang.Long,LongLongIndexElement> wayRelationIndexReader,
                          IndexStoreReader<java.lang.Long,LongLongIndexElement> relationRelationIndexReader,
                          boolean enableWayTileIndex)
Creates a new instance.

Parameters:
nodeObjectReader - The raw node objects.
nodeObjectOffsetIndexReader - The node object offsets.
wayObjectReader - The raw way objects.
wayObjectOffsetIndexReader - The way object offsets.
relationObjectReader - The raw relation objects.
relationObjectOffsetIndexReader - The relation object offsets.
tileCalculator - The tile index value calculator.
tileOrdering - The ordering of tiles within the index.
nodeTileIndexReader - The tile to node index.
wayTileIndexReader - The tile to way index.
nodeWayIndexReader - The node to way index.
nodeRelationIndexReader - The node to relation index.
wayRelationIndexReader - The way to relation index.
relationRelationIndexReader - The relation to relation index.
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.