return new Bike2WeightFlagEncoder(configuration);
@Test public void testDirectionDependentSpeedFwdSearch() { runTestWithDirectionDependentEdgeSpeed(10, 20, 0, 2, IntArrayList.from(0, 1, 2), new MotorcycleFlagEncoder()); runTestWithDirectionDependentEdgeSpeed(10, 20, 0, 2, IntArrayList.from(0, 1, 2), new Bike2WeightFlagEncoder()); }
@Test public void testDirectionDependentSpeedBwdSearch() { runTestWithDirectionDependentEdgeSpeed(20, 10, 2, 0, IntArrayList.from(2, 1, 0), new MotorcycleFlagEncoder()); runTestWithDirectionDependentEdgeSpeed(20, 10, 2, 0, IntArrayList.from(2, 1, 0), new Bike2WeightFlagEncoder()); }
@Test public void testTime() { FlagEncoder tmpEnc = new Bike2WeightFlagEncoder(); GraphHopperStorage g = new GraphBuilder(new EncodingManager(tmpEnc)).create(); Weighting w = new FastestWeighting(tmpEnc); long flags = tmpEnc.setSpeed(tmpEnc.setReverseSpeed(tmpEnc.setAccess(0, true, true), 10), 15); EdgeIteratorState edge = GHUtility.createMockedEdgeIteratorState(100000, flags); assertEquals(375 * 60 * 1000, w.calcMillis(edge, false, EdgeIterator.NO_EDGE)); assertEquals(600 * 60 * 1000, w.calcMillis(edge, true, EdgeIterator.NO_EDGE)); g.close(); } }
@Test public void testTwoWeightsPerEdge() { FlagEncoder encoder = new Bike2WeightFlagEncoder(); EncodingManager em = new EncodingManager(encoder); AlgorithmOptions opts = AlgorithmOptions.start(). weighting(new FastestWeighting(encoder)).build(); GraphHopperStorage graph = createGHStorage(em, Arrays.asList(opts.getWeighting()), true); initEleGraph(graph); // force the other path GHUtility.getEdge(graph, 0, 3).setFlags(encoder.setProperties(10, false, true)); // for two weights per edge it happened that Path (and also the Weighting) read the wrong side // of the speed and read 0 => infinity weight => overflow of millis => negative millis! Path p = createAlgo(graph, opts). calcPath(0, 10); assertEquals(85124371, p.getTime()); assertEquals(425622, p.getDistance(), 1); assertEquals(85124.4, p.getWeight(), 1); }
@Test public void testShortcutCreationAndAccessForManyVehicles() { FlagEncoder tmpCar = new CarFlagEncoder(); FlagEncoder tmpBike = new Bike2WeightFlagEncoder(); EncodingManager em = new EncodingManager(tmpCar, tmpBike); List<Weighting> chWeightings = new ArrayList<>();
@Test public void testGetWeightIfAdvancedEncoder() { FlagEncoder customEncoder = new Bike2WeightFlagEncoder(); EncodingManager em = new EncodingManager(customEncoder); FastestWeighting weighting = new FastestWeighting(customEncoder); GraphHopperStorage ghStorage = new GraphBuilder(em).setCHGraph(weighting).create(); ghStorage.edge(0, 2); ghStorage.freeze(); CHGraphImpl lg = (CHGraphImpl) ghStorage.getGraph(CHGraph.class, weighting); CHEdgeIteratorState sc1 = lg.shortcut(0, 1); long flags = customEncoder.setProperties(10, false, true); sc1.setFlags(flags); sc1.setWeight(100.123); assertEquals(100.123, lg.getEdgeIteratorState(sc1.getEdge(), sc1.getAdjNode()).getWeight(), 1e-3); assertEquals(100.123, lg.getEdgeIteratorState(sc1.getEdge(), sc1.getBaseNode()).getWeight(), 1e-3); assertEquals(100.123, ((CHEdgeIteratorState) GHUtility.getEdge(lg, sc1.getBaseNode(), sc1.getAdjNode())).getWeight(), 1e-3); assertEquals(100.123, ((CHEdgeIteratorState) GHUtility.getEdge(lg, sc1.getAdjNode(), sc1.getBaseNode())).getWeight(), 1e-3); sc1 = lg.shortcut(1, 0); assertTrue(sc1.isShortcut()); sc1.setFlags(PrepareEncoder.getScDirMask()); sc1.setWeight(1.011011); assertEquals(1.011011, sc1.getWeight(), 1e-3); }
@Test public void testPathRecursiveUnpacking() { FlagEncoder encoder = new Bike2WeightFlagEncoder(); EncodingManager em = new EncodingManager(encoder); ShortestWeighting weighting = new ShortestWeighting(encoder);
@Override public FlagEncoder createFlagEncoder( String name, PMap configuration ) { if (name.equals(CAR)) return new CarFlagEncoder(configuration); if (name.equals(BIKE)) return new BikeFlagEncoder(configuration); if (name.equals(BIKE2)) return new Bike2WeightFlagEncoder(configuration); if (name.equals(RACINGBIKE)) return new RacingBikeFlagEncoder(configuration); if (name.equals(MOUNTAINBIKE)) return new MountainBikeFlagEncoder(configuration); if (name.equals(FOOT)) return new FootFlagEncoder(configuration); if (name.equals(HIKE)) return new HikeFlagEncoder(configuration); if (name.equals(MOTORCYCLE)) return new MotorcycleFlagEncoder(configuration); throw new IllegalArgumentException("entry in encoder list not supported " + name); } }
return new Bike2WeightFlagEncoder(configuration);
return new Bike2WeightFlagEncoder(configuration);