Search in sources :

Example 91 with Node

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

the class DatasetDriver method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(Dataset dataset) {
    try (DatasetContext dsCtx = dataset.createReader()) {
        EntityManager<Node> nodeManager = dsCtx.getNodeManager();
        OsmUser user;
        Node node;
        // Create the user for edits to be performed under. This is an existing user with an
        // updated name.
        user = new OsmUser(10, "user10b");
        // Modify node 1 to add a new tag.
        node = nodeManager.getEntity(1).getWriteableInstance();
        node.setUser(user);
        node.getTags().add(new Tag("change", "new tag"));
        nodeManager.modifyEntity(node);
        // Delete node 6.
        nodeManager.removeEntity(6);
        // Add node 7 using the NONE user.
        node = new Node(new CommonEntityData(7, 16, buildDate("2008-01-02 18:19:20"), OsmUser.NONE, 93), -11, -12);
        node.getTags().addAll(Arrays.asList(new Tag[] { new Tag("created_by", "Me7"), new Tag("change", "new node") }));
        nodeManager.addEntity(node);
        dsCtx.complete();
    }
}
Also used : 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) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) DatasetContext(org.openstreetmap.osmosis.core.container.v0_6.DatasetContext)

Example 92 with Node

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

the class ChangeSimplifierTest method badSortOrderId.

/**
 * Tests that badly ordered input (with respect to the ids) is detected correctly.
 *
 * @throws Exception
 *             if anything fails.
 */
@Test
public void badSortOrderId() throws Exception {
    ChangeSimplifier simplifier = new ChangeSimplifier();
    simplifier.setChangeSink(new NullChangeWriter());
    simplifier.initialize(new HashMap<String, Object>());
    Node node;
    node = new Node(new CommonEntityData(2, 2, new Date(), OsmUser.NONE, 2), 1, 1);
    simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));
    try {
        node = new Node(new CommonEntityData(1, 2, new Date(), OsmUser.NONE, 1), 1, 1);
        simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));
    } catch (OsmosisRuntimeException e) {
        if (e.getMessage().startsWith("Pipeline entities are not sorted")) {
            return;
        }
        throw e;
    }
    Assert.fail("Expected exception not thrown");
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) NullChangeWriter(org.openstreetmap.osmosis.core.misc.v0_6.NullChangeWriter) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) Date(java.util.Date) OsmosisRuntimeException(org.openstreetmap.osmosis.core.OsmosisRuntimeException) AbstractDataTest(org.openstreetmap.osmosis.testutil.AbstractDataTest) Test(org.junit.Test)

Example 93 with Node

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

the class ChangeSimplifierTest method badSortOrderType.

/**
 * Tests that badly ordered input (with respect to the ids) is detected correctly.
 *
 * @throws Exception
 *             if anything fails.
 */
@Test
public void badSortOrderType() throws Exception {
    ChangeSimplifier simplifier = new ChangeSimplifier();
    simplifier.setChangeSink(new NullChangeWriter());
    simplifier.initialize(new HashMap<String, Object>());
    Node node;
    Way way;
    way = new Way(new CommonEntityData(2, 2, new Date(), OsmUser.NONE, 2));
    simplifier.process(new ChangeContainer(new WayContainer(way), ChangeAction.Modify));
    try {
        node = new Node(new CommonEntityData(1, 2, new Date(), OsmUser.NONE, 1), 1, 1);
        simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));
    } catch (OsmosisRuntimeException e) {
        if (e.getMessage().startsWith("Pipeline entities are not sorted")) {
            return;
        }
        throw e;
    }
    Assert.fail("Expected exception not thrown");
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) WayContainer(org.openstreetmap.osmosis.core.container.v0_6.WayContainer) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) NullChangeWriter(org.openstreetmap.osmosis.core.misc.v0_6.NullChangeWriter) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) Way(org.openstreetmap.osmosis.core.domain.v0_6.Way) Date(java.util.Date) OsmosisRuntimeException(org.openstreetmap.osmosis.core.OsmosisRuntimeException) AbstractDataTest(org.openstreetmap.osmosis.testutil.AbstractDataTest) Test(org.junit.Test)

Example 94 with Node

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

the class ChangeSimplifierTest method badSortOrderVersion.

/**
 * Tests that badly ordered input (with respect to the version) is detected correctly.
 *
 * @throws Exception
 *             if anything fails.
 */
@Test
public void badSortOrderVersion() throws Exception {
    ChangeSimplifier simplifier = new ChangeSimplifier();
    simplifier.setChangeSink(new NullChangeWriter());
    simplifier.initialize(new HashMap<String, Object>());
    Node node;
    node = new Node(new CommonEntityData(1, 2, new Date(), OsmUser.NONE, 2), 1, 1);
    simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));
    try {
        node = new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1);
        simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));
    } catch (OsmosisRuntimeException e) {
        if (e.getMessage().startsWith("Pipeline entities are not sorted")) {
            return;
        }
        throw e;
    }
    Assert.fail("Expected exception not thrown");
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) NullChangeWriter(org.openstreetmap.osmosis.core.misc.v0_6.NullChangeWriter) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) Date(java.util.Date) OsmosisRuntimeException(org.openstreetmap.osmosis.core.OsmosisRuntimeException) AbstractDataTest(org.openstreetmap.osmosis.testutil.AbstractDataTest) Test(org.junit.Test)

Example 95 with Node

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

the class NodeRowMapper method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(CommonEntityData data, ResultSet resultSet) throws SQLException {
    double latitude;
    double longitude;
    Node node;
    latitude = FixedPrecisionCoordinateConvertor.convertToDouble(resultSet.getInt("latitude"));
    longitude = FixedPrecisionCoordinateConvertor.convertToDouble(resultSet.getInt("longitude"));
    node = new Node(data, latitude, longitude);
    listener.process(node, resultSet);
}
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