Examples of WayNode


Examples of org.openstreetmap.osmosis.core.domain.v0_6.WayNode

            }
        }

        // Insert the nodes of the new way into the history table.
        for (int i = 0; i < nodeReferenceList.size(); i++) {
            WayNode nodeReference;

            nodeReference = nodeReferenceList.get(i);

            try {
                prmIndex = 1;
                insertWayNodeStatement.setLong(prmIndex++, way.getId());
                insertWayNodeStatement.setInt(prmIndex++, way.getVersion());
                insertWayNodeStatement.setLong(prmIndex++, nodeReference.getNodeId());
                insertWayNodeStatement.setLong(prmIndex++, i + 1);

                insertWayNodeStatement.execute();

            } catch (SQLException e) {
                throw new OsmosisRuntimeException("Unable to insert history way node with way id=" + way.getId()
                        + " and node id=" + nodeReference.getNodeId() + ".", e);
            }
        }

        if (populateCurrentTables) {
            // Delete the existing way tags from the current table.
            try {
                deleteWayTagCurrentStatement.setLong(1, way.getId());

                deleteWayTagCurrentStatement.execute();

            } catch (SQLException e) {
                throw new OsmosisRuntimeException("Unable to delete current way tags with id=" + way.getId() + ".", e);
            }
            // Delete the existing way nodes from the current table.
            try {
                deleteWayNodeCurrentStatement.setLong(1, way.getId());

                deleteWayNodeCurrentStatement.execute();

            } catch (SQLException e) {
                throw new OsmosisRuntimeException("Unable to delete current way nodes with id=" + way.getId() + ".", e);
            }

            // Update the node if it already exists in the current table, otherwise insert it.
            try {
                exists = checkIfEntityExists(selectWayCurrentCountStatement, way.getId());

            } catch (SQLException e) {
                throw new OsmosisRuntimeException("Unable to check if current way with id=" + way.getId() + " exists.",
                        e);
            }
            if (exists) {
                // Update the way in the current table.
                try {
                    prmIndex = 1;
                    updateWayCurrentStatement.setInt(prmIndex++, way.getVersion());
                    updateWayCurrentStatement.setTimestamp(prmIndex++, new Timestamp(way.getTimestamp().getTime()));
                    updateWayCurrentStatement.setBoolean(prmIndex++, visible);
                    updateWayCurrentStatement.setLong(prmIndex++, way.getChangesetId());
                    updateWayCurrentStatement.setLong(prmIndex++, way.getId());

                    updateWayCurrentStatement.execute();

                } catch (SQLException e) {
                    throw new OsmosisRuntimeException("Unable to update current way with id=" + way.getId() + ".", e);
                }
            } else {
                // Insert the new way into the current table.
                try {
                    prmIndex = 1;
                    insertWayCurrentStatement.setLong(prmIndex++, way.getId());
                    insertWayCurrentStatement.setInt(prmIndex++, way.getVersion());
                    insertWayCurrentStatement.setTimestamp(prmIndex++, new Timestamp(way.getTimestamp().getTime()));
                    insertWayCurrentStatement.setBoolean(prmIndex++, visible);
                    insertWayCurrentStatement.setLong(prmIndex++, way.getChangesetId());

                    insertWayCurrentStatement.execute();

                } catch (SQLException e) {
                    throw new OsmosisRuntimeException("Unable to insert current way with id=" + way.getId() + ".", e);
                }
            }

            // Insert the tags of the new way into the current table.
            for (Tag tag : way.getTags()) {
                try {
                    prmIndex = 1;
                    insertWayTagCurrentStatement.setLong(prmIndex++, way.getId());
                    insertWayTagCurrentStatement.setString(prmIndex++, tag.getKey());
                    insertWayTagCurrentStatement.setString(prmIndex++, tag.getValue());

                    insertWayTagCurrentStatement.execute();

                } catch (SQLException e) {
                    throw new OsmosisRuntimeException("Unable to insert current way tag with id=" + way.getId()
                            + " and key=(" + tag.getKey() + ").", e);
                }
            }

            // Insert the nodes of the new way into the current table.
            for (int i = 0; i < nodeReferenceList.size(); i++) {
                WayNode nodeReference;

                nodeReference = nodeReferenceList.get(i);

                try {
                    prmIndex = 1;
                    insertWayNodeCurrentStatement.setLong(prmIndex++, way.getId());
                    insertWayNodeCurrentStatement.setLong(prmIndex++, nodeReference.getNodeId());
                    insertWayNodeCurrentStatement.setLong(prmIndex++, i);

                    insertWayNodeCurrentStatement.execute();

                } catch (SQLException e) {
                    throw new OsmosisRuntimeException("Unable to insert current way node with way id=" + way.getId()
                            + " and node id=" + nodeReference.getNodeId() + ".", e);
                }
            }
        }
    }
View Full Code Here

Examples of org.openstreetmap.osmosis.core.domain.v0_6.WayNode

   
    return node;
  }
 
  private WayNode readWayNode() throws Exception {
    WayNode node = new WayNode(
        Long.parseLong(reader.getAttributeValue(null, ATTRIBUTE_NAME_REF)));
    reader.nextTag();
    reader.nextTag();
    return node;
  }
View Full Code Here

Examples of org.openstreetmap.osmosis.core.domain.v0_6.WayNode

      // the previous one.
      long nodeId = 0;
      List<WayNode> wayNodes = osmWay.getWayNodes();
      for (long nodeIdOffset : way.getRefsList()) {
        nodeId += nodeIdOffset;
        wayNodes.add(new WayNode(nodeId));
      }

      decodedEntities.add(new WayContainer(osmWay));
    }
  }
View Full Code Here

Examples of org.openstreetmap.osmosis.core.domain.v0_6.WayNode

  public void begin(Attributes attributes) {
    long id;
   
    id = Long.parseLong(attributes.getValue(ATTRIBUTE_NAME_ID));
   
    wayNode = new WayNode(id);
  }
View Full Code Here

Examples of org.openstreetmap.osmosis.core.domain.v0_6.WayNode

            }
               
            long lastId = 0;
            List<WayNode> nodes = new ArrayList<WayNode>();
            for (long j : i.getRefsList()) {
                nodes.add(new WayNode(j + lastId));
                lastId = j + lastId;
            }

            long id = i.getId();
View Full Code Here

Examples of org.openstreetmap.osmosis.core.domain.v0_6.WayNode

      filteredWayContainer = wayContainer.getWriteableInstance();
      filteredWay = filteredWayContainer.getEntity();
     
      // Remove node references for nodes that are unavailable.
      for (Iterator<WayNode> i = filteredWay.getWayNodes().iterator(); i.hasNext();) {
        WayNode nodeReference = i.next();
       
        if (!availableNodes.get(nodeReference.getNodeId())) {
          i.remove();
        }
      }
     
      // Only add ways that contain nodes.
View Full Code Here

Examples of org.openstreetmap.osmosis.core.domain.v0_6.WayNode

   */
  @Override
  public DbOrderedFeature<WayNode> mapRow(ResultSet rs, int rowNumber) throws SQLException {
    return new DbOrderedFeature<WayNode>(
        rs.getLong("entity_id"),
        new WayNode(
          rs.getLong("node_id")
        ),
        rs.getInt("sequence_id")
      );
  }
View Full Code Here

Examples of org.openstreetmap.osmosis.core.domain.v0_6.WayNode

  @Test
  public final void testProcess6() {
    Way testWay;
   
    testWay = new Way(new CommonEntityData(3456, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0));
    testWay.getWayNodes().add(new WayNode(1234));
    testWay.getWayNodes().add(new WayNode(1235));
    testWay.getTags().add(new Tag("test_key1", "test_value1"));
   
    testOsmWriter.process(new WayContainer(testWay));
    // Nothing to assert; just expect no exception
  }
View Full Code Here

Examples of org.openstreetmap.osmosis.core.domain.v0_6.WayNode

  @Test(expected = OsmosisRuntimeException.class)
  public final void testProcess7() {
    Way testWay;
   
    testWay = new Way(new CommonEntityData(3456, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0));
    testWay.getWayNodes().add(new WayNode(1234));
    testWay.getWayNodes().add(new WayNode(1235));
    testWay.getTags().add(new Tag("test_key1", "test_value1"));
   
    testOsmWriter.process(new WayContainer(testWay));
    testOsmWriter.process(new BoundContainer(new Bound("source")));
  }
View Full Code Here

Examples of org.openstreetmap.osmosis.core.domain.v0_6.WayNode

  @Override
  public DbOrderedFeature<WayNode> buildEntity(ResultSet resultSet) {
    try {
      return new DbOrderedFeature<WayNode>(
        resultSet.getLong("entity_id"),
        new WayNode(
          resultSet.getLong("node_id")
        ),
        resultSet.getInt("sequence_id")
      );
     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.