@Override public void init(CmdArgs args) { setPreparationThreads(args.getInt(Parameters.Landmark.PREPARE + "threads", getPreparationThreads())); landmarkCount = args.getInt(Parameters.Landmark.COUNT, landmarkCount); activeLandmarkCount = args.getInt(Landmark.ACTIVE_COUNT_DEFAULT, Math.min(8, landmarkCount)); logDetails = args.getBool(Landmark.PREPARE + "log_details", false); minNodes = args.getInt(Landmark.PREPARE + "min_network_size", -1); for (String loc : args.get(Landmark.PREPARE + "suggestions_location", "").split(",")) { if (!loc.trim().isEmpty()) lmSuggestionsLocations.add(loc.trim()); } String lmWeightingsStr = args.get(Landmark.PREPARE + "weightings", ""); if (!lmWeightingsStr.isEmpty() && !lmWeightingsStr.equalsIgnoreCase("no")) { List<String> tmpLMWeightingList = Arrays.asList(lmWeightingsStr.split(",")); setWeightingsAsStrings(tmpLMWeightingList); } boolean enableThis = !weightingsAsStrings.isEmpty(); setEnabled(enableThis); if (enableThis) setDisablingAllowed(args.getBool(Landmark.INIT_DISABLING_ALLOWED, isDisablingAllowed())); }
public GraphHopperManaged(CmdArgs configuration, ObjectMapper objectMapper) { String splitAreaLocation = configuration.get(Parameters.Landmark.PREPARE + "split_area_location", ""); JsonFeatureCollection landmarkSplittingFeatureCollection; try (Reader reader = splitAreaLocation.isEmpty() ? new InputStreamReader(LandmarkStorage.class.getResource("map.geo.json").openStream(), UTF_CS) : new InputStreamReader(new FileInputStream(splitAreaLocation), UTF_CS)) { landmarkSplittingFeatureCollection = objectMapper.readValue(reader, JsonFeatureCollection.class); } catch (IOException e1) { logger.error("Problem while reading border map GeoJSON. Skipping this.", e1); landmarkSplittingFeatureCollection = null; } graphHopper = new GraphHopperOSM(landmarkSplittingFeatureCollection).forServer(); String spatialRuleLocation = configuration.get("spatial_rules.location", ""); if (!spatialRuleLocation.isEmpty()) { final BBox maxBounds = BBox.parseBBoxString(configuration.get("spatial_rules.max_bbox", "-180, 180, -90, 90")); try (final InputStreamReader reader = new InputStreamReader(new FileInputStream(spatialRuleLocation), UTF_CS)) { JsonFeatureCollection jsonFeatureCollection = objectMapper.readValue(reader, JsonFeatureCollection.class); SpatialRuleLookupHelper.buildAndInjectSpatialRuleIntoGH(graphHopper, maxBounds, jsonFeatureCollection); } catch (IOException e) { throw new RuntimeException(e); } } graphHopper.init(configuration); }
String tmpOsmFile = args.get("datareader.file", ""); if (!isEmpty(tmpOsmFile)) dataReaderFile = tmpOsmFile; String graphHopperFolder = args.get("graph.location", ""); if (isEmpty(graphHopperFolder) && isEmpty(ghLocation)) { if (isEmpty(dataReaderFile)) String graphDATypeStr = args.get("graph.dataaccess", "RAM_STORE"); dataAccessType = DAType.fromString(graphDATypeStr); removeZipped = args.getBool("graph.remove_zipped", removeZipped); int bytesForFlags = args.getInt("graph.bytes_for_flags", 4); String flagEncodersStr = args.get("graph.flag_encoders", ""); if (!flagEncodersStr.isEmpty()) setEncodingManager(new EncodingManager(flagEncoderFactory, flagEncodersStr, bytesForFlags)); if (args.get("graph.locktype", "native").equals("simple")) lockFactory = new SimpleFSLockFactory(); else String eleProviderStr = toLowerCase(args.get("graph.elevation.provider", "noop")); this.smoothElevation = args.getBool("graph.elevation.smoothing", false); String cacheDirStr = args.get("graph.elevation.cache_dir", ""); if (cacheDirStr.isEmpty()) cacheDirStr = args.get("graph.elevation.cachedir", ""); String baseURL = args.get("graph.elevation.base_url", "");
@Override public void init(CmdArgs args) { // throw explicit error for deprecated configs if (!args.get("prepare.threads", "").isEmpty()) throw new IllegalStateException("Use " + CH.PREPARE + "threads instead of prepare.threads"); if (!args.get("prepare.chWeighting", "").isEmpty() || !args.get("prepare.chWeightings", "").isEmpty()) throw new IllegalStateException("Use " + CH.PREPARE + "weightings and a comma separated list instead of prepare.chWeighting or prepare.chWeightings"); setPreparationThreads(args.getInt(CH.PREPARE + "threads", getPreparationThreads())); // default is enabled & fastest String chWeightingsStr = args.get(CH.PREPARE + "weightings", ""); if ("no".equals(chWeightingsStr) || "false".equals(chWeightingsStr)) { // default is fastest and we need to clear this explicitly weightingsAsStrings.clear(); } else if (!chWeightingsStr.isEmpty()) { List<String> tmpCHWeightingList = Arrays.asList(chWeightingsStr.split(",")); setWeightingsAsStrings(tmpCHWeightingList); } boolean enableThis = !weightingsAsStrings.isEmpty(); setEnabled(enableThis); if (enableThis) setDisablingAllowed(args.getBool(CH.INIT_DISABLING_ALLOWED, isDisablingAllowed())); pMap = args; }
@Override public void run(GraphHopperServerConfiguration configuration, Environment environment) { environment.jersey().register(new RootResource()); environment.servlets().addFilter("cors", CORSFilter.class).addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "*"); environment.servlets().addFilter("ipfilter", new IPFilter(configuration.getGraphHopperConfiguration().get("jetty.whiteips", ""), configuration.getGraphHopperConfiguration().get("jetty.blackips", ""))).addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "*"); } }
void start(CmdArgs args) { String graphLocation = args.get("graph.location", ""); String propLocation = args.get("measurement.location", ""); boolean cleanGraph = args.getBool("measurement.clean", false); String summaryLocation = args.get("measurement.summaryfile", ""); String timeStamp = new SimpleDateFormat("yyyy-MM-dd_HH_mm_ss").format(new Date()); put("measurement.timestamp", timeStamp); String gitCommit = args.get("measurement.gitinfo", ""); int count = args.getInt("measurement.count", 5000); String vehicleStr = args.get("graph.flag_encoders", "car"); FlagEncoder encoder = hopper.getEncodingManager().getEncoder(vehicleStr);
@Override public void init(CmdArgs args) { setPreparationThreads(args.getInt(Parameters.Landmark.PREPARE + "threads", getPreparationThreads())); landmarkCount = args.getInt(Parameters.Landmark.COUNT, landmarkCount); activeLandmarkCount = args.getInt(Landmark.ACTIVE_COUNT_DEFAULT, Math.min(8, landmarkCount)); for (String loc : args.get("prepare.lm.suggestions_location", "").split(",")) { if (!loc.trim().isEmpty()) lmSuggestionsLocations.add(loc.trim()); } String lmWeightingsStr = args.get(Landmark.PREPARE + "weightings", ""); if (!lmWeightingsStr.isEmpty()) { List<String> tmpLMWeightingList = Arrays.asList(lmWeightingsStr.split(",")); setWeightingsAsStrings(tmpLMWeightingList); } boolean enableThis = !weightingsAsStrings.isEmpty(); setEnabled(enableThis); if (enableThis) setDisablingAllowed(args.getBool(Landmark.INIT_DISABLING_ALLOWED, isDisablingAllowed())); }
private void runPtGraphHopper(CmdArgs configuration, Environment environment) { final PtFlagEncoder ptFlagEncoder = new PtFlagEncoder(); final GHDirectory ghDirectory = GraphHopperGtfs.createGHDirectory(configuration.get("graph.location", "target/tmp")); final GtfsStorage gtfsStorage = GraphHopperGtfs.createGtfsStorage(); final EncodingManager encodingManager = new EncodingManager(Arrays.asList(ptFlagEncoder, new FootFlagEncoder(), new CarFlagEncoder()), 8); final GraphHopperStorage graphHopperStorage = GraphHopperGtfs.createOrLoad(ghDirectory, encodingManager, ptFlagEncoder, gtfsStorage, configuration.has("gtfs.file") ? Arrays.asList(configuration.get("gtfs.file", "").split(",")) : Collections.emptyList(), configuration.has("datareader.file") ? Arrays.asList(configuration.get("datareader.file", "").split(",")) : Collections.emptyList()); final TranslationMap translationMap = GraphHopperGtfs.createTranslationMap(); final LocationIndex locationIndex = GraphHopperGtfs.createOrLoadIndex(ghDirectory, graphHopperStorage);
@Override public void init(CmdArgs args) { // throw explicit error for deprecated configs if (!args.get("prepare.threads", "").isEmpty()) throw new IllegalStateException("Use " + CH.PREPARE + "threads instead of prepare.threads"); if (!args.get("prepare.chWeighting", "").isEmpty() || !args.get("prepare.chWeightings", "").isEmpty()) throw new IllegalStateException("Use " + CH.PREPARE + "weightings and a comma separated list instead of prepare.chWeighting or prepare.chWeightings"); setPreparationThreads(args.getInt(CH.PREPARE + "threads", getPreparationThreads())); // default is enabled & fastest String chWeightingsStr = args.get(CH.PREPARE + "weightings", ""); if ("no".equals(chWeightingsStr)) { // default is fastest and we need to clear this explicitely weightingsAsStrings.clear(); } else if (!chWeightingsStr.isEmpty()) { List<String> tmpCHWeightingList = Arrays.asList(chWeightingsStr.split(",")); setWeightingsAsStrings(tmpCHWeightingList); } boolean enableThis = !weightingsAsStrings.isEmpty(); setEnabled(enableThis); if (enableThis) setDisablingAllowed(args.getBool(CH.INIT_DISABLING_ALLOWED, isDisablingAllowed())); setPreparationPeriodicUpdates(args.getInt(CH.PREPARE + "updates.periodic", getPreparationPeriodicUpdates())); setPreparationLazyUpdates(args.getInt(CH.PREPARE + "updates.lazy", getPreparationLazyUpdates())); setPreparationNeighborUpdates(args.getInt(CH.PREPARE + "updates.neighbor", getPreparationNeighborUpdates())); setPreparationContractedNodes(args.getInt(CH.PREPARE + "contracted_nodes", getPreparationContractedNodes())); setPreparationLogMessages(args.getDouble(CH.PREPARE + "log_messages", getPreparationLogMessages())); }
@Override public void init(CmdArgs args) { setPreparationThreads(args.getInt(Parameters.Landmark.PREPARE + "threads", getPreparationThreads())); landmarkCount = args.getInt(Parameters.Landmark.COUNT, landmarkCount); activeLandmarkCount = args.getInt(Landmark.ACTIVE_COUNT_DEFAULT, Math.min(8, landmarkCount)); logDetails = args.getBool(Landmark.PREPARE + "log_details", false); minNodes = args.getInt(Landmark.PREPARE + "min_network_size", -1); for (String loc : args.get(Landmark.PREPARE + "suggestions_location", "").split(",")) { if (!loc.trim().isEmpty()) lmSuggestionsLocations.add(loc.trim()); } String lmWeightingsStr = args.get(Landmark.PREPARE + "weightings", ""); if (!lmWeightingsStr.isEmpty() && !lmWeightingsStr.equalsIgnoreCase("no")) { List<String> tmpLMWeightingList = Arrays.asList(lmWeightingsStr.split(",")); setWeightingsAsStrings(tmpLMWeightingList); } boolean enableThis = !weightingsAsStrings.isEmpty(); setEnabled(enableThis); if (enableThis) setDisablingAllowed(args.getBool(Landmark.INIT_DISABLING_ALLOWED, isDisablingAllowed())); }
/** * Command line configuration overwrites the ones in the config file. * <p> * * @return a new CmdArgs object if necessary. */ public static CmdArgs readFromConfigAndMerge(CmdArgs args, String configKey, String configSysAttr) { String configVal = args.get(configKey, ""); if (!Helper.isEmpty(configVal)) { try { CmdArgs tmp = CmdArgs.readFromConfig(configVal, configSysAttr); tmp.merge(args); return tmp; } catch (Exception ex) { throw new RuntimeException(ex); } } return args; }
public void init( CmdArgs args ) { setPreparationThreads(args.getInt("prepare.threads", getPreparationThreads())); String deprecatedWeightingConfig = args.get("prepare.chWeighting", ""); if (!deprecatedWeightingConfig.isEmpty()) throw new IllegalStateException("Use prepare.ch.weightings and a comma separated list instead of prepare.chWeighting"); // default is enabled & fastest String chWeightingsStr = args.get("prepare.ch.weightings", ""); // backward compatibility if (chWeightingsStr.isEmpty()) chWeightingsStr = args.get("prepare.chWeightings", ""); if ("no".equals(chWeightingsStr)) { // default is fastest and we need to clear this explicitely weightingsAsStrings.clear(); } else if (!chWeightingsStr.isEmpty()) { List<String> tmpCHWeightingList = Arrays.asList(chWeightingsStr.split(",")); setWeightingsAsStrings(tmpCHWeightingList); } boolean enableThis = !weightingsAsStrings.isEmpty(); setEnabled(enableThis); if (enableThis) setDisablingAllowed(args.getBool(CH.INIT_DISABLING_ALLOWED, isDisablingAllowed())); setPreparationPeriodicUpdates(args.getInt("prepare.updates.periodic", getPreparationPeriodicUpdates())); setPreparationLazyUpdates(args.getInt("prepare.updates.lazy", getPreparationLazyUpdates())); setPreparationNeighborUpdates(args.getInt("prepare.updates.neighbor", getPreparationNeighborUpdates())); setPreparationContractedNodes(args.getInt("prepare.contracted_nodes", getPreparationContractedNodes())); setPreparationLogMessages(args.getDouble("prepare.log_messages", getPreparationLogMessages())); }
@Override public void init(CmdArgs args) { // throw explicit error for deprecated configs if (!args.get("prepare.threads", "").isEmpty()) throw new IllegalStateException("Use " + CH.PREPARE + "threads instead of prepare.threads"); if (!args.get("prepare.chWeighting", "").isEmpty() || !args.get("prepare.chWeightings", "").isEmpty()) throw new IllegalStateException("Use " + CH.PREPARE + "weightings and a comma separated list instead of prepare.chWeighting or prepare.chWeightings"); setPreparationThreads(args.getInt(CH.PREPARE + "threads", getPreparationThreads())); // default is enabled & fastest String chWeightingsStr = args.get(CH.PREPARE + "weightings", ""); if ("no".equals(chWeightingsStr) || "false".equals(chWeightingsStr)) { // default is fastest and we need to clear this explicitly weightingsAsStrings.clear(); } else if (!chWeightingsStr.isEmpty()) { List<String> tmpCHWeightingList = Arrays.asList(chWeightingsStr.split(",")); setWeightingsAsStrings(tmpCHWeightingList); } boolean enableThis = !weightingsAsStrings.isEmpty(); setEnabled(enableThis); if (enableThis) setDisablingAllowed(args.getBool(CH.INIT_DISABLING_ALLOWED, isDisablingAllowed())); pMap = args; }
/** * Command line configuration overwrites the ones in the config file. * <p> * @return a new CmdArgs object if necessary. */ public static CmdArgs readFromConfigAndMerge( CmdArgs args, String configKey, String configSysAttr ) { String configVal = args.get(configKey, ""); if (!Helper.isEmpty(configVal)) { try { CmdArgs tmp = CmdArgs.readFromConfig(configVal, configSysAttr); tmp.merge(args); return tmp; } catch (Exception ex) { throw new RuntimeException(ex); } } return args; } }
String tmpOsmFile = args.get("datareader.file", ""); if (!Helper.isEmpty(tmpOsmFile)) dataReaderFile = tmpOsmFile; String graphHopperFolder = args.get("graph.location", ""); if (Helper.isEmpty(graphHopperFolder) && Helper.isEmpty(ghLocation)) { if (Helper.isEmpty(dataReaderFile)) String graphDATypeStr = args.get("graph.dataaccess", "RAM_STORE"); dataAccessType = DAType.fromString(graphDATypeStr); removeZipped = args.getBool("graph.remove_zipped", removeZipped); int bytesForFlags = args.getInt("graph.bytes_for_flags", 4); String flagEncodersStr = args.get("graph.flag_encoders", ""); if (!flagEncodersStr.isEmpty()) setEncodingManager(new EncodingManager(flagEncoderFactory, flagEncodersStr, bytesForFlags)); if (args.get("graph.locktype", "native").equals("simple")) lockFactory = new SimpleFSLockFactory(); else String eleProviderStr = args.get("graph.elevation.provider", "noop").toLowerCase(); String cacheDirStr = args.get("graph.elevation.cache_dir", ""); if (cacheDirStr.isEmpty()) cacheDirStr = args.get("graph.elevation.cachedir", ""); String baseURL = args.get("graph.elevation.base_url", ""); if (baseURL.isEmpty())
public static void buildAndInjectSpatialRuleIntoGH(GraphHopper graphHopper, CmdArgs args) { String spatialRuleLocation = args.get("spatial_rules.location", ""); if (!spatialRuleLocation.isEmpty()) { try { final BBox maxBounds = BBox.parseBBoxString(args.get("spatial_rules.max_bbox", "-180, 180, -90, 90")); final InputStreamReader reader = new InputStreamReader(new FileInputStream(spatialRuleLocation), UTF_CS); final SpatialRuleLookup index = SpatialRuleLookupBuilder.buildIndex(new GHJsonFactory().create().fromJson(reader, JsonFeatureCollection.class), "ISO_A3", new CountriesSpatialRuleFactory(), .1, maxBounds); logger.info("Set spatial rule lookup with " + index.size() + " rules"); final FlagEncoderFactory oldFEF = graphHopper.getFlagEncoderFactory(); graphHopper.setFlagEncoderFactory(new FlagEncoderFactory() { @Override public FlagEncoder createFlagEncoder(String name, PMap configuration) { if (name.equals(GENERIC)) { return new DataFlagEncoder(configuration).setSpatialRuleLookup(index); } return oldFEF.createFlagEncoder(name, configuration); } }); } catch (IOException ex) { throw new RuntimeException(ex); } } }
String tmpOsmFile = args.get("osmreader.osm", ""); if (!Helper.isEmpty(tmpOsmFile)) osmFile = tmpOsmFile; String graphHopperFolder = args.get("graph.location", ""); if (Helper.isEmpty(graphHopperFolder) && Helper.isEmpty(ghLocation)) String graphDATypeStr = args.get("graph.dataaccess", "RAM_STORE"); dataAccessType = DAType.fromString(graphDATypeStr); removeZipped = args.getBool("graph.remove_zipped", removeZipped); int bytesForFlags = args.getInt("graph.bytes_for_flags", 4); String flagEncodersStr = args.get("graph.flag_encoders", ""); if (!flagEncodersStr.isEmpty()) setEncodingManager(new EncodingManager(flagEncoderFactory, flagEncodersStr, bytesForFlags)); if (args.get("graph.locktype", "native").equals("simple")) lockFactory = new SimpleFSLockFactory(); else String eleProviderStr = args.get("graph.elevation.provider", "noop").toLowerCase(); String cacheDirStr = args.get("graph.elevation.cache_dir", ""); if (cacheDirStr.isEmpty()) cacheDirStr = args.get("graph.elevation.cachedir", ""); String baseURL = args.get("graph.elevation.base_url", ""); if (baseURL.isEmpty()) args.get("graph.elevation.baseurl", "");
@Override public void run(GraphHopperServerConfiguration configuration, Environment environment) { environment.jersey().register(new RootResource()); environment.servlets().addFilter("cors", CORSFilter.class).addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "*"); environment.servlets().addFilter("ipfilter", new IPFilter(configuration.getGraphHopperConfiguration().get("jetty.whiteips", ""), configuration.getGraphHopperConfiguration().get("jetty.blackips", ""))).addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "*"); } }
hopper.getCHFactoryDecorator().setEnabled(false); System.out.println("loading graph from cache"); hopper.load(graphHopperConfiguration.get("graph.location", "graph-cache"));