Exemplo n.º 1
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));
  }
Exemplo n.º 2
0
  @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();
  }
Exemplo n.º 3
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));
  }
Exemplo n.º 4
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));
  }
Exemplo n.º 5
0
  @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));
  }
Exemplo n.º 6
0
  @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)));
  }