public final boolean isDisablingAllowed() { return disablingAllowed || !isEnabled(); }
@Override public RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFactory defaultAlgoFactory, HintsMap map) { // for now do not allow mixing CH&LM #1082 boolean disableCH = map.getBool(Parameters.CH.DISABLE, false); boolean disableLM = map.getBool(Parameters.Landmark.DISABLE, false); if (!isEnabled() || disablingAllowed && disableLM || !disableCH) return defaultAlgoFactory; if (preparations.isEmpty()) throw new IllegalStateException("No preparations added to this decorator"); for (final PrepareLandmarks p : preparations) { if (p.getWeighting().matches(map)) return new LMRAFactory(p, defaultAlgoFactory); } // if the initial encoder&weighting has certain properties we could cross query it but for now avoid this return defaultAlgoFactory; }
if (!isEnabled() || !preparations.isEmpty()) return; if (weightings.isEmpty())
/** * For landmarks it is required to always call this method: either it creates the landmark data or it loads it. */ protected void loadOrPrepareLM() { boolean tmpPrepare = lmFactoryDecorator.isEnabled() && !lmFactoryDecorator.getPreparations().isEmpty(); if (tmpPrepare) { ensureWriteAccess(); ghStorage.freeze(); if (lmFactoryDecorator.loadOrDoWork(ghStorage.getProperties())) ghStorage.getProperties().put(Landmark.PREPARE + "done", true); } }
@Override protected void loadOrPrepareLM() { if (!getLMFactoryDecorator().isEnabled() || getLMFactoryDecorator().getPreparations().isEmpty()) return; if (landmarkSplittingFeatureCollection != null && !landmarkSplittingFeatureCollection.getFeatures().isEmpty()) { SpatialRuleLookup ruleLookup = SpatialRuleLookupBuilder.buildIndex(landmarkSplittingFeatureCollection, "area", new SpatialRuleLookupBuilder.SpatialRuleFactory() { @Override public SpatialRule createSpatialRule(final String id, List<Polygon> polygons) { return new DefaultSpatialRule() { @Override public String getId() { return id; } }.setBorders(polygons); } }); for (PrepareLandmarks prep : getLMFactoryDecorator().getPreparations()) { // the ruleLookup splits certain areas from each other but avoids making this a permanent change so that other algorithms still can route through these regions. if (ruleLookup != null && ruleLookup.size() > 0) { prep.setSpatialRuleLookup(ruleLookup); } } } super.loadOrPrepareLM(); } }
? new TurnCostExtension() : new GraphExtension.NoOpExtension(); if (lmFactoryDecorator.isEnabled()) initLMAlgoFactoryDecorator();
/** * Does the preparation and creates the location index */ public void postProcessing() { // Later: move this into the GraphStorage.optimize method // Or: Doing it after preparation to optimize shortcuts too. But not possible yet #12 if (sortGraph) { if (ghStorage.isCHPossible() && isCHPrepared()) throw new IllegalArgumentException("Sorting a prepared CHGraph is not possible yet. See #12"); GraphHopperStorage newGraph = GHUtility.newStorage(ghStorage); GHUtility.sortDFS(ghStorage, newGraph); logger.info("graph sorted (" + getMemInfo() + ")"); ghStorage = newGraph; } if (hasElevation()) { interpolateBridgesAndOrTunnels(); } initLocationIndex(); if (chFactoryDecorator.isEnabled()) chFactoryDecorator.createPreparations(ghStorage, traversalMode); if (!isCHPrepared()) prepareCH(); if (lmFactoryDecorator.isEnabled()) lmFactoryDecorator.createPreparations(ghStorage, locationIndex); loadOrPrepareLM(); }
@Test public void testPrepareWeightingNo() { CmdArgs args = new CmdArgs(); args.put(Parameters.Landmark.PREPARE + "weightings", "fastest"); LMAlgoFactoryDecorator dec = new LMAlgoFactoryDecorator(); dec.init(args); assertTrue(dec.isEnabled()); // See #1076 args.put(Parameters.Landmark.PREPARE + "weightings", "no"); dec = new LMAlgoFactoryDecorator(); dec.init(args); assertFalse(dec.isEnabled()); } }
if (hopper.getLMFactoryDecorator().isEnabled()) { final HintsMap lmHints = new HintsMap(defaultHints).put(Parameters.Landmark.DISABLE, false); prepare.add(new AlgoHelperEntry(ghStorage, AlgorithmOptions.start(astarbiOpts).hints(lmHints).build(), idx, "astarbi|landmarks|" + weighting) {
public final boolean isDisablingAllowed() { return disablingAllowed || !isEnabled(); }
public final boolean isDisablingAllowed() { return disablingAllowed || !isEnabled(); }
@Override public RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFactory defaultAlgoFactory, HintsMap map) { boolean forceFlexMode = map.getBool(DISABLE, false); if (!isEnabled() || disablingAllowed && forceFlexMode) return defaultAlgoFactory; if (preparations.isEmpty()) throw new IllegalStateException("No preparations added to this decorator"); for (final PrepareLandmarks p : preparations) { if (p.getWeighting().matches(map)) return new LMRAFactory(p, defaultAlgoFactory); } // if the initial encoder&weighting has certain properies we could cross query it but for now avoid this return defaultAlgoFactory; }
@Override public RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFactory defaultAlgoFactory, HintsMap map) { // for now do not allow mixing CH&LM #1082 boolean disableCH = map.getBool(Parameters.CH.DISABLE, false); boolean disableLM = map.getBool(Parameters.Landmark.DISABLE, false); if (!isEnabled() || disablingAllowed && disableLM || !disableCH) return defaultAlgoFactory; if (preparations.isEmpty()) throw new IllegalStateException("No preparations added to this decorator"); for (final PrepareLandmarks p : preparations) { if (p.getWeighting().matches(map)) return new LMRAFactory(p, defaultAlgoFactory); } // if the initial encoder&weighting has certain properties we could cross query it but for now avoid this return defaultAlgoFactory; }
if (!isEnabled() || !preparations.isEmpty()) return; if (weightings.isEmpty())
if (!isEnabled() || !preparations.isEmpty()) return; if (weightings.isEmpty())
/** * For landmarks it is required to always call this method: either it creates the landmark data or it loads it. */ protected void loadOrPrepareLM() { boolean tmpPrepare = lmFactoryDecorator.isEnabled() && !lmFactoryDecorator.getPreparations().isEmpty(); if (tmpPrepare) { ensureWriteAccess(); ghStorage.freeze(); if (lmFactoryDecorator.loadOrDoWork(ghStorage.getProperties())) ghStorage.getProperties().put(Landmark.PREPARE + "done", true); } }
/** * For landmarks it is required to always call this method: either it creates the landmark data or it loads it. */ protected void loadOrPrepareLM() { boolean tmpPrepare = lmFactoryDecorator.isEnabled(); if (tmpPrepare) { ensureWriteAccess(); ghStorage.freeze(); if (lmFactoryDecorator.loadOrDoWork(ghStorage.getProperties())) ghStorage.getProperties().put(Landmark.PREPARE + "done", true); } }
/** * Does the preparation and creates the location index */ public void postProcessing() { // Later: move this into the GraphStorage.optimize method // Or: Doing it after preparation to optimize shortcuts too. But not possible yet #12 if (sortGraph) { if (ghStorage.isCHPossible() && isCHPrepared()) throw new IllegalArgumentException("Sorting a prepared CHGraph is not possible yet. See #12"); GraphHopperStorage newGraph = GHUtility.newStorage(ghStorage); GHUtility.sortDFS(ghStorage, newGraph); logger.info("graph sorted (" + Helper.getMemInfo() + ")"); ghStorage = newGraph; } if (hasElevation()) { interpolateBridgesAndOrTunnels(); } initLocationIndex(); if (chFactoryDecorator.isEnabled()) chFactoryDecorator.createPreparations(ghStorage, traversalMode); if (!isCHPrepared()) prepareCH(); if (lmFactoryDecorator.isEnabled()) lmFactoryDecorator.createPreparations(ghStorage, traversalMode, locationIndex); loadOrPrepareLM(); }
/** * Does the preparation and creates the location index */ public void postProcessing() { // Later: move this into the GraphStorage.optimize method // Or: Doing it after preparation to optimize shortcuts too. But not possible yet #12 if (sortGraph) { if (ghStorage.isCHPossible() && isCHPrepared()) throw new IllegalArgumentException("Sorting a prepared CHGraph is not possible yet. See #12"); GraphHopperStorage newGraph = GHUtility.newStorage(ghStorage); GHUtility.sortDFS(ghStorage, newGraph); logger.info("graph sorted (" + getMemInfo() + ")"); ghStorage = newGraph; } if (hasElevation()) { interpolateBridgesAndOrTunnels(); } initLocationIndex(); if (chFactoryDecorator.isEnabled()) chFactoryDecorator.createPreparations(ghStorage, traversalMode); if (!isCHPrepared()) prepareCH(); if (lmFactoryDecorator.isEnabled()) lmFactoryDecorator.createPreparations(ghStorage, locationIndex); loadOrPrepareLM(); }