use of org.openstreetmap.osmosis.core.container.v0_6.RelationContainer 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();
}
});
}
use of org.openstreetmap.osmosis.core.container.v0_6.RelationContainer in project osmosis by openstreetmap.
the class OsmWriterTest method testProcess8.
/**
* Test processing a Relation.
*/
@Test
public final void testProcess8() {
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));
// Nothing to assert; just expect no exception
}
use of org.openstreetmap.osmosis.core.container.v0_6.RelationContainer 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")));
}
use of org.openstreetmap.osmosis.core.container.v0_6.RelationContainer in project osmosis by openstreetmap.
the class FastXmlParser method readOsm.
/**
* Parses the xml and sends all data to the sink.
*/
public void readOsm() {
try {
String generator = null;
if (reader.nextTag() == XMLStreamConstants.START_ELEMENT && reader.getLocalName().equals("osm")) {
String fileVersion;
fileVersion = reader.getAttributeValue(null, ATTRIBUTE_NAME_VERSION);
if (!XmlConstants.OSM_VERSION.equals(fileVersion)) {
LOG.warning("Expected version " + XmlConstants.OSM_VERSION + " but received " + fileVersion + ".");
}
generator = reader.getAttributeValue(null, ATTRIBUTE_NAME_GENERATOR);
reader.nextTag();
if (reader.getEventType() == XMLStreamConstants.START_ELEMENT && reader.getLocalName().equals(ELEMENT_NAME_BOUND)) {
LOG.fine("Legacy <bound> element encountered.");
sink.process(new BoundContainer(readBound()));
}
if (reader.getEventType() == XMLStreamConstants.START_ELEMENT && reader.getLocalName().equals(ELEMENT_NAME_BOUNDS)) {
sink.process(new BoundContainer(readBounds(generator)));
}
while (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
// Node, way, relation
if (reader.getLocalName().equals(ELEMENT_NAME_NODE)) {
sink.process(new NodeContainer(readNode()));
} else if (reader.getLocalName().equals(ELEMENT_NAME_WAY)) {
sink.process(new WayContainer(readWay()));
} else if (reader.getLocalName().equals(ELEMENT_NAME_RELATION)) {
sink.process(new RelationContainer(readRelation()));
} else {
readUnknownElement();
}
}
} else {
throw new XMLStreamException();
}
} catch (Exception e) {
throw new OsmosisRuntimeException(e);
}
}
use of org.openstreetmap.osmosis.core.container.v0_6.RelationContainer in project osmosis by openstreetmap.
the class UsedNodeFilter method complete.
/**
* {@inheritDoc}
*/
public void complete() {
// send on all required nodes
ReleasableIterator<NodeContainer> nodeIterator = allNodes.iterate();
while (nodeIterator.hasNext()) {
NodeContainer nodeContainer = nodeIterator.next();
long nodeId = nodeContainer.getEntity().getId();
if (!requiredNodes.get(nodeId)) {
continue;
}
sink.process(nodeContainer);
}
nodeIterator.close();
nodeIterator = null;
// send on all ways
ReleasableIterator<WayContainer> wayIterator = allWays.iterate();
while (wayIterator.hasNext()) {
sink.process(wayIterator.next());
}
wayIterator.close();
wayIterator = null;
// send on all relations
ReleasableIterator<RelationContainer> relationIterator = allRelations.iterate();
while (relationIterator.hasNext()) {
sink.process(relationIterator.next());
}
relationIterator.close();
relationIterator = null;
// done
sink.complete();
}
Aggregations