Search in sources :

Example 6 with Node

use of org.openhab.binding.mqtt.homie.internal.homie300.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());
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) Date(java.util.Date) Test(org.junit.Test)

Example 7 with Node

use of org.openhab.binding.mqtt.homie.internal.homie300.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());
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) Date(java.util.Date) Test(org.junit.Test)

Example 8 with Node

use of org.openhab.binding.mqtt.homie.internal.homie300.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.");
}
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 9 with Node

use of org.openhab.binding.mqtt.homie.internal.homie300.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;
}
Also used : SimpleTimestampContainer(org.openstreetmap.osmosis.core.domain.common.SimpleTimestampContainer) UnparsedTimestampContainer(org.openstreetmap.osmosis.core.domain.common.UnparsedTimestampContainer) TimestampContainer(org.openstreetmap.osmosis.core.domain.common.TimestampContainer) CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) OsmUser(org.openstreetmap.osmosis.core.domain.v0_6.OsmUser) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node)

Example 10 with Node

use of org.openhab.binding.mqtt.homie.internal.homie300.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);
}
Also used : TimestampContainer(org.openstreetmap.osmosis.core.domain.common.TimestampContainer) 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) OsmosisRuntimeException(org.openstreetmap.osmosis.core.OsmosisRuntimeException)

Aggregations

Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)52 Test (org.junit.Test)27 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)26 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)21 Date (java.util.Date)18 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)17 Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)16 Node (org.flyte.api.v1.Node)15 Test (org.junit.jupiter.api.Test)15 ArrayList (java.util.ArrayList)14 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)14 Way (org.openstreetmap.osmosis.core.domain.v0_6.Way)13 TaskNode (org.flyte.api.v1.TaskNode)10 Bound (org.openstreetmap.osmosis.core.domain.v0_6.Bound)10 List (java.util.List)9 Map (java.util.Map)9 Node (org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Node)9 Node (org.openhab.binding.mqtt.homie.internal.homie300.Node)9 EntityContainer (org.openstreetmap.osmosis.core.container.v0_6.EntityContainer)9 Node (ch.ethz.globis.phtree.v16.Node)8