Search in sources :

Example 1 with ReleasableIterator

use of org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator in project osmosis by openstreetmap.

the class AllEntityDao method getCurrent.

/**
 * Retrieves all current data in the database.
 *
 * @return An iterator pointing at the current records.
 */
public ReleasableIterator<EntityContainer> getCurrent() {
    try (ReleasableContainer releasableContainer = new ReleasableContainer()) {
        List<ReleasableIterator<EntityContainer>> sources;
        MultipleSourceIterator<EntityContainer> resultIterator;
        sources = new ArrayList<ReleasableIterator<EntityContainer>>();
        sources.add(releasableContainer.add(nodeDao.getCurrent()));
        sources.add(releasableContainer.add(wayDao.getCurrent()));
        sources.add(releasableContainer.add(relationDao.getCurrent()));
        resultIterator = new MultipleSourceIterator<EntityContainer>(sources);
        releasableContainer.clear();
        return resultIterator;
    }
}
Also used : ReleasableContainer(org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) ReleasableIterator(org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator)

Example 2 with ReleasableIterator

use of org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator in project osmosis by openstreetmap.

the class PostgreSqlDatasetContext method iterate.

/**
 * {@inheritDoc}
 */
@Override
public ReleasableIterator<EntityContainer> iterate() {
    List<Bound> bounds;
    List<ReleasableIterator<EntityContainer>> sources;
    if (!initialized) {
        initialize();
    }
    // Build the bounds list.
    bounds = new ArrayList<Bound>();
    bounds.add(new Bound("Osmosis " + OsmosisConstants.VERSION));
    sources = new ArrayList<ReleasableIterator<EntityContainer>>();
    sources.add(new UpcastIterator<EntityContainer, BoundContainer>(new BoundContainerIterator(new ReleasableAdaptorForIterator<Bound>(bounds.iterator()))));
    sources.add(new UpcastIterator<EntityContainer, NodeContainer>(new NodeContainerIterator(nodeDao.iterate())));
    sources.add(new UpcastIterator<EntityContainer, WayContainer>(new WayContainerIterator(wayDao.iterate())));
    sources.add(new UpcastIterator<EntityContainer, RelationContainer>(new RelationContainerIterator(relationDao.iterate())));
    return new MultipleSourceIterator<EntityContainer>(sources);
}
Also used : NodeContainerIterator(org.openstreetmap.osmosis.core.container.v0_6.NodeContainerIterator) WayContainer(org.openstreetmap.osmosis.core.container.v0_6.WayContainer) MultipleSourceIterator(org.openstreetmap.osmosis.core.store.MultipleSourceIterator) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) RelationContainerIterator(org.openstreetmap.osmosis.core.container.v0_6.RelationContainerIterator) ReleasableIterator(org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) WayContainerIterator(org.openstreetmap.osmosis.core.container.v0_6.WayContainerIterator) BoundContainerIterator(org.openstreetmap.osmosis.core.container.v0_6.BoundContainerIterator) RelationContainer(org.openstreetmap.osmosis.core.container.v0_6.RelationContainer) BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer)

Example 3 with ReleasableIterator

use of org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator in project osmosis by openstreetmap.

the class AllEntityDao method getHistory.

/**
 * Retrieves the changes that have were made by a set of transactions.
 *
 * @param predicates
 *            Contains the predicates defining the transactions to be queried.
 * @return An iterator pointing at the identified records.
 */
public ReleasableIterator<ChangeContainer> getHistory(ReplicationQueryPredicates predicates) {
    try (ReleasableContainer releasableContainer = new ReleasableContainer()) {
        List<ReleasableIterator<ChangeContainer>> sources;
        MultipleSourceIterator<ChangeContainer> resultIterator;
        sources = new ArrayList<ReleasableIterator<ChangeContainer>>();
        sources.add(releasableContainer.add(nodeDao.getHistory(predicates)));
        sources.add(releasableContainer.add(wayDao.getHistory(predicates)));
        sources.add(releasableContainer.add(relationDao.getHistory(predicates)));
        resultIterator = new MultipleSourceIterator<ChangeContainer>(sources);
        releasableContainer.clear();
        return resultIterator;
    }
}
Also used : ReleasableContainer(org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) ReleasableIterator(org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator)

Example 4 with ReleasableIterator

use of org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator in project osmosis by openstreetmap.

the class AllEntityDao method getHistory.

/**
 * Retrieves the changes that have were made between two points in time.
 *
 * @param intervalBegin
 *            Marks the beginning (inclusive) of the time interval to be checked.
 * @param intervalEnd
 *            Marks the end (exclusive) of the time interval to be checked.
 * @return An iterator pointing at the identified records.
 */
public ReleasableIterator<ChangeContainer> getHistory(Date intervalBegin, Date intervalEnd) {
    try (ReleasableContainer releasableContainer = new ReleasableContainer()) {
        List<ReleasableIterator<ChangeContainer>> sources;
        MultipleSourceIterator<ChangeContainer> resultIterator;
        sources = new ArrayList<ReleasableIterator<ChangeContainer>>();
        sources.add(releasableContainer.add(nodeDao.getHistory(intervalBegin, intervalEnd)));
        sources.add(releasableContainer.add(wayDao.getHistory(intervalBegin, intervalEnd)));
        sources.add(releasableContainer.add(relationDao.getHistory(intervalBegin, intervalEnd)));
        resultIterator = new MultipleSourceIterator<ChangeContainer>(sources);
        releasableContainer.clear();
        return resultIterator;
    }
}
Also used : ReleasableContainer(org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) ReleasableIterator(org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator)

Example 5 with ReleasableIterator

use of org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator in project osmosis by openstreetmap.

the class AllEntityDao method getHistory.

/**
 * Retrieves all changes in the database.
 *
 * @return An iterator pointing at the identified records.
 */
public ReleasableIterator<ChangeContainer> getHistory() {
    try (ReleasableContainer releasableContainer = new ReleasableContainer()) {
        List<ReleasableIterator<ChangeContainer>> sources;
        MultipleSourceIterator<ChangeContainer> resultIterator;
        sources = new ArrayList<ReleasableIterator<ChangeContainer>>();
        sources.add(releasableContainer.add(nodeDao.getHistory()));
        sources.add(releasableContainer.add(wayDao.getHistory()));
        sources.add(releasableContainer.add(relationDao.getHistory()));
        resultIterator = new MultipleSourceIterator<ChangeContainer>(sources);
        releasableContainer.clear();
        return resultIterator;
    }
}
Also used : ReleasableContainer(org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) ReleasableIterator(org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator)

Aggregations

ReleasableIterator (org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator)8 EntityContainer (org.openstreetmap.osmosis.core.container.v0_6.EntityContainer)5 BoundContainer (org.openstreetmap.osmosis.core.container.v0_6.BoundContainer)4 BoundContainerIterator (org.openstreetmap.osmosis.core.container.v0_6.BoundContainerIterator)4 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)4 NodeContainerIterator (org.openstreetmap.osmosis.core.container.v0_6.NodeContainerIterator)4 RelationContainer (org.openstreetmap.osmosis.core.container.v0_6.RelationContainer)4 RelationContainerIterator (org.openstreetmap.osmosis.core.container.v0_6.RelationContainerIterator)4 WayContainer (org.openstreetmap.osmosis.core.container.v0_6.WayContainer)4 WayContainerIterator (org.openstreetmap.osmosis.core.container.v0_6.WayContainerIterator)4 Bound (org.openstreetmap.osmosis.core.domain.v0_6.Bound)4 ReleasableContainer (org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer)4 MultipleSourceIterator (org.openstreetmap.osmosis.core.store.MultipleSourceIterator)4 ChangeContainer (org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer)3 PGgeometry (org.postgis.PGgeometry)2 Point (org.postgis.Point)2 Polygon (org.postgis.Polygon)2 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 OsmosisRuntimeException (org.openstreetmap.osmosis.core.OsmosisRuntimeException)1