Exemplo n.º 1
0
  /**
   * merge to complete nodes onto an incomplete way with the same two nodes, but incomplete. => both
   * the nodes and the way should be complete in the target dataset after merging
   */
  @Test
  public void twoCompleteNodesOntoAnIncompleteWay() {

    // -- source dataset

    // an complete node
    Node n1 = new Node(1, 1);
    n1.setCoor(new LatLon(1, 1));
    their.addPrimitive(n1);

    // another complete node
    Node n2 = new Node(2, 1);
    n2.setCoor(new LatLon(2, 2));
    their.addPrimitive(n2);

    // --- target dataset

    Node n4 = new Node(1);
    my.addPrimitive(n4);

    Node n5 = new Node(2);
    my.addPrimitive(n5);

    Way w6 = new Way(3, 1);
    w6.addNode(n4);
    w6.addNode(n5);
    my.addPrimitive(w6);

    // -- merge it
    DataSetMerger visitor = new DataSetMerger(my, their);
    visitor.merge();

    // -- test it
    assertEquals(0, visitor.getConflicts().size());

    Node n = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE);
    assertNotNull(n);
    assertFalse(n.isIncomplete());

    n = (Node) my.getPrimitiveById(2, OsmPrimitiveType.NODE);
    assertNotNull(n);
    assertFalse(n.isIncomplete());

    Way w = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY);
    assertNotNull(w);
    assertFalse(w.hasIncompleteNodes());
    assertTrue(w.isUsable());
    assertEquals(2, w.getNodesCount());
    assertEquals(1, w.getNode(0).getId());
    assertEquals(2, w.getNode(1).getId());
  }
Exemplo n.º 2
0
 protected void loadIncompleteNodes() throws OsmTransferException {
   // a way loaded with MultiFetch may have incomplete nodes because at least one of its
   // nodes isn't present in the local data set. We therefore fully load all ways with incomplete
   // nodes.
   for (Way w : ds.getWays()) {
     if (canceled) return;
     if (w.hasIncompleteNodes()) {
       synchronized (this) {
         if (canceled) return;
         objectReader =
             new OsmServerObjectReader(w.getId(), OsmPrimitiveType.WAY, true /* full */);
       }
       DataSet theirDataSet =
           objectReader.parseOsm(
               progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
       synchronized (this) {
         objectReader = null;
       }
       new DataSetMerger(ds, theirDataSet).merge();
     }
   }
 }