/** * Enables the use of contraction hierarchies to reduce query times. Enabled by default. * * @param weightingList A list containing multiple weightings like: "fastest", "shortest" or * your own weight-calculation type. */ public LMAlgoFactoryDecorator setWeightingsAsStrings(List<String> weightingList) { if (weightingList.isEmpty()) throw new IllegalArgumentException("It is not allowed to pass an emtpy weightingList"); weightingsAsStrings.clear(); for (String strWeighting : weightingList) { strWeighting = toLowerCase(strWeighting); strWeighting = strWeighting.trim(); addWeighting(strWeighting); } return this; }
private void initLMAlgoFactoryDecorator() { if (lmFactoryDecorator.hasWeightings()) return; for (FlagEncoder encoder : encodingManager.fetchEdgeEncoders()) { for (String lmWeightingStr : lmFactoryDecorator.getWeightingsAsStrings()) { Weighting weighting = createWeighting(new HintsMap(lmWeightingStr), encoder, null); lmFactoryDecorator.addWeighting(weighting); } } }
@Test public void addWeighting() { LMAlgoFactoryDecorator dec = new LMAlgoFactoryDecorator().setEnabled(true); dec.addWeighting("fastest"); assertEquals(Arrays.asList("fastest"), dec.getWeightingsAsStrings()); // special parameters like the maximum weight dec = new LMAlgoFactoryDecorator().setEnabled(true); dec.addWeighting("fastest|maximum=65000"); dec.addWeighting("shortest|maximum=20000"); assertEquals(Arrays.asList("fastest", "shortest"), dec.getWeightingsAsStrings()); FlagEncoder car = new CarFlagEncoder(); EncodingManager em = new EncodingManager(car); dec.addWeighting(new FastestWeighting(car)).addWeighting(new ShortestWeighting(car)); dec.createPreparations(new GraphHopperStorage(new RAMDirectory(), em, false, new GraphExtension.NoOpExtension()), null); assertEquals(1, dec.getPreparations().get(0).getLandmarkStorage().getFactor(), .1); assertEquals(0.3, dec.getPreparations().get(1).getLandmarkStorage().getFactor(), .1); }
/** * Enables the use of contraction hierarchies to reduce query times. Enabled by default. * * @param weightingList A list containing multiple weightings like: "fastest", "shortest" or * your own weight-calculation type. */ public LMAlgoFactoryDecorator setWeightingsAsStrings(List<String> weightingList) { if (weightingList.isEmpty()) throw new IllegalArgumentException("It is not allowed to pass an emtpy weightingList"); weightingsAsStrings.clear(); for (String strWeighting : weightingList) { strWeighting = strWeighting.toLowerCase(); strWeighting = strWeighting.trim(); addWeighting(strWeighting); } return this; }
/** * Enables the use of contraction hierarchies to reduce query times. Enabled by default. * * @param weightingList A list containing multiple weightings like: "fastest", "shortest" or * your own weight-calculation type. */ public LMAlgoFactoryDecorator setWeightingsAsStrings(List<String> weightingList) { if (weightingList.isEmpty()) throw new IllegalArgumentException("It is not allowed to pass an emtpy weightingList"); weightingsAsStrings.clear(); for (String strWeighting : weightingList) { strWeighting = toLowerCase(strWeighting); strWeighting = strWeighting.trim(); addWeighting(strWeighting); } return this; }
private void initLMAlgoFactoryDecorator() { if (lmFactoryDecorator.hasWeightings()) return; for (FlagEncoder encoder : encodingManager.fetchEdgeEncoders()) { for (String lmWeightingStr : lmFactoryDecorator.getWeightingsAsStrings()) { Weighting weighting = createWeighting(new HintsMap(lmWeightingStr), encoder, null); lmFactoryDecorator.addWeighting(weighting); } } }
private void initLMAlgoFactoryDecorator() { if (lmFactoryDecorator.hasWeightings()) return; for (FlagEncoder encoder : encodingManager.fetchEdgeEncoders()) { for (String lmWeightingStr : lmFactoryDecorator.getWeightingsAsStrings()) { Weighting weighting = createWeighting(new HintsMap(lmWeightingStr), encoder, null); lmFactoryDecorator.addWeighting(weighting); } } }