org.openstreetmap.osmosis.core.pgsql.v0_5.impl
Class PostgreSqlDatasetReader

java.lang.Object
  extended by org.openstreetmap.osmosis.core.pgsql.v0_5.impl.PostgreSqlDatasetReader
All Implemented Interfaces:
DatasetReader, Releasable

public class PostgreSqlDatasetReader
extends java.lang.Object
implements DatasetReader

Provides read-only access to a PostgreSQL dataset store. Each thread accessing the store must create its own reader. It is important that all iterators obtained from this reader are released before releasing the reader itself.

Author:
Brett Henderson

Constructor Summary
PostgreSqlDatasetReader(DatabaseLoginCredentials loginCredentials, DatabasePreferences preferences)
          Creates a new instance.
 
Method Summary
 Node getNode(long id)
          Retrieves a specific node by its identifier.
 Relation getRelation(long id)
          Retrieves a specific relation by its identifier.
 Way getWay(long id)
          Retrieves a specific way by its identifier.
 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

PostgreSqlDatasetReader

public PostgreSqlDatasetReader(DatabaseLoginCredentials loginCredentials,
                               DatabasePreferences preferences)
Creates a new instance.

Parameters:
loginCredentials - Contains all information required to connect to the database.
preferences - Contains preferences configuring database behaviour.
Method Detail

getNode

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

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

getWay

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

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

getRelation

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

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

iterate

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

Specified by:
iterate in interface DatasetReader
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 DatasetReader
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.

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