Search in sources :

Example 16 with Node

use of dsa450List.PracticeLinkedList2.Node in project osmosis by openstreetmap.

the class MockReplicationSource method sendSequence.

/**
 * Sends a replication sequence containing dummy data to the destination.
 */
public void sendSequence() {
    // Initialise the replication stream.
    ReplicationState state = new ReplicationState();
    Map<String, Object> metaData = new HashMap<String, Object>(1);
    metaData.put(ReplicationState.META_DATA_KEY, state);
    changeSink.initialize(metaData);
    // allowed. We'll only send a single record for simplicity.
    if (state.getSequenceNumber() > 0) {
        // We'll do a create action on the first replication pass, and modify subsequently.
        ChangeAction action;
        if (state.getSequenceNumber() == 1) {
            action = ChangeAction.Create;
        } else {
            action = ChangeAction.Modify;
        }
        // Create a change record which data derived from the
        // replication sequence number itself.
        ChangeContainer change = new ChangeContainer(new NodeContainer(new Node(new CommonEntityData(10, (int) state.getSequenceNumber(), new Date(state.getSequenceNumber() * 1000), new OsmUser(11, "test"), state.getSequenceNumber() * 2), state.getSequenceNumber() * 3, state.getSequenceNumber() * 4)), action);
        // Send the record downstream.
        changeSink.process(change);
    }
    state.setTimestamp(new Date(state.getSequenceNumber() * 1000));
    changeSink.complete();
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) ChangeAction(org.openstreetmap.osmosis.core.task.common.ChangeAction) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) HashMap(java.util.HashMap) OsmUser(org.openstreetmap.osmosis.core.domain.v0_6.OsmUser) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) ReplicationState(org.openstreetmap.osmosis.replication.common.ReplicationState) Date(java.util.Date)

Example 17 with Node

use of dsa450List.PracticeLinkedList2.Node in project osmosis by openstreetmap.

the class ApidbWriter method flushNodes.

/**
 * Flushes nodes to the database. If complete is false, this will only write nodes until the
 * remaining node count is less than the multi-row insert statement row count. If complete is
 * true, all remaining rows will be written using single row insert statements.
 *
 * @param complete If true, all data will be written to the database. If false, some data may be
 *        left until more data is available.
 */
private void flushNodes(boolean complete) {
    while (nodeBuffer.size() >= INSERT_BULK_ROW_COUNT_NODE) {
        int prmIndex;
        List<Node> processedNodes;
        processedNodes = new ArrayList<Node>(INSERT_BULK_ROW_COUNT_NODE);
        prmIndex = 1;
        for (int i = 0; i < INSERT_BULK_ROW_COUNT_NODE; i++) {
            Node node;
            node = nodeBuffer.remove(0);
            processedNodes.add(node);
            populateNodeParameters(bulkNodeStatement, prmIndex, node);
            prmIndex += INSERT_PRM_COUNT_NODE;
            transactionSizeCount++;
        }
        try {
            bulkNodeStatement.executeUpdate();
            if (transactionSizeCount % TRANSACTION_SIZE == 0) {
                dbCtx.commit();
            }
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to bulk insert nodes into the database.", e);
        }
        for (Node node : processedNodes) {
            addNodeTags(node);
        }
    }
    if (complete) {
        while (nodeBuffer.size() > 0) {
            Node node;
            node = nodeBuffer.remove(0);
            populateNodeParameters(singleNodeStatement, 1, node);
            try {
                singleNodeStatement.executeUpdate();
            } catch (SQLException e) {
                throw new OsmosisRuntimeException("Unable to insert a node into the database.", e);
            }
            addNodeTags(node);
        }
    }
    dbCtx.commit();
}
Also used : SQLException(java.sql.SQLException) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) OsmosisRuntimeException(org.openstreetmap.osmosis.core.OsmosisRuntimeException)

Example 18 with Node

use of dsa450List.PracticeLinkedList2.Node in project osmosis by openstreetmap.

the class ApidbWriter method process.

/**
 * {@inheritDoc}
 */
public void process(NodeContainer nodeContainer) {
    Node node;
    long nodeId;
    node = nodeContainer.getEntity();
    nodeId = node.getId();
    if (nodeId >= maxNodeId) {
        maxNodeId = nodeId + 1;
    }
    if (nodeId < minNodeId) {
        minNodeId = nodeId;
    }
    nodeBuffer.add(node);
    flushNodes(false);
}
Also used : WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node)

Example 19 with Node

use of dsa450List.PracticeLinkedList2.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 20 with Node

use of dsa450List.PracticeLinkedList2.Node in project osmosis by openstreetmap.

the class CopyFilesetBuilder method process.

/**
 * {@inheritDoc}
 */
public void process(NodeContainer nodeContainer) {
    Node node;
    node = nodeContainer.getEntity();
    nodeWriter.writeField(node.getId());
    nodeWriter.writeField(node.getVersion());
    nodeWriter.writeField(node.getUser().getId());
    nodeWriter.writeField(node.getTimestamp());
    nodeWriter.writeField(node.getChangesetId());
    nodeWriter.writeField(buildTags(node));
    nodeWriter.writeField(pointBuilder.createPoint(node.getLatitude(), node.getLongitude()));
    nodeWriter.endRecord();
    if (enableBboxBuilder || enableLinestringBuilder) {
        wayGeometryBuilder.addNodeLocation(node);
    }
}
Also used : WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) 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