@Test
  public void test8BytesFlags() {
    Directory dir = new RAMDirectory();
    List<FlagEncoder> list = new ArrayList<FlagEncoder>();
    list.add(new TmpCarFlagEncoder(29, 0.001));
    list.add(new TmpCarFlagEncoder(29, 0.001));
    EncodingManager manager = new EncodingManager(list, 8, 0);
    graph = new GraphHopperStorage(dir, manager, false).create(defaultSize);

    EdgeIteratorState edge = graph.edge(0, 1);
    edge.setFlags(Long.MAX_VALUE / 3);
    // System.out.println(BitUtil.LITTLE.toBitString(Long.MAX_VALUE / 3) + "\n" +
    // BitUtil.LITTLE.toBitString(edge.getFlags()));
    assertEquals(Long.MAX_VALUE / 3, edge.getFlags());
    graph.close();

    graph = new GraphHopperStorage(dir, manager, false).create(defaultSize);

    edge = graph.edge(0, 1);
    edge.setFlags(list.get(0).setProperties(99.123, true, true));
    assertEquals(99.123, list.get(0).getSpeed(edge.getFlags()), 1e-3);
    long flags = GHUtility.getEdge(graph, 1, 0).getFlags();
    assertEquals(99.123, list.get(0).getSpeed(flags), 1e-3);
    assertTrue(list.get(0).isBool(flags, FlagEncoder.K_FORWARD));
    assertTrue(list.get(0).isBool(flags, FlagEncoder.K_BACKWARD));
    edge = graph.edge(2, 3);
    edge.setFlags(list.get(1).setProperties(44.123, true, false));
    assertEquals(44.123, list.get(1).getSpeed(edge.getFlags()), 1e-3);
    flags = GHUtility.getEdge(graph, 3, 2).getFlags();
    assertEquals(44.123, list.get(1).getSpeed(flags), 1e-3);
    assertTrue(list.get(1).isBool(flags, FlagEncoder.K_FORWARD));
    assertFalse(list.get(1).isBool(flags, FlagEncoder.K_BACKWARD));
  }
  @Test
  public void testDetachEdge() {
    graph = createGraph();
    graph.edge(0, 1, 2, true);
    long flags = carEncoder.setProperties(10, true, false);
    graph.edge(0, 2, 2, true).setWayGeometry(Helper.createPointList(1, 2, 3, 4)).setFlags(flags);
    graph.edge(1, 2, 2, true);

    EdgeIterator iter = graph.createEdgeExplorer().setBaseNode(0);
    try {
      // currently not possible to detach without next, without introducing a new property inside
      // EdgeIterable
      iter.detach(false);
      assertTrue(false);
    } catch (Exception ex) {
    }

    iter.next();
    EdgeIteratorState edgeState2 = iter.detach(false);
    assertEquals(2, iter.getAdjNode());
    assertEquals(1, edgeState2.fetchWayGeometry(0).getLatitude(0), 1e-1);
    assertEquals(2, edgeState2.getAdjNode());
    assertTrue(carEncoder.isBool(edgeState2.getFlags(), FlagEncoder.K_FORWARD));

    EdgeIteratorState edgeState3 = iter.detach(true);
    assertEquals(0, edgeState3.getAdjNode());
    assertEquals(2, edgeState3.getBaseNode());
    assertEquals(3, edgeState3.fetchWayGeometry(0).getLatitude(0), 1e-1);
    assertFalse(carEncoder.isBool(edgeState3.getFlags(), FlagEncoder.K_FORWARD));
    assertEquals(GHUtility.getEdge(graph, 0, 2).getFlags(), edgeState2.getFlags());
    assertEquals(GHUtility.getEdge(graph, 2, 0).getFlags(), edgeState3.getFlags());

    iter.next();
    assertEquals(1, iter.getAdjNode());
    assertEquals(2, edgeState2.getAdjNode());
    assertEquals(2, edgeState3.getBaseNode());

    assertEquals(0, iter.fetchWayGeometry(0).size());
    assertEquals(1, edgeState2.fetchWayGeometry(0).getLatitude(0), 1e-1);
    assertEquals(3, edgeState3.fetchWayGeometry(0).getLatitude(0), 1e-1);

    // #162 a directed self referencing edge should be able to reverse its state too
    graph.edge(3, 3, 2, true).setFlags(flags);
    EdgeIterator iter2 = graph.createEdgeExplorer().setBaseNode(3);
    iter2.next();
    assertEquals(edgeState2.getFlags(), iter2.detach(false).getFlags());
    assertEquals(edgeState3.getFlags(), iter2.detach(true).getFlags());
  }
  @Test
  public void testEnabledElevation() {
    graph = createGraph(defaultGraphLoc, true);
    NodeAccess na = graph.getNodeAccess();
    assertTrue(na.is3D());
    na.setNode(0, 10, 20, -10);
    na.setNode(1, 11, 2, 100);
    assertEquals(-10, na.getEle(0), 1e-1);
    assertEquals(100, na.getEle(1), 1e-1);

    graph.edge(0, 1).setWayGeometry(Helper.createPointList3D(10, 27, 72, 11, 20, 1));
    assertEquals(
        Helper.createPointList3D(10, 27, 72, 11, 20, 1),
        GHUtility.getEdge(graph, 0, 1).fetchWayGeometry(0));
    assertEquals(
        Helper.createPointList3D(10, 20, -10, 10, 27, 72, 11, 20, 1, 11, 2, 100),
        GHUtility.getEdge(graph, 0, 1).fetchWayGeometry(3));
    assertEquals(
        Helper.createPointList3D(11, 2, 100, 11, 20, 1, 10, 27, 72, 10, 20, -10),
        GHUtility.getEdge(graph, 1, 0).fetchWayGeometry(3));
  }