@Override public HintsMap put(String key, Object str) { super.put(key, str); return this; }
static List<FlagEncoder> parseEncoderString(FlagEncoderFactory factory, String encoderList) { if (encoderList.contains(":")) throw new IllegalArgumentException("EncodingManager does no longer use reflection instantiate encoders directly."); if (!encoderList.equals(toLowerCase(encoderList))) throw new IllegalArgumentException("Since 0.7 EncodingManager does no longer accept upper case profiles: " + encoderList); String[] entries = encoderList.split(","); List<FlagEncoder> resultEncoders = new ArrayList<>(); for (String entry : entries) { entry = toLowerCase(entry.trim()); if (entry.isEmpty()) continue; String entryVal = ""; if (entry.contains("|")) { entryVal = entry; entry = entry.split("\\|")[0]; } PMap configuration = new PMap(entryVal); FlagEncoder fe = factory.createFlagEncoder(entry, configuration); if (configuration.has("version") && fe.getVersion() != configuration.getInt("version", -1)) throw new IllegalArgumentException("Encoder " + entry + " was used in version " + configuration.getLong("version", -1) + ", but current version is " + fe.getVersion()); resultEncoders.add(fe); } return resultEncoders; }
public boolean getBool(String key, boolean _default) { String str = get(key); if (!Helper.isEmpty(str)) { try { return Boolean.parseBoolean(str); } catch (Exception ex) { } } return _default; }
public RoutingAlgorithm getDecoratedAlgorithm(Graph qGraph, RoutingAlgorithm algo, AlgorithmOptions opts) { int activeLM = Math.max(1, opts.getHints().getInt(Landmark.ACTIVE_COUNT, defaultActiveLandmarks)); if (algo instanceof AStar) { if (!lms.isInitialized()) throw new IllegalStateException("Initialize landmark storage before creating algorithms"); double epsilon = opts.getHints().getDouble(Parameters.Algorithms.AStar.EPSILON, 1); AStar astar = (AStar) algo; astar.setApproximation(new LMApproximator(qGraph, this.graph.getNodes(), lms, activeLM, lms.getFactor(), false). throw new IllegalStateException("Initialize landmark storage before creating algorithms"); double epsilon = opts.getHints().getDouble(Parameters.Algorithms.AStarBi.EPSILON, 1); AStarBidirection astarbi = (AStarBidirection) algo; astarbi.setApproximation(new LMApproximator(qGraph, this.graph.getNodes(), lms, activeLM, lms.getFactor(), false). throw new IllegalStateException("Initialize landmark storage before creating algorithms"); double epsilon = opts.getHints().getDouble(Parameters.Algorithms.AStarBi.EPSILON, 1); AlternativeRoute altRoute = (AlternativeRoute) algo; altRoute.setApproximation(new LMApproximator(qGraph, this.graph.getNodes(), lms, activeLM, lms.getFactor(), false).
public MotorcycleFlagEncoder(String propertiesStr) { this(new PMap(propertiesStr)); }
public DataFlagEncoder(PMap properties) { this((int) properties.getLong("speed_bits", 5), properties.getDouble("speed_factor", 5), properties.getBool("turn_costs", false) ? 1 : 0); this.properties = properties; this.setStoreHeight(properties.getBool("store_height", false)); this.setStoreWeight(properties.getBool("store_weight", false)); this.setStoreWidth(properties.getBool("store_width", false)); this.setSpatialRules(properties.getInt("spatial_rules", 0)); }
String type = splitTypeVariant[0].trim(); String variant = splitTypeVariant.length>1? splitTypeVariant[1].trim():""; PMap propertiesMap = new PMap(encoderString); if (propertiesMap.has("version") && encoder.getVersion()!=propertiesMap.getInt("version", -1)){ properties.close(); throw new RuntimeException("Graph was built with wrong encoder version - probably built using an older version of the graphhopper library?");
public static WeightApproximator getApproximation(String prop, AlgorithmOptions opts, NodeAccess na) { String approxAsStr = opts.getHints().get(prop + ".approximation", "BeelineSimplification"); double epsilon = opts.getHints().getDouble(prop + ".epsilon", 1); BeelineWeightApproximator approx = new BeelineWeightApproximator(na, opts.getWeighting()); approx.setEpsilon(epsilon); if ("BeelineSimplification".equals(approxAsStr)) approx.setDistanceCalc(Helper.DIST_PLANE); else if ("BeelineAccurate".equals(approxAsStr)) approx.setDistanceCalc(Helper.DIST_EARTH); else throw new IllegalArgumentException("Approximation " + approxAsStr + " not found in " + RoutingAlgorithmFactorySimple.class.getName()); return approx; } }
public FastestWeighting(FlagEncoder encoder, PMap map) { super(encoder); headingPenalty = map.getDouble(Routing.HEADING_PENALTY, Routing.DEFAULT_HEADING_PENALTY); headingPenaltyMillis = Math.round(headingPenalty * 1000); maxSpeed = encoder.getMaxSpeed() / SPEED_CONV; }
@Override public String toString() { return getMap().toString(); } }
public PrepareContractionHierarchies setParams(PMap pMap) { this.pMap = pMap; params.setPeriodicUpdatesPercentage(pMap.getInt(PERIODIC_UPDATES, params.getPeriodicUpdatesPercentage())); params.setLastNodesLazyUpdatePercentage(pMap.getInt(LAST_LAZY_NODES_UPDATES, params.getLastNodesLazyUpdatePercentage())); params.setNeighborUpdatePercentage(pMap.getInt(NEIGHBOR_UPDATES, params.getNeighborUpdatePercentage())); params.setNodesContractedPercentage(pMap.getInt(CONTRACTED_NODES, params.getNodesContractedPercentage())); params.setLogMessagesPercentage(pMap.getInt(LOG_MESSAGES, params.getLogMessagesPercentage())); return this; }
visitedNodesSum.addAndGet(rsp.getHints().getLong("visited_nodes.sum", 0)); long dist = (long) arsp.getDistance(); distSum.addAndGet(dist);
private AbstractBidirAlgo doCreateAlgo(Graph graph, AlgorithmOptions opts) { if (ASTAR_BI.equals(opts.getAlgorithm())) { return new AStarBidirectionCH(graph, prepareWeighting, traversalMode) .setApproximation(RoutingAlgorithmFactorySimple.getApproximation(ASTAR_BI, opts, graph.getNodeAccess())); } else if (DIJKSTRA_BI.equals(opts.getAlgorithm())) { if (opts.getHints().getBool("stall_on_demand", true)) { return new DijkstraBidirectionCH(graph, prepareWeighting, traversalMode); } else { return new DijkstraBidirectionCHNoSOD(graph, prepareWeighting, traversalMode); } } else { throw new IllegalArgumentException("Algorithm " + opts.getAlgorithm() + " not supported for Contraction Hierarchies. Try with ch.disable=true"); } }