@Test
  public void testDestinationTag() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    assertEquals(60, encoder.getSpeed(way), 1e-1);

    way.setTag("vehicle", "destination");
    long flags = encoder.handleWayTags(way, encoder.acceptWay(way), 0);
    assertEquals(5, encoder.getSpeed(flags), 1e-1);
  }
 @Test
 public void testEdgeReturn() {
   graph = createGraph();
   EdgeIteratorState iter =
       graph.edge(4, 10).setDistance(100).setFlags(carEncoder.setProperties(10, true, false));
   assertEquals(4, iter.getBaseNode());
   assertEquals(10, iter.getAdjNode());
   iter = graph.edge(14, 10).setDistance(100).setFlags(carEncoder.setProperties(10, true, false));
   assertEquals(14, iter.getBaseNode());
   assertEquals(10, iter.getAdjNode());
 }
  @Test
  public void testCombination() {
    ReaderWay way = new ReaderWay(123);
    way.setTag("highway", "cycleway");
    way.setTag("sac_scale", "hiking");

    long flags = em.acceptWay(way);
    long edgeFlags = em.handleWayTags(way, flags, 0);
    assertFalse(encoder.isBackward(edgeFlags));
    assertFalse(encoder.isForward(edgeFlags));
    assertTrue(em.getEncoder("bike").isBackward(edgeFlags));
    assertTrue(em.getEncoder("bike").isForward(edgeFlags));
  }
 @Test
 public void testFootMix() {
   graph = createGraph();
   graph.edge(0, 1).setDistance(10).setFlags(footEncoder.setProperties(10, true, true));
   graph.edge(0, 2).setDistance(10).setFlags(carEncoder.setProperties(10, true, true));
   graph
       .edge(0, 3)
       .setDistance(10)
       .setFlags(
           footEncoder.setProperties(10, true, true) | carEncoder.setProperties(10, true, true));
   EdgeExplorer footOutExplorer =
       graph.createEdgeExplorer(new DefaultEdgeFilter(footEncoder, false, true));
   assertEquals(GHUtility.asSet(3, 1), GHUtility.getNeighbors(footOutExplorer.setBaseNode(0)));
   assertEquals(GHUtility.asSet(3, 2), GHUtility.getNeighbors(carOutExplorer.setBaseNode(0)));
 }
  @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 testApplyBadSurfaceSpeed() {
   ReaderWay way = new ReaderWay(1);
   way.setTag("highway", "secondary");
   way.setTag("surface", "unpaved");
   assertEquals(30, encoder.applyBadSurfaceSpeed(way, 90), 1e-1);
 }
 @Test
 public void testMilitaryAccess() {
   ReaderWay way = new ReaderWay(1);
   way.setTag("highway", "track");
   way.setTag("access", "military");
   assertFalse(encoder.acceptWay(way) > 0);
 }
  @Test
  public void testSwapDir() {
    long swappedFlags = encoder.reverseFlags(encoder.flagsDefault(true, true));
    assertTrue(encoder.isForward(swappedFlags));
    assertTrue(encoder.isBackward(swappedFlags));

    swappedFlags = encoder.reverseFlags(encoder.flagsDefault(true, false));

    assertFalse(encoder.isForward(swappedFlags));
    assertTrue(encoder.isBackward(swappedFlags));

    assertEquals(0, encoder.reverseFlags(0));
  }
  @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) {
    }
  }
  @Test
  public void testDifferentVehicles() {
    final EncodingManager encodingManager = new EncodingManager("car,foot");
    Graph g = AbstractLocationIndexTester.this.createGHStorage(encodingManager);
    initSimpleGraph(g);
    idx = createIndex(g, -1);
    assertEquals(1, findID(idx, 1, -1));

    // now make all edges from node 1 accessible for CAR only
    EdgeIterator iter = g.createEdgeExplorer().setBaseNode(1);
    CarFlagEncoder carEncoder = (CarFlagEncoder) encodingManager.getEncoder("car");
    while (iter.next()) {
      iter.setFlags(carEncoder.setProperties(50, true, true));
    }
    idx.close();

    idx = createIndex(g, -1);
    FootFlagEncoder footEncoder = (FootFlagEncoder) encodingManager.getEncoder("foot");
    assertEquals(2, idx.findClosest(1, -1, new DefaultEdgeFilter(footEncoder)).getClosestNode());
    Helper.close((Closeable) g);
  }
  @Test
  public void testCreateDuplicateEdges() {
    graph = createGraph();
    graph.edge(2, 1, 12, true);
    graph.edge(2, 3, 12, true);
    graph.edge(2, 3, 13, false);
    assertEquals(3, GHUtility.count(carOutExplorer.setBaseNode(2)));

    // no exception
    graph.getEdgeProps(1, 3);

    // raise exception
    try {
      graph.getEdgeProps(4, 3);
      assertTrue(false);
    } catch (Exception ex) {
    }
    try {
      graph.getEdgeProps(-1, 3);
      assertTrue(false);
    } catch (Exception ex) {
    }

    EdgeIterator iter = carOutExplorer.setBaseNode(2);
    assertTrue(iter.next());
    EdgeIteratorState oneIter = graph.getEdgeProps(iter.getEdge(), 3);
    assertEquals(13, oneIter.getDistance(), 1e-6);
    assertEquals(2, oneIter.getBaseNode());
    assertTrue(carEncoder.isBool(oneIter.getFlags(), FlagEncoder.K_FORWARD));
    assertFalse(carEncoder.isBool(oneIter.getFlags(), FlagEncoder.K_BACKWARD));

    oneIter = graph.getEdgeProps(iter.getEdge(), 2);
    assertEquals(13, oneIter.getDistance(), 1e-6);
    assertEquals(3, oneIter.getBaseNode());
    assertFalse(carEncoder.isBool(oneIter.getFlags(), FlagEncoder.K_FORWARD));
    assertTrue(carEncoder.isBool(oneIter.getFlags(), FlagEncoder.K_BACKWARD));

    graph.edge(3, 2, 14, true);
    assertEquals(4, GHUtility.count(carOutExplorer.setBaseNode(2)));
  }
  @Test
  public void testBarrierAccess() {
    ReaderNode node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "lift_gate");
    node.setTag("access", "yes");
    // no barrier!
    assertTrue(encoder.handleNodeTags(node) == 0);

    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "lift_gate");
    node.setTag("bicycle", "yes");
    // barrier!
    assertTrue(encoder.handleNodeTags(node) > 0);

    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "lift_gate");
    node.setTag("access", "yes");
    node.setTag("bicycle", "yes");
    // should this be a barrier for motorcars too?
    // assertTrue(encoder.handleNodeTags(node) > 0);

    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "lift_gate");
    node.setTag("access", "no");
    node.setTag("motorcar", "yes");
    // no barrier!
    assertTrue(encoder.handleNodeTags(node) == 0);

    node = new ReaderNode(1, -1, -1);
    node.setTag("barrier", "bollard");
    // barrier!
    assertTrue(encoder.handleNodeTags(node) > 0);

    // ignore other access tags for absolute barriers!
    node.setTag("motorcar", "yes");
    // still barrier!
    assertTrue(encoder.handleNodeTags(node) > 0);
  }
  @Test
  public void testSetSpeed0_issue367() {
    long flags = encoder.setProperties(10, true, true);
    flags = encoder.setSpeed(flags, encoder.speedFactor * 0.49);

    assertEquals(0, encoder.getSpeed(flags), .1);
    assertEquals(0, encoder.getReverseSpeed(flags), .1);
    assertFalse(encoder.isForward(flags));
    assertFalse(encoder.isBackward(flags));
  }
  @Test
  public void testMaxValue() {
    CarFlagEncoder instance = new CarFlagEncoder(10, 0.5, 0);
    EncodingManager em = new EncodingManager(instance);
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "motorway_link");
    way.setTag("maxspeed", "60 mph");
    long flags = instance.handleWayTags(way, 1, 0);

    // double speed = AbstractFlagEncoder.parseSpeed("60 mph");
    // => 96.56 * 0.9 => 86.9
    assertEquals(86.9, instance.getSpeed(flags), 1e-1);
    flags = instance.reverseFlags(flags);
    assertEquals(86.9, instance.getSpeed(flags), 1e-1);

    // test that maxPossibleValue  is not exceeded
    way = new ReaderWay(2);
    way.setTag("highway", "motorway_link");
    way.setTag("maxspeed", "70 mph");
    flags = instance.handleWayTags(way, 1, 0);
    assertEquals(101.5, instance.getSpeed(flags), .1);
  }
  @Test
  public void testFordAccess() {
    ReaderNode node = new ReaderNode(0, 0.0, 0.0);
    node.setTag("ford", "yes");

    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "unclassified");
    way.setTag("ford", "yes");

    // Node and way are initially blocking
    assertTrue(encoder.isBlockFords());
    assertFalse(encoder.acceptWay(way) > 0);
    assertTrue(encoder.handleNodeTags(node) > 0);

    try {
      // Now they are passable
      encoder.setBlockFords(false);
      assertTrue(encoder.acceptWay(way) > 0);
      assertFalse(encoder.handleNodeTags(node) > 0);
    } finally {
      encoder.setBlockFords(true);
    }
  }
  @Test
  public void testMaxSpeed() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "trunk");
    way.setTag("maxspeed", "500");
    long allowed = encoder.acceptWay(way);
    long encoded = encoder.handleWayTags(way, allowed, 0);
    assertEquals(140, encoder.getSpeed(encoded), 1e-1);

    way = new ReaderWay(1);
    way.setTag("highway", "primary");
    way.setTag("maxspeed:backward", "10");
    way.setTag("maxspeed:forward", "20");
    encoded = encoder.handleWayTags(way, encoder.acceptWay(way), 0);
    assertEquals(10, encoder.getSpeed(encoded), 1e-1);

    way = new ReaderWay(1);
    way.setTag("highway", "primary");
    way.setTag("maxspeed:forward", "20");
    encoded = encoder.handleWayTags(way, encoder.acceptWay(way), 0);
    assertEquals(20, encoder.getSpeed(encoded), 1e-1);

    way = new ReaderWay(1);
    way.setTag("highway", "primary");
    way.setTag("maxspeed:backward", "20");
    encoded = encoder.handleWayTags(way, encoder.acceptWay(way), 0);
    assertEquals(20, encoder.getSpeed(encoded), 1e-1);

    way = new ReaderWay(1);
    way.setTag("highway", "motorway");
    way.setTag("maxspeed", "none");
    encoded = encoder.handleWayTags(way, encoder.acceptWay(way), 0);
    assertEquals(125, encoder.getSpeed(encoded), .1);
  }
 @Test
 public void testSetToMaxSpeed() {
   ReaderWay way = new ReaderWay(12);
   way.setTag("maxspeed", "90");
   assertEquals(90, encoder.getMaxSpeed(way), 1e-2);
 }
  @Test
  public void testOneway() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "primary");
    long flags = encoder.handleWayTags(way, encoder.acceptWay(way), 0);
    assertTrue(encoder.isForward(flags));
    assertTrue(encoder.isBackward(flags));
    way.setTag("oneway", "yes");
    flags = encoder.handleWayTags(way, encoder.acceptWay(way), 0);
    assertTrue(encoder.isForward(flags));
    assertFalse(encoder.isBackward(flags));
    way.clearTags();

    way.setTag("highway", "tertiary");
    flags = encoder.handleWayTags(way, encoder.acceptWay(way), 0);
    assertTrue(encoder.isForward(flags));
    assertTrue(encoder.isBackward(flags));
    way.clearTags();

    way.setTag("highway", "tertiary");
    way.setTag("vehicle:forward", "no");
    flags = encoder.handleWayTags(way, encoder.acceptWay(way), 0);
    assertFalse(encoder.isForward(flags));
    assertTrue(encoder.isBackward(flags));
    way.clearTags();

    way.setTag("highway", "tertiary");
    way.setTag("vehicle:backward", "no");
    flags = encoder.handleWayTags(way, encoder.acceptWay(way), 0);
    assertTrue(encoder.isForward(flags));
    assertFalse(encoder.isBackward(flags));
    way.clearTags();
  }
  @Test
  public void testRailway() {
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    way.setTag("railway", "rail");
    assertTrue(encoder.acceptWay(way) > 0);

    way.clearTags();
    way.setTag("highway", "path");
    way.setTag("railway", "abandoned");
    assertTrue(encoder.acceptWay(way) == 0);

    way.setTag("highway", "track");
    assertTrue(encoder.acceptWay(way) > 0);

    // this is fully okay as sometimes old rails are on the road
    way.setTag("highway", "primary");
    way.setTag("railway", "historic");
    assertTrue(encoder.acceptWay(way) > 0);

    way.setTag("motorcar", "no");
    assertTrue(encoder.acceptWay(way) == 0);

    way = new ReaderWay(1);
    way.setTag("highway", "secondary");
    way.setTag("railway", "tram");
    // but allow tram to be on the same way
    assertTrue(encoder.acceptWay(way) > 0);

    way = new ReaderWay(1);
    way.setTag("route", "shuttle_train");
    way.setTag("motorcar", "yes");
    way.setTag("bicycle", "no");
    // Provide the duration value in seconds:
    way.setTag("duration:seconds", Long.toString(35 * 60));
    way.setTag("estimated_distance", 50000);
    // accept
    assertTrue(encoder.acceptWay(way) > 0);
    // calculate speed from estimated_distance and duration
    assertEquals(61, encoder.getFerrySpeed(way, 20, 30, 40), 1e-1);

    // Test for very short and slow 0.5km/h still realisitic ferry
    way = new ReaderWay(1);
    way.setTag("route", "ferry");
    way.setTag("motorcar", "yes");
    // Provide the duration of 12 minutes in seconds:
    way.setTag("duration:seconds", Long.toString(12 * 60));
    way.setTag("estimated_distance", 100);
    // accept
    assertTrue(encoder.acceptWay(way) > 0);
    // We can't store 0.5km/h, but we expect the lowest possible speed (5km/h)
    assertEquals(2.5, encoder.getFerrySpeed(way, 20, 30, 40), 1e-1);
    assertEquals(5, encoder.getSpeed(encoder.setSpeed(0, 2.5)), 1e-1);

    // Test for an unrealisitic long duration
    way = new ReaderWay(1);
    way.setTag("route", "ferry");
    way.setTag("motorcar", "yes");
    // Provide the duration of 2 months in seconds:
    way.setTag("duration:seconds", Long.toString(87900 * 60));
    way.setTag("estimated_distance", 100);
    // accept
    assertTrue(encoder.acceptWay(way) > 0);
    // We have ignored the unrealisitc long duration and take the unknown speed
    assertEquals(20, encoder.getFerrySpeed(way, 20, 30, 40), 1e-1);
  }
  @Test
  public void testPillarNodes() {
    graph = createGraph();
    NodeAccess na = graph.getNodeAccess();
    na.setNode(0, 0.01, 0.01);
    na.setNode(4, 0.4, 0.4);
    na.setNode(14, 0.14, 0.14);
    na.setNode(10, 0.99, 0.99);

    PointList pointList = Helper.createPointList(1, 1, 1, 2, 1, 3);
    graph
        .edge(0, 4)
        .setDistance(100)
        .setFlags(carEncoder.setProperties(10, true, false))
        .setWayGeometry(pointList);
    pointList = Helper.createPointList(1, 5, 1, 6, 1, 7, 1, 8, 1, 9);
    graph
        .edge(4, 10)
        .setDistance(100)
        .setFlags(carEncoder.setProperties(10, true, false))
        .setWayGeometry(pointList);
    pointList = Helper.createPointList(1, 13, 1, 12, 1, 11);
    graph
        .edge(14, 0)
        .setDistance(100)
        .setFlags(carEncoder.setProperties(10, true, false))
        .setWayGeometry(pointList);

    EdgeIterator iter = carAllExplorer.setBaseNode(0);
    assertTrue(iter.next());
    assertEquals(14, iter.getAdjNode());
    assertPList(Helper.createPointList(1, 11, 1, 12, 1, 13.0), iter.fetchWayGeometry(0));
    assertPList(
        Helper.createPointList(0.01, 0.01, 1, 11, 1, 12, 1, 13.0), iter.fetchWayGeometry(1));
    assertPList(
        Helper.createPointList(1, 11, 1, 12, 1, 13.0, 0.14, 0.14), iter.fetchWayGeometry(2));
    assertPList(
        Helper.createPointList(0.01, 0.01, 1, 11, 1, 12, 1, 13.0, 0.14, 0.14),
        iter.fetchWayGeometry(3));

    assertTrue(iter.next());
    assertEquals(4, iter.getAdjNode());
    assertPList(Helper.createPointList(1, 1, 1, 2, 1, 3), iter.fetchWayGeometry(0));
    assertPList(Helper.createPointList(0.01, 0.01, 1, 1, 1, 2, 1, 3), iter.fetchWayGeometry(1));
    assertPList(Helper.createPointList(1, 1, 1, 2, 1, 3, 0.4, 0.4), iter.fetchWayGeometry(2));
    assertPList(
        Helper.createPointList(0.01, 0.01, 1, 1, 1, 2, 1, 3, 0.4, 0.4), iter.fetchWayGeometry(3));

    assertFalse(iter.next());

    iter = carOutExplorer.setBaseNode(0);
    assertTrue(iter.next());
    assertEquals(4, iter.getAdjNode());
    assertPList(Helper.createPointList(1, 1, 1, 2, 1, 3), iter.fetchWayGeometry(0));
    assertFalse(iter.next());

    iter = carInExplorer.setBaseNode(10);
    assertTrue(iter.next());
    assertEquals(4, iter.getAdjNode());
    assertPList(Helper.createPointList(1, 9, 1, 8, 1, 7, 1, 6, 1, 5), iter.fetchWayGeometry(0));
    assertPList(
        Helper.createPointList(0.99, 0.99, 1, 9, 1, 8, 1, 7, 1, 6, 1, 5), iter.fetchWayGeometry(1));
    assertPList(
        Helper.createPointList(1, 9, 1, 8, 1, 7, 1, 6, 1, 5, 0.4, 0.4), iter.fetchWayGeometry(2));
    assertPList(
        Helper.createPointList(0.99, 0.99, 1, 9, 1, 8, 1, 7, 1, 6, 1, 5, 0.4, 0.4),
        iter.fetchWayGeometry(3));
    assertFalse(iter.next());
  }
  @Test
  public void testAccess() {
    ReaderWay way = new ReaderWay(1);
    assertFalse(encoder.acceptWay(way) > 0);
    way.setTag("highway", "service");
    assertTrue(encoder.acceptWay(way) > 0);
    way.setTag("access", "no");
    assertFalse(encoder.acceptWay(way) > 0);

    way.clearTags();
    way.setTag("highway", "track");
    assertTrue(encoder.acceptWay(way) > 0);

    way.setTag("motorcar", "no");
    assertFalse(encoder.acceptWay(way) > 0);

    // for now allow grade1+2+3 for every country, see #253
    way.clearTags();
    way.setTag("highway", "track");
    way.setTag("tracktype", "grade2");
    assertTrue(encoder.acceptWay(way) > 0);
    way.setTag("tracktype", "grade4");
    assertFalse(encoder.acceptWay(way) > 0);

    way.clearTags();
    way.setTag("highway", "service");
    way.setTag("access", "delivery");
    assertFalse(encoder.acceptWay(way) > 0);

    way.clearTags();
    way.setTag("highway", "unclassified");
    way.setTag("ford", "yes");
    assertFalse(encoder.acceptWay(way) > 0);
    way.setTag("motorcar", "yes");
    assertTrue(encoder.acceptWay(way) > 0);

    way.clearTags();
    way.setTag("route", "ferry");
    assertTrue(encoder.acceptWay(way) > 0);
    assertTrue(encoder.isFerry(encoder.acceptWay(way)));
    way.setTag("motorcar", "no");
    assertFalse(encoder.acceptWay(way) > 0);

    way.clearTags();
    way.setTag("route", "ferry");
    way.setTag("foot", "yes");
    assertFalse(encoder.acceptWay(way) > 0);
    assertFalse(encoder.isFerry(encoder.acceptWay(way)));

    way.clearTags();
    way.setTag("access", "yes");
    way.setTag("motor_vehicle", "no");
    assertFalse(encoder.acceptWay(way) > 0);

    way.clearTags();
    way.setTag("highway", "service");
    way.setTag("access", "yes");
    way.setTag("motor_vehicle", "no");
    assertFalse(encoder.acceptWay(way) > 0);

    way.clearTags();
    way.setTag("highway", "service");
    way.setTag("access", "no");
    way.setTag("motorcar", "yes");
    assertTrue(encoder.acceptWay(way) > 0);

    way.clearTags();
    way.setTag("highway", "service");
    way.setTag("access", "emergency");
    assertFalse(encoder.acceptWay(way) > 0);

    way.clearTags();
    way.setTag("highway", "service");
    way.setTag("motor_vehicle", "emergency");
    assertFalse(encoder.acceptWay(way) > 0);

    DateFormat simpleDateFormat = Helper.createFormatter("yyyy MMM dd");

    way.clearTags();
    way.setTag("highway", "road");
    way.setTag(
        "access:conditional", "no @ (" + simpleDateFormat.format(new Date().getTime()) + ")");
    assertFalse(encoder.acceptWay(way) > 0);

    way.clearTags();
    way.setTag("highway", "road");
    way.setTag("access", "no");
    way.setTag(
        "access:conditional", "yes @ (" + simpleDateFormat.format(new Date().getTime()) + ")");
    assertTrue(encoder.acceptWay(way) > 0);
  }
  @Test
  public void testRoundabout() {
    long flags = encoder.setAccess(0, true, true);
    long resFlags = encoder.setBool(flags, FlagEncoder.K_ROUNDABOUT, true);
    assertTrue(encoder.isBool(resFlags, FlagEncoder.K_ROUNDABOUT));
    assertTrue(encoder.isForward(resFlags));
    assertTrue(encoder.isBackward(resFlags));

    resFlags = encoder.setBool(flags, FlagEncoder.K_ROUNDABOUT, false);
    assertFalse(encoder.isBool(resFlags, FlagEncoder.K_ROUNDABOUT));
    assertTrue(encoder.isForward(resFlags));
    assertTrue(encoder.isBackward(resFlags));

    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "motorway");
    flags = encoder.handleWayTags(way, encoder.acceptBit, 0);
    assertTrue(encoder.isForward(flags));
    assertTrue(encoder.isBackward(flags));
    assertFalse(encoder.isBool(flags, FlagEncoder.K_ROUNDABOUT));

    way.setTag("junction", "roundabout");
    flags = encoder.handleWayTags(way, encoder.acceptBit, 0);
    assertTrue(encoder.isForward(flags));
    assertFalse(encoder.isBackward(flags));
    assertTrue(encoder.isBool(flags, FlagEncoder.K_ROUNDABOUT));
  }
  @Test
  public void testSetAccess() {
    assertTrue(encoder.isForward(encoder.setProperties(0, true, true)));
    assertTrue(encoder.isBackward(encoder.setProperties(0, true, true)));

    assertTrue(encoder.isForward(encoder.setProperties(0, true, false)));
    assertFalse(encoder.isBackward(encoder.setProperties(0, true, false)));

    assertFalse(encoder.isForward(encoder.setProperties(0, false, true)));
    assertTrue(encoder.isBackward(encoder.setProperties(0, false, true)));

    assertTrue(encoder.isForward(encoder.flagsDefault(true, true)));
    assertTrue(encoder.isBackward(encoder.flagsDefault(true, true)));

    assertTrue(encoder.isForward(encoder.flagsDefault(true, false)));
    assertFalse(encoder.isBackward(encoder.flagsDefault(true, false)));

    long flags = encoder.flagsDefault(true, true);
    // disable access
    assertFalse(encoder.isForward(encoder.setAccess(flags, false, false)));
    assertFalse(encoder.isBackward(encoder.setAccess(flags, false, false)));
  }
 @Test
 public void testSetSpeed() {
   assertEquals(10, encoder.getSpeed(encoder.setSpeed(0, 10)), 1e-1);
 }
  @Test
  public void testSpeed() {
    // limit bigger than default road speed
    ReaderWay way = new ReaderWay(1);
    way.setTag("highway", "trunk");
    way.setTag("maxspeed", "110");
    long allowed = encoder.acceptWay(way);
    long encoded = encoder.handleWayTags(way, allowed, 0);
    assertEquals(100, encoder.getSpeed(encoded), 1e-1);

    way.clearTags();
    way.setTag("highway", "residential");
    way.setTag("surface", "cobblestone");
    allowed = encoder.acceptWay(way);
    encoded = encoder.handleWayTags(way, allowed, 0);
    assertEquals(30, encoder.getSpeed(encoded), 1e-1);

    way.clearTags();
    way.setTag("highway", "track");
    allowed = encoder.acceptWay(way);
    encoded = encoder.handleWayTags(way, allowed, 0);
    assertEquals(15, encoder.getSpeed(encoded), 1e-1);

    way.clearTags();
    way.setTag("highway", "track");
    way.setTag("tracktype", "grade1");
    allowed = encoder.acceptWay(way);
    encoded = encoder.handleWayTags(way, allowed, 0);
    assertEquals(20, encoder.getSpeed(encoded), 1e-1);

    way.clearTags();
    way.setTag("highway", "secondary");
    way.setTag("surface", "compacted");
    allowed = encoder.acceptWay(way);
    encoded = encoder.handleWayTags(way, allowed, 0);
    assertEquals(30, encoder.getSpeed(encoded), 1e-1);

    try {
      encoder.setSpeed(0, -1);
      assertTrue(false);
    } catch (IllegalArgumentException ex) {
    }
  }