use of dataStructure.JunkCourse.ch04.Node in project osmosis by openstreetmap.
the class BoundComputerTest method computeBoundNoUpstreamBound.
/**
* Tests the bound computation when no bound entity is upstream.
*/
@Test
public void computeBoundNoUpstreamBound() {
SinkEntityInspector inspector = new SinkEntityInspector();
BoundComputer bc = new BoundComputer("NewBound");
bc.setSink(inspector);
bc.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
bc.process(new NodeContainer(new Node(new CommonEntityData(2, 2, new Date(), OsmUser.NONE, 1), 2, 2)));
bc.complete();
bc.close();
EntityContainer ec = inspector.getProcessedEntities().iterator().next();
Assert.assertEquals(new Bound(2, 1, 2, 1, "NewBound"), ec.getEntity());
}
use of dataStructure.JunkCourse.ch04.Node in project osmosis by openstreetmap.
the class BoundComputerTest method computeBoundWithUpstreamBound.
/**
* Tests the bound computation when there is bound entity is upstream.
*/
@Test
public void computeBoundWithUpstreamBound() {
SinkEntityInspector inspector = new SinkEntityInspector();
BoundComputer bc = new BoundComputer("NewBound");
bc.setSink(inspector);
bc.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
bc.process(new NodeContainer(new Node(new CommonEntityData(2, 2, new Date(), OsmUser.NONE, 1), 2, 2)));
bc.complete();
bc.close();
Iterator<EntityContainer> iterator = inspector.getProcessedEntities().iterator();
EntityContainer ec = iterator.next();
Assert.assertEquals(new Bound(2, 1, 2, 1, "NewBound"), ec.getEntity());
// Ensure there is no second bound.
ec = iterator.next();
Assert.assertEquals(EntityType.Node, ec.getEntity().getType());
}
use of dataStructure.JunkCourse.ch04.Node 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.");
}
use of dataStructure.JunkCourse.ch04.Node in project osmosis by openstreetmap.
the class FastXmlParser method readNode.
private Node readNode() throws Exception {
long id;
int version;
TimestampContainer timestamp;
OsmUser user;
long changesetId;
double latitude;
double longitude;
Node node;
id = Long.parseLong(reader.getAttributeValue(null, ATTRIBUTE_NAME_ID));
version = Integer.parseInt(reader.getAttributeValue(null, ATTRIBUTE_NAME_VERSION));
timestamp = parseTimestamp(reader.getAttributeValue(null, ATTRIBUTE_NAME_TIMESTAMP));
changesetId = Long.parseLong(reader.getAttributeValue(null, ATTRIBUTE_NAME_CHANGESET_ID));
user = readUser();
changesetId = readChangesetId();
latitude = Double.parseDouble(reader.getAttributeValue(null, ATTRIBUTE_NAME_LATITUDE));
longitude = Double.parseDouble(reader.getAttributeValue(null, ATTRIBUTE_NAME_LONGITUDE));
node = new Node(new CommonEntityData(id, version, timestamp, user, changesetId), latitude, longitude);
reader.nextTag();
while (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
if (reader.getLocalName().equals(ELEMENT_NAME_TAG)) {
node.getTags().add(readTag());
} else {
readUnknownElement();
}
}
reader.nextTag();
return node;
}
use of dataStructure.JunkCourse.ch04.Node in project osmosis by openstreetmap.
the class NodeElementProcessor method begin.
/**
* {@inheritDoc}
*/
public void begin(Attributes attributes) {
long id;
String sversion;
int version;
TimestampContainer timestampContainer;
String rawUserId;
String rawUserName;
OsmUser user;
long changesetId;
double latitude;
double longitude;
id = Long.parseLong(attributes.getValue(ATTRIBUTE_NAME_ID));
sversion = attributes.getValue(ATTRIBUTE_NAME_VERSION);
if (sversion == null) {
throw new OsmosisRuntimeException("Node " + id + " does not have a version attribute as OSM 0.6 are required to have. Is this a 0.5 file?");
} else {
version = Integer.parseInt(sversion);
}
timestampContainer = createTimestampContainer(attributes.getValue(ATTRIBUTE_NAME_TIMESTAMP));
rawUserId = attributes.getValue(ATTRIBUTE_NAME_USERID);
rawUserName = attributes.getValue(ATTRIBUTE_NAME_USER);
changesetId = buildChangesetId(attributes.getValue(ATTRIBUTE_NAME_CHANGESET_ID));
latitude = getLatLonDouble(attributes, ATTRIBUTE_NAME_LATITUDE, id);
longitude = getLatLonDouble(attributes, ATTRIBUTE_NAME_LONGITUDE, id);
user = buildUser(rawUserId, rawUserName);
node = new Node(new CommonEntityData(id, version, timestampContainer, user, changesetId), latitude, longitude);
}
Aggregations