Package org.openstreetmap.osmosis.core.domain.v0_6

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


    when(way.getId()).thenReturn(1l);
    List<Tag> tags = new ArrayList<Tag>();
    tags.add(new Tag("highway", "primary"));
    when(way.getTags()).thenReturn(tags);
    List<WayNode> wayNodes = new ArrayList<WayNode>();
    wayNodes.add(new WayNode(1l));
    wayNodes.add(new WayNode(2l));
    when(way.getWayNodes()).thenReturn(wayNodes);

    ESShapeBuilder builder = new ESShapeBuilder();
    builder.addLocation(1.0, 2.0).addLocation(2.0, 3.0);
View Full Code Here


    when(way.getId()).thenReturn(1l);
    List<Tag> tags = new ArrayList<Tag>();
    tags.add(new Tag("highway", "primary"));
    when(way.getTags()).thenReturn(tags);
    List<WayNode> wayNodes = new ArrayList<WayNode>();
    wayNodes.add(new WayNode(1l));
    wayNodes.add(new WayNode(2l));
    when(way.getWayNodes()).thenReturn(wayNodes);

    ESShapeBuilder builder = new ESShapeBuilder();
    builder.addLocation(1.0, 2.0);
View Full Code Here

    Assert.assertFalse(expectedTags.hasNext() || actualTags.hasNext());
    // Verify WayNodes
    Iterator<WayNode> expectedWayNodes = expected.getWayNodes().iterator();
    Iterator<WayNode> actualWayNodes = actual.getWayNodes().iterator();
    while (expectedWayNodes.hasNext() && actualWayNodes.hasNext()) {
      WayNode expectedWayNode = expectedWayNodes.next();
      WayNode actualWayNode = actualWayNodes.next();
      Assert.assertEquals(0, expectedWayNode.compareTo(actualWayNode));
    }
    Assert.assertFalse(expectedWayNodes.hasNext() || actualWayNodes.hasNext());
  }
View Full Code Here

  public static Way buildSampleWay(long id, long... nodeIds) {
    List<Tag> tags = Arrays.asList(new Tag[] { new Tag("highway", "residential") });
    CommonEntityData entityData = new CommonEntityData(id, 0, new Date(), new OsmUser(1, "nco"), 1l, tags);
    List<WayNode> wayNodes = new ArrayList<WayNode>();
    for (int i = 0; i < nodeIds.length; i++)
      wayNodes.add(new WayNode(nodeIds[i]));
    return new Way(entityData, wayNodes);
  }
View Full Code Here

   */
  @Test
  public final void testProcessNormalWay() {
    Way way =
      new Way(new CommonEntityData(1234, 2, timestamp, new OsmUser(23, "someuser"), 0));
    way.getWayNodes().add(new WayNode(1235));
    way.getWayNodes().add(new WayNode(1236));
    way.getTags().add(new Tag("waykey", "wayvalue"));
   
    testWayWriter.process(way);
    try {
      testBufferedWriter.flush();
View Full Code Here

   */
  @Test
  public final void testProcessWayWithNoUser() {
    Way way =
      new Way(new CommonEntityData(1234, 2, timestamp, OsmUser.NONE, 0));
    way.getWayNodes().add(new WayNode(1235));
    way.getWayNodes().add(new WayNode(1236));
    way.getTags().add(new Tag("waykey", "wayvalue"));
   
    testWayWriter.process(way);
    try {
      testBufferedWriter.flush();
View Full Code Here

   */
  @Test
  public final void testProcessWayNoTags() {
    Way way =
      new Way(new CommonEntityData(1234, 2, timestamp, new OsmUser(23, "someuser"), 0));
    way.getWayNodes().add(new WayNode(1235));
    way.getWayNodes().add(new WayNode(1236));
   
    testWayWriter.process(way);
    try {
      testBufferedWriter.flush();
    } catch (IOException e) {
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public void processRow(ResultSet resultSet) throws SQLException {
        long nodeId;
        WayNode wayNode;
       
    nodeId = resultSet.getLong("node_id");
   
    wayNode = new WayNode(nodeId);
   
        listener.process(wayNode, resultSet);
  }
View Full Code Here

            }
        }

        // 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

   
    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

TOP

Related Classes of org.openstreetmap.osmosis.core.domain.v0_6.WayNode

Copyright © 2018 www.massapicom. 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.