Search in sources :

Example 11 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project osmosis by openstreetmap.

the class BoundSetterTest method setNewBoundTest.

/**
 * Tests the bound setting when there is no bound upstream.
 */
@Test
public void setNewBoundTest() {
    SinkEntityInspector inspector = new SinkEntityInspector();
    Bound newBound = new Bound(2, 1, 4, 3, "NewBound");
    BoundSetter setter = new BoundSetter(newBound);
    setter.setSink(inspector);
    setter.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
    setter.complete();
    setter.close();
    EntityContainer ec = inspector.getProcessedEntities().iterator().next();
    Assert.assertEquals(EntityType.Bound, ec.getEntity().getType());
    Bound bound = (Bound) ec.getEntity();
    Assert.assertEquals(bound, newBound);
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) 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 12 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project osmosis by openstreetmap.

the class BoundSetterTest method removeNoBoundTest.

/**
 * Tests the bound removal when there is no bound upstream.
 */
@Test
public void removeNoBoundTest() {
    SinkEntityInspector inspector = new SinkEntityInspector();
    BoundSetter setter = new BoundSetter(null);
    setter.setSink(inspector);
    setter.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
    setter.complete();
    setter.close();
    EntityContainer ec = inspector.getProcessedEntities().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) 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 13 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project osmosis by openstreetmap.

the class BoundSetterTest method overwriteBoundTest.

/**
 * Tests the bound setting.
 */
@Test
public void overwriteBoundTest() {
    SinkEntityInspector inspector = new SinkEntityInspector();
    Bound newBound = new Bound(2, 1, 4, 3, "NewBound");
    BoundSetter setter = new BoundSetter(newBound);
    setter.setSink(inspector);
    setter.process(new BoundContainer(new Bound("Test")));
    setter.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
    setter.complete();
    setter.close();
    Iterator<EntityContainer> iterator = inspector.getProcessedEntities().iterator();
    EntityContainer ec = iterator.next();
    Assert.assertEquals(EntityType.Bound, ec.getEntity().getType());
    Bound bound = (Bound) ec.getEntity();
    Assert.assertEquals(bound, newBound);
    // 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) BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) 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 14 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project osmosis by openstreetmap.

the class AreaFilter method process.

/**
 * {@inheritDoc}
 */
public void process(NodeContainer container) {
    Node node;
    node = container.getEntity();
    // Check if we're storing entities for later.
    if (storeEntities) {
        allNodes.add(container);
    }
    // Only add the node if it lies within the box boundaries.
    if (isNodeWithinArea(node)) {
        availableNodes.set(node.getId());
        // If we're not storing entities, we pass it on immediately.
        if (!storeEntities) {
            emitNode(container);
        }
    }
}
Also used : WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node)

Example 15 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project osmosis by openstreetmap.

the class BoundComputer method process.

@Override
public void process(NodeContainer nodeContainer) {
    Node node = nodeContainer.getEntity();
    if (nodesSeen) {
        left = Math.min(left, node.getLongitude());
        right = Math.max(right, node.getLongitude());
        bottom = Math.min(bottom, node.getLatitude());
        top = Math.max(top, node.getLatitude());
    } else {
        left = node.getLongitude();
        right = node.getLongitude();
        top = node.getLatitude();
        bottom = node.getLatitude();
        nodesSeen = true;
    }
    objects.add(nodeContainer);
}
Also used : Node(org.openstreetmap.osmosis.core.domain.v0_6.Node)

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