public final boolean isDisablingAllowed() { return disablingAllowed || !isEnabled(); }
public final boolean isCHEnabled() { return chFactoryDecorator.isEnabled(); }
public void createPreparations(GraphHopperStorage ghStorage, TraversalMode traversalMode) { if (!isEnabled() || !preparations.isEmpty()) return; if (weightings.isEmpty()) throw new IllegalStateException("No CH weightings found"); traversalMode = getNodeBase(); for (Weighting weighting : getWeightings()) { PrepareContractionHierarchies tmpPrepareCH = PrepareContractionHierarchies.fromGraphHopperStorage( ghStorage, weighting, traversalMode); tmpPrepareCH.setParams(pMap); addPreparation(tmpPrepareCH); } }
/** * This method applies the changes to the graph specified as feature collection. It does so by locking the routing * to avoid concurrent changes which could result in incorrect routing (like when done while a Dijkstra search) or * also while just reading one edge row (inconsistent edge properties). */ public ChangeGraphResponse changeGraph(Collection<JsonFeature> collection) { // TODO allow calling this method if called before CH preparation if (getCHFactoryDecorator().isEnabled()) throw new IllegalArgumentException("To use the changeGraph API you need to turn off CH"); Lock writeLock = readWriteLock.writeLock(); writeLock.lock(); try { ChangeGraphHelper overlay = createChangeGraphHelper(ghStorage, locationIndex); long updateCount = overlay.applyChanges(encodingManager, collection); return new ChangeGraphResponse(updateCount); } finally { writeLock.unlock(); } }
@Override public RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFactory defaultAlgoFactory, HintsMap map) { boolean disableCH = map.getBool(DISABLE, false); if (!isEnabled() || disablingAllowed && disableCH) return defaultAlgoFactory; if (preparations.isEmpty()) throw new IllegalStateException("No preparations added to this decorator"); if (map.getWeighting().isEmpty()) map.setWeighting(getDefaultWeighting()); String entriesStr = ""; for (PrepareContractionHierarchies p : preparations) { if (p.getWeighting().matches(map)) return p; entriesStr += p.getWeighting() + ", "; } throw new IllegalArgumentException("Cannot find CH RoutingAlgorithmFactory for weighting map " + map + " in entries " + entriesStr); }
protected void prepareCH() { boolean tmpPrepare = chFactoryDecorator.isEnabled(); if (tmpPrepare) { ensureWriteAccess(); ghStorage.freeze(); chFactoryDecorator.prepare(ghStorage.getProperties()); ghStorage.getProperties().put(CH.PREPARE + "done", true); } }
initLMAlgoFactoryDecorator(); if (chFactoryDecorator.isEnabled()) { initCHAlgoFactoryDecorator(); ghStorage = new GraphHopperStorage(chFactoryDecorator.getWeightings(), dir, encodingManager, hasElevation(), ext);
/** * 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(); }
if (hopper.getCHFactoryDecorator().isEnabled()) { isCH = true;
if (hopper.getCHFactoryDecorator().isEnabled()) { final HintsMap chHints = new HintsMap(defaultHints).put(Parameters.CH.DISABLE, false); Weighting pickedWeighting = null;
public final boolean isCHEnabled() { return chFactoryDecorator.isEnabled(); }
public final boolean isDisablingAllowed() { return disablingAllowed || !isEnabled(); }
public final boolean isDisablingAllowed() { return disablingAllowed || !isEnabled(); }
public final boolean isCHEnabled() { return chFactoryDecorator.isEnabled(); }
public final boolean isCHEnabled() { return chFactoryDecorator.isEnabled(); }
public void createPreparations(GraphHopperStorage ghStorage, TraversalMode traversalMode) { if (!isEnabled() || !preparations.isEmpty()) return; if (weightings.isEmpty()) throw new IllegalStateException("No CH weightings found"); traversalMode = getNodeBase(); for (Weighting weighting : getWeightings()) { PrepareContractionHierarchies tmpPrepareCH = new PrepareContractionHierarchies( new GHDirectory("", DAType.RAM_INT), ghStorage, ghStorage.getGraph(CHGraph.class, weighting), traversalMode); tmpPrepareCH.setParams(pMap); addPreparation(tmpPrepareCH); } }
protected void prepareCH() { boolean tmpPrepare = chFactoryDecorator.isEnabled(); if (tmpPrepare) { ensureWriteAccess(); ghStorage.freeze(); chFactoryDecorator.prepare(ghStorage.getProperties()); ghStorage.getProperties().put(CH.PREPARE + "done", true); } }
protected void prepareCH() { boolean tmpPrepare = chFactoryDecorator.isEnabled(); if (tmpPrepare) { ensureWriteAccess(); if (chFactoryDecorator.getPreparationThreads() > 1 && dataAccessType.isMMap() && !dataAccessType.isSynched()) throw new IllegalStateException("You cannot execute CH preparation in parallel for MMAP without synching! Specify MMAP_SYNC or use 1 thread only"); ghStorage.freeze(); chFactoryDecorator.prepare(ghStorage.getProperties()); ghStorage.getProperties().put(CH.PREPARE + "done", true); } }
protected void prepare() { boolean tmpPrepare = chFactoryDecorator.isEnabled(); if (tmpPrepare) { ensureWriteAccess(); if (chFactoryDecorator.getPreparationThreads() > 1 && dataAccessType.isMMap() && !dataAccessType.isSynched()) throw new IllegalStateException("You cannot execute CH preparation in parallel for MMAP without synching! Specify MMAP_SYNC or use 1 thread only"); ghStorage.freeze(); chFactoryDecorator.prepare(ghStorage.getProperties()); } ghStorage.getProperties().put("prepare.done", tmpPrepare); }