@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 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); }