Search in sources :

Example 1 with EntityProcessor

use of org.openstreetmap.osmosis.core.container.v0_6.EntityProcessor 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)

Aggregations

BoundContainer (org.openstreetmap.osmosis.core.container.v0_6.BoundContainer)1 EntityProcessor (org.openstreetmap.osmosis.core.container.v0_6.EntityProcessor)1 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)1 RelationContainer (org.openstreetmap.osmosis.core.container.v0_6.RelationContainer)1 WayContainer (org.openstreetmap.osmosis.core.container.v0_6.WayContainer)1