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

java.lang.Object
  extended by org.openstreetmap.osmosis.core.customdb.v0_6.impl.DatasetStoreReader
All Implemented Interfaces:
DatasetContext, Completable, Releasable

public class DatasetStoreReader
extends java.lang.Object
implements DatasetContext

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
 void complete()
          Ensures that all information is fully persisted.
 Node getNode(long id)
          Deprecated. 
 EntityManager<Node> getNodeManager()
          Returns the manager for manipulating node instances.
 Relation getRelation(long id)
          Deprecated. 
 EntityManager<Relation> getRelationManager()
          Returns the manager for manipulating relation instances.
 Way getWay(long id)
          Deprecated. 
 EntityManager<Way> getWayManager()
          Returns the manager for manipulating way instances.
 ReleasableIterator<EntityContainer> iterate()
          Allows the entire dataset to be iterated across.
 ReleasableIterator<EntityContainer> iterateBoundingBox(double left, double right, double top, double bottom, boolean completeWays)
          Allows all data within a bounding box to be iterated across.
 void release()
          Performs resource cleanup tasks such as closing files, or database connections.
 
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

getNode

@Deprecated
public Node getNode(long id)
Deprecated. 

Retrieves a specific node by its identifier.

Specified by:
getNode in interface DatasetContext
Parameters:
id - The id of the node.
Returns:
The node.

getWay

@Deprecated
public Way getWay(long id)
Deprecated. 

Retrieves a specific way by its identifier.

Specified by:
getWay in interface DatasetContext
Parameters:
id - The id of the way.
Returns:
The way.

getRelation

@Deprecated
public Relation getRelation(long id)
Deprecated. 

Retrieves a specific relation by its identifier.

Specified by:
getRelation in interface DatasetContext
Parameters:
id - The id of the relation.
Returns:
The relation.

getNodeManager

public EntityManager<Node> getNodeManager()
Returns the manager for manipulating node instances.

Specified by:
getNodeManager in interface DatasetContext
Returns:
The node manager.

getWayManager

public EntityManager<Way> getWayManager()
Returns the manager for manipulating way instances.

Specified by:
getWayManager in interface DatasetContext
Returns:
The way manager.

getRelationManager

public EntityManager<Relation> getRelationManager()
Returns the manager for manipulating relation instances.

Specified by:
getRelationManager in interface DatasetContext
Returns:
The relation manager.

iterate

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

Specified by:
iterate in interface DatasetContext
Returns:
An iterator pointing to the start of the collection.

iterateBoundingBox

public ReleasableIterator<EntityContainer> iterateBoundingBox(double left,
                                                              double right,
                                                              double top,
                                                              double bottom,
                                                              boolean completeWays)
Allows all data within a bounding box to be iterated across.

Specified by:
iterateBoundingBox in interface DatasetContext
Parameters:
left - The longitude marking the left edge of the bounding box.
right - The longitude marking the right edge of the bounding box.
top - The latitude marking the top edge of the bounding box.
bottom - The latitude marking the bottom edge of the bounding box.
completeWays - If true, all nodes within the ways will be returned even if they lie outside the box.
Returns:
An iterator pointing to the start of the result data.

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