Exemplo n.º 1
0
  @Test
  public void testCopy() {
    Graph g = initUnsorted(createGraph());
    EdgeIteratorState eb = g.edge(6, 5, 11, true);
    eb.setWayGeometry(Helper.createPointList(12, 10, -1, 3));
    LevelGraph lg = new GraphBuilder(encodingManager).levelGraphCreate();
    GHUtility.copyTo(g, lg);
    eb = lg.getEdgeProps(eb.getEdge(), 6);
    assertEquals(Helper.createPointList(-1, 3, 12, 10), eb.getWayGeometry());
    assertEquals(0, lg.getLevel(0));
    assertEquals(0, lg.getLevel(1));
    assertEquals(0, lg.getLatitude(0), 1e-6);
    assertEquals(1, lg.getLongitude(0), 1e-6);
    assertEquals(2.5, lg.getLatitude(1), 1e-6);
    assertEquals(4.5, lg.getLongitude(1), 1e-6);
    assertEquals(9, lg.getNodes());
    EdgeIterator iter = lg.createEdgeExplorer().setBaseNode(8);
    iter.next();
    assertEquals(2.05, iter.getDistance(), 1e-6);
    assertEquals("11", BitUtil.toBitString(iter.getFlags(), 2));
    iter.next();
    assertEquals(0.5, iter.getDistance(), 1e-6);
    assertEquals("11", BitUtil.toBitString(iter.getFlags(), 2));

    iter = lg.createEdgeExplorer().setBaseNode(7);
    iter.next();
    assertEquals(2.1, iter.getDistance(), 1e-6);
    assertEquals("01", BitUtil.toBitString(iter.getFlags(), 2));
    assertTrue(iter.next());
    assertEquals(0.7, iter.getDistance(), 1e-6);
  }
  @Test
  public void testFlags() {
    graph = createGraph();
    graph.edge(0, 1).setDistance(10).setFlags(carEncoder.setProperties(100, true, true));
    graph.edge(2, 3).setDistance(10).setFlags(carEncoder.setProperties(10, true, false));

    EdgeIterator iter = carAllExplorer.setBaseNode(0);
    assertTrue(iter.next());
    assertEquals(carEncoder.setProperties(100, true, true), iter.getFlags());

    iter = carAllExplorer.setBaseNode(2);
    assertTrue(iter.next());
    assertEquals(carEncoder.setProperties(10, true, false), iter.getFlags());

    try {
      graph.edge(0, 1).setDistance(-1);
      assertTrue(false);
    } catch (IllegalArgumentException ex) {
    }
  }