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

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


public class ESWayUTest {

  @Test
  public void buildFromWayEntity() {
    // Setup
    Way way = mock(Way.class);
    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);

    ESWay expected = ESWay.Builder.create().id(1l)
View Full Code Here


  }

  @Test(expected = IllegalArgumentException.class)
  public void buildFromWayEntity_withIncorrectWayNodeSize() {
    // Setup
    Way way = mock(Way.class);
    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);

    // Action
View Full Code Here

  public static void assertWaysEquals(Collection<Way> expected, Collection<Way> actual) {
    Assert.assertEquals(expected.size(), actual.size());
    Iterator<Way> expectedWays = expected.iterator();
    Iterator<Way> actualWays = actual.iterator();
    while (expectedWays.hasNext() && actualWays.hasNext()) {
      Way expectedWay = expectedWays.next();
      Way actualWay = actualWays.next();
      assertEquals(expectedWay, actualWay);
    }
  }
View Full Code Here

    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 writing out a normal Way element.
   */
  @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();
    } catch (IOException e) {
View Full Code Here

  /**
   * Test writing of a Way element with no user.
   */
  @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();
    } catch (IOException e) {
View Full Code Here

  /**
   * Test writing out a Way element with no tags.
   */
  @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}
   */
  public void process(WayContainer wayContainer) {
    Way way;
   
    way = wayContainer.getEntity();
   
    wayBitSet.set(way.getId());
   
    for (WayNode wayNode : way.getWayNodes()) {
      if (!nodeBitSet.get(wayNode.getNodeId())) {
        initialize();
       
        write("Way," + way.getId() + ",Node," + wayNode.getNodeId());
        writeNewLine();
      }
    }
  }
View Full Code Here

    }

    protected String buildNodesString(List<WayNode> wayNodes) {
        StringBuilder sb = new StringBuilder();
        for (Iterator<WayNode> it = wayNodes.iterator(); it.hasNext();) {
            WayNode node = it.next();
            sb.append(Long.toString(node.getNodeId()));
            if (it.hasNext()) {
                sb.append(";");
            }
        }
        return sb.toString();
View Full Code Here

        } else {
            List<WayNode> nodes = Lists.newArrayList();
            String nodesString = (String) feature.getAttribute("nodes");
            for (String s : nodesString.split(";")) {
                nodes.add(new WayNode(Long.parseLong(s)));
            }
            entity = new Way(entityData, nodes);
        }

        return entity;
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.