Search in sources :

Example 81 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class EntityDao method getEntityHistory.

private ReleasableIterator<EntityHistory<T>> getEntityHistory(String selectedEntityStatement, MapSqlParameterSource parameterSource) {
    ReleasableContainer releasableContainer;
    releasableContainer = new ReleasableContainer();
    try {
        ReleasableIterator<EntityHistory<T>> entityIterator;
        ReleasableIterator<DbFeatureHistory<DbFeature<Tag>>> tagIterator;
        List<FeatureHistoryPopulator<T, ?, ?>> featurePopulators;
        EntityHistoryReader<T> entityHistoryReader;
        entityIterator = releasableContainer.add(getFeaturelessEntityHistory(selectedEntityStatement, parameterSource));
        tagIterator = releasableContainer.add(getTagHistory(selectedEntityStatement, parameterSource));
        featurePopulators = getFeatureHistoryPopulators(selectedEntityStatement, parameterSource);
        for (FeatureHistoryPopulator<T, ?, ?> featurePopulator : featurePopulators) {
            releasableContainer.add(featurePopulator);
        }
        entityHistoryReader = new EntityHistoryReader<T>(entityIterator, tagIterator, featurePopulators);
        // The sources are now all attached to the history reader so we don't want to release
        // them in the finally block.
        releasableContainer.clear();
        return entityHistoryReader;
    } finally {
        releasableContainer.close();
    }
}
Also used : ReleasableContainer(org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer) DbFeatureHistory(org.openstreetmap.osmosis.core.database.DbFeatureHistory) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Example 82 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class EntityDao method getTagHistory.

private ReleasableIterator<DbFeatureHistory<DbFeature<Tag>>> getTagHistory(String selectedEntityStatement, MapSqlParameterSource parameterSource) {
    FileBasedSort<DbFeatureHistory<DbFeature<Tag>>> sortingStore = new FileBasedSort<DbFeatureHistory<DbFeature<Tag>>>(new SingleClassObjectSerializationFactory(DbFeatureHistory.class), new DbFeatureHistoryComparator<Tag>(), true);
    try {
        String sql;
        SortingStoreRowMapperListener<DbFeatureHistory<DbFeature<Tag>>> storeListener;
        DbFeatureHistoryRowMapper<DbFeature<Tag>> dbFeatureHistoryRowMapper;
        DbFeatureRowMapper<Tag> dbFeatureRowMapper;
        TagRowMapper tagRowMapper;
        ReleasableIterator<DbFeatureHistory<DbFeature<Tag>>> resultIterator;
        sql = "SELECT et." + entityName + "_id AS id, et.k, et.v, et.version" + " FROM " + entityName + "_tags et" + " INNER JOIN " + selectedEntityStatement + " t ON et." + entityName + "_id = t." + entityName + "_id AND et.version = t.version";
        LOG.log(Level.FINER, "Tag history query: " + sql);
        // Sends all received data into the object store.
        storeListener = new SortingStoreRowMapperListener<DbFeatureHistory<DbFeature<Tag>>>(sortingStore);
        // Retrieves the version information associated with the tag.
        dbFeatureHistoryRowMapper = new DbFeatureHistoryRowMapper<DbFeature<Tag>>(storeListener);
        // Retrieves the entity information associated with the tag.
        dbFeatureRowMapper = new DbFeatureRowMapper<Tag>(dbFeatureHistoryRowMapper);
        // Retrieves the basic tag information.
        tagRowMapper = new TagRowMapper(dbFeatureRowMapper);
        // Perform the query passing the row mapper chain to process rows in a streamy fashion.
        namedParamJdbcTemplate.query(sql, parameterSource, tagRowMapper);
        // Open a iterator on the store that will release the store upon completion.
        resultIterator = new StoreReleasingIterator<DbFeatureHistory<DbFeature<Tag>>>(sortingStore.iterate(), sortingStore);
        // The store itself shouldn't be released now that it has been attached to the iterator.
        sortingStore = null;
        return resultIterator;
    } finally {
        if (sortingStore != null) {
            sortingStore.close();
        }
    }
}
Also used : SingleClassObjectSerializationFactory(org.openstreetmap.osmosis.core.store.SingleClassObjectSerializationFactory) DbFeatureHistory(org.openstreetmap.osmosis.core.database.DbFeatureHistory) DbFeature(org.openstreetmap.osmosis.core.database.DbFeature) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) FileBasedSort(org.openstreetmap.osmosis.core.sort.common.FileBasedSort)

Example 83 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class BoundingBoxFilterTest method setUp.

/**
 * Performs pre-test activities.
 */
@Before
public void setUp() {
    OsmUser user;
    List<Tag> tags;
    user = new OsmUser(12, "OsmosisTest");
    // All nodes have an empty tags list.
    tags = new ArrayList<Tag>();
    entityInspector = new SinkEntityInspector();
    // simpleAreaFilter doesn't cross antimeridian; no complete ways or relations
    simpleAreaFilter = new BoundingBoxFilter(IdTrackerType.Dynamic, -20, 20, 20, -20, false, false, false, false);
    simpleAreaFilter.setSink(entityInspector);
    intersectingBound = new Bound(30, 10, 30, 10, "intersecting");
    nonIntersectingBound = new Bound(-30, -50, 10, -10, "nonintersecting");
    inAreaNode = new Node(new CommonEntityData(1234, 0, new Date(), user, 0, tags), 10, 10);
    outOfAreaNode = new Node(new CommonEntityData(1235, 0, new Date(), user, 0, tags), 30, 30);
    edgeNodeEast = new Node(new CommonEntityData(1236, 0, new Date(), user, 0, tags), 10, 20);
    edgeNodeWest = new Node(new CommonEntityData(1237, 0, new Date(), user, 0, tags), 10, -20);
    edgeNodeNorth = new Node(new CommonEntityData(1238, 0, new Date(), user, 0, tags), 20, 10);
    edgeNodeSouth = new Node(new CommonEntityData(1239, 0, new Date(), user, 0, tags), -20, 10);
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) OsmUser(org.openstreetmap.osmosis.core.domain.v0_6.OsmUser) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) Date(java.util.Date) Before(org.junit.Before)

Example 84 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class PolygonFilterTest method setUp.

/**
 * Performs pre-test activities.
 */
@Before
public void setUp() {
    OsmUser user;
    List<Tag> tags;
    user = new OsmUser(12, "OsmosisTest");
    // All nodes have an empty tags list.
    tags = new ArrayList<Tag>();
    polygonFile = new File(getClass().getResource("testPolygon.txt").getFile());
    entityInspector = new SinkEntityInspector();
    // polyAreaFilter has a notch out of the Northeast corner.
    polyAreaFilter = new PolygonFilter(IdTrackerType.Dynamic, polygonFile, false, false, false, false);
    polyAreaFilter.setSink(entityInspector);
    intersectingBound = new Bound(30, 0, 30, 0, "intersecting");
    crossingIntersectingBound = new Bound(-10, 10, 30, -30, "crossing intersecting");
    nonIntersectingBound = new Bound(30, 15, 30, 15, "nonintersecting");
    inAreaNode = new Node(new CommonEntityData(1234, 0, new Date(), user, 0, tags), 5, 10);
    outOfAreaNode = new Node(new CommonEntityData(1235, 0, new Date(), user, 0, tags), 15, 15);
    edgeNode = new Node(new CommonEntityData(1236, 0, new Date(), user, 0, tags), 15, 10);
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) OsmUser(org.openstreetmap.osmosis.core.domain.v0_6.OsmUser) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) File(java.io.File) Date(java.util.Date) Before(org.junit.Before)

Example 85 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class WayKeyFilter method process.

/**
 * {@inheritDoc}
 */
public void process(WayContainer container) {
    Way way = container.getEntity();
    boolean matchesFilter = false;
    for (Tag tag : way.getTags()) {
        if (allowedKeys.contains(tag.getKey())) {
            matchesFilter = true;
            break;
        }
    }
    if (matchesFilter) {
        sink.process(container);
    }
}
Also used : Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) Way(org.openstreetmap.osmosis.core.domain.v0_6.Way)

Aggregations

Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)66 SEQUENCE (org.mozilla.jss.asn1.SEQUENCE)23 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)23 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)17 IOException (java.io.IOException)16 Test (org.junit.Test)16 Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)16 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)16 Way (org.openstreetmap.osmosis.core.domain.v0_6.Way)12 Date (java.util.Date)10 RelationMember (org.openstreetmap.osmosis.core.domain.v0_6.RelationMember)10 OsmosisRuntimeException (org.openstreetmap.osmosis.core.OsmosisRuntimeException)9 Relation (org.openstreetmap.osmosis.core.domain.v0_6.Relation)9 Tag (org.mozilla.jss.asn1.Tag)7 SQLException (java.sql.SQLException)6 ArrayList (java.util.ArrayList)6 EXPLICIT (org.mozilla.jss.asn1.EXPLICIT)6 Osmformat (crosby.binary.Osmformat)5 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)5 Point (com.vividsolutions.jts.geom.Point)4