args.merge(CmdArgs.readFromSystemProperties()); if (args.has("osmreader.osm")) throw new IllegalArgumentException("Instead osmreader.osm use datareader.file, for other changes see core/files/changelog.txt");
@Override public void run(GraphHopperBundleConfiguration configuration, Environment environment) { configuration.getGraphHopperConfiguration().merge(CmdArgs.readFromSystemProperties()); // If the "?type=gpx" parameter is present, sets a corresponding media type header environment.jersey().register(new TypeGPXFilter()); // Together, these two take care that MultiExceptions thrown from RouteResource // come out as JSON or GPX, depending on the media type environment.jersey().register(new MultiExceptionMapper()); environment.jersey().register(new MultiExceptionGPXMessageBodyWriter()); environment.jersey().register(new IllegalArgumentExceptionMapper()); environment.jersey().register(new GHPointConverterProvider()); if (configuration.getGraphHopperConfiguration().has("gtfs.file")) { // switch to different API implementation when using Pt runPtGraphHopper(configuration.getGraphHopperConfiguration(), environment); } else { runRegularGraphHopper(configuration.getGraphHopperConfiguration(), environment); } }
/** * @param fileStr the file name of config.properties * @param systemProperty the property name of the configuration. E.g. -Dgraphhopper.config */ public static CmdArgs readFromConfig(String fileStr, String systemProperty) throws IOException { if (systemProperty.startsWith("-D")) systemProperty = systemProperty.substring(2); String configLocation = System.getProperty(systemProperty); if (Helper.isEmpty(configLocation)) configLocation = fileStr; Map<String, String> map = new LinkedHashMap<String, String>(); Helper.loadProperties(map, new InputStreamReader(new FileInputStream( new File(configLocation).getAbsoluteFile()), Helper.UTF_CS)); CmdArgs args = new CmdArgs(); args.merge(map); // overwrite with system settings Properties props = System.getProperties(); for (Entry<Object, Object> e : props.entrySet()) { String k = ((String) e.getKey()); String v = ((String) e.getValue()); if (k.startsWith("graphhopper.")) { k = k.substring("graphhopper.".length()); args.put(k, v); } } return args; }
/** * @param fileStr the file name of config.properties * @param systemProperty the property name of the configuration. E.g. -Dgraphhopper.config */ public static CmdArgs readFromConfig( String fileStr, String systemProperty ) throws IOException { if (systemProperty.startsWith("-D")) systemProperty = systemProperty.substring(2); String configLocation = System.getProperty(systemProperty); if (Helper.isEmpty(configLocation)) configLocation = fileStr; Map<String, String> map = new LinkedHashMap<String, String>(); Helper.loadProperties(map, new InputStreamReader(new FileInputStream( new File(configLocation).getAbsoluteFile()), Helper.UTF_CS)); CmdArgs args = new CmdArgs(); args.merge(map); // overwrite with system settings Properties props = System.getProperties(); for (Entry<Object, Object> e : props.entrySet()) { String k = ((String) e.getKey()); String v = ((String) e.getValue()); if (k.startsWith("graphhopper.")) { k = k.substring("graphhopper.".length()); args.put(k, v); } } return 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; }
/** * 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; } }
args.merge(CmdArgs.readFromSystemProperties()); if (args.has("osmreader.osm")) throw new IllegalArgumentException("Instead osmreader.osm use datareader.file, for other changes see core/files/changelog.txt");