Search in sources :

Example 1 with BoundContainer

use of org.openstreetmap.osmosis.core.container.v0_6.BoundContainer in project osmosis by openstreetmap.

the class EntityReporter method process.

/**
 * {@inheritDoc}
 */
public void process(EntityContainer entityContainer) {
    String userName;
    final UserStatistics user;
    // Obtain the user statistics object.
    userName = entityContainer.getEntity().getUser().getName();
    if (userName != null && userName.length() > 0) {
        if (userMap.containsKey(userName)) {
            user = userMap.get(userName);
        } else {
            user = new UserStatistics(userName);
            userMap.put(userName, user);
        }
    } else {
        user = anonymousUser;
    }
    // Increment the relevant user statistic.
    entityContainer.process(new EntityProcessor() {

        private UserStatistics processorUser = user;

        public void process(BoundContainer bound) {
        // Do nothing.
        }

        public void process(NodeContainer node) {
            processorUser.incrementNodeCount();
            totalUser.incrementNodeCount();
        }

        public void process(WayContainer way) {
            processorUser.incrementWayCount();
            totalUser.incrementWayCount();
        }

        public void process(RelationContainer relation) {
            processorUser.incrementRelationCount();
            totalUser.incrementRelationCount();
        }
    });
}
Also used : WayContainer(org.openstreetmap.osmosis.core.container.v0_6.WayContainer) RelationContainer(org.openstreetmap.osmosis.core.container.v0_6.RelationContainer) BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) EntityProcessor(org.openstreetmap.osmosis.core.container.v0_6.EntityProcessor)

Example 2 with BoundContainer

use of org.openstreetmap.osmosis.core.container.v0_6.BoundContainer in project osmosis by openstreetmap.

the class BoundComputerTest method computeBoundNoNodesWithBound.

/**
 * Tests the bound computation if no nodes but a bound entity is upstream.
 */
@Test
public void computeBoundNoNodesWithBound() {
    SinkEntityInspector inspector = new SinkEntityInspector();
    BoundComputer bc = new BoundComputer("NewBound");
    bc.setSink(inspector);
    bc.process(new BoundContainer(new Bound("Test")));
    bc.complete();
    bc.close();
    Assert.assertNull(inspector.getLastEntityContainer());
}
Also used : BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) Test(org.junit.Test)

Example 3 with BoundContainer

use of org.openstreetmap.osmosis.core.container.v0_6.BoundContainer in project osmosis by openstreetmap.

the class OsmWriterTest method testProcess4.

/**
 * Test processing a Bound after a Node.
 */
@Test(expected = OsmosisRuntimeException.class)
public final void testProcess4() {
    testOsmWriter.process(new NodeContainer(new Node(new CommonEntityData(1234, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0, new ArrayList<Tag>()), 20, 20)));
    testOsmWriter.process(new BoundContainer(new Bound("source")));
    fail("Expected to throw an exception.");
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) OsmUser(org.openstreetmap.osmosis.core.domain.v0_6.OsmUser) BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) ArrayList(java.util.ArrayList) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) Date(java.util.Date) Test(org.junit.Test)

Example 4 with BoundContainer

use of org.openstreetmap.osmosis.core.container.v0_6.BoundContainer in project osmosis by openstreetmap.

the class OsmWriterTest method testProcess9.

/**
 * Test processing a Bound after a Relation.
 */
@Test(expected = OsmosisRuntimeException.class)
public final void testProcess9() {
    Relation testRelation;
    testRelation = new Relation(new CommonEntityData(3456, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0));
    testRelation.getMembers().add(new RelationMember(1234, EntityType.Node, "role1"));
    testRelation.getTags().add(new Tag("test_key1", "test_value1"));
    testOsmWriter.process(new RelationContainer(testRelation));
    testOsmWriter.process(new BoundContainer(new Bound("source")));
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) Relation(org.openstreetmap.osmosis.core.domain.v0_6.Relation) RelationContainer(org.openstreetmap.osmosis.core.container.v0_6.RelationContainer) RelationMember(org.openstreetmap.osmosis.core.domain.v0_6.RelationMember) OsmUser(org.openstreetmap.osmosis.core.domain.v0_6.OsmUser) BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) Date(java.util.Date) Test(org.junit.Test)

Example 5 with BoundContainer

use of org.openstreetmap.osmosis.core.container.v0_6.BoundContainer in project osmosis by openstreetmap.

the class BoundsElementProcessor method end.

/**
 * {@inheritDoc}
 */
@Override
public void end() {
    getSink().process(new BoundContainer(bound));
    bound = null;
}
Also used : BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer)

Aggregations

BoundContainer (org.openstreetmap.osmosis.core.container.v0_6.BoundContainer)29 Bound (org.openstreetmap.osmosis.core.domain.v0_6.Bound)22 Test (org.junit.Test)12 EntityContainer (org.openstreetmap.osmosis.core.container.v0_6.EntityContainer)10 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)9 RelationContainer (org.openstreetmap.osmosis.core.container.v0_6.RelationContainer)7 WayContainer (org.openstreetmap.osmosis.core.container.v0_6.WayContainer)7 Date (java.util.Date)5 OsmosisRuntimeException (org.openstreetmap.osmosis.core.OsmosisRuntimeException)5 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)5 BoundContainerIterator (org.openstreetmap.osmosis.core.container.v0_6.BoundContainerIterator)4 NodeContainerIterator (org.openstreetmap.osmosis.core.container.v0_6.NodeContainerIterator)4 RelationContainerIterator (org.openstreetmap.osmosis.core.container.v0_6.RelationContainerIterator)4 WayContainerIterator (org.openstreetmap.osmosis.core.container.v0_6.WayContainerIterator)4 ReleasableIterator (org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator)4 MultipleSourceIterator (org.openstreetmap.osmosis.core.store.MultipleSourceIterator)4 Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)3 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)3 SinkEntityInspector (org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector)3 Osmformat (crosby.binary.Osmformat)2