@Override public CmdArgs deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { jsonParser.setCodec(new ObjectMapper()); Map<String, String> args = jsonParser.readValueAs(MAP_STRING_STRING); return new CmdArgs(args); } }
public static CmdArgs readFromSystemProperties() { CmdArgs cmdArgs = new CmdArgs(); for (Entry<Object, Object> e : System.getProperties().entrySet()) { String k = ((String) e.getKey()); String v = ((String) e.getValue()); if (k.startsWith("graphhopper.")) { k = k.substring("graphhopper.".length()); cmdArgs.put(k, v); } } return cmdArgs; }
/** * This method creates a CmdArgs object from the specified string array (a list of key=value pairs). */ public static CmdArgs read(String[] args) { Map<String, String> map = new LinkedHashMap<>(); for (String arg : args) { int index = arg.indexOf("="); if (index <= 0) { continue; } String key = arg.substring(0, index); if (key.startsWith("-")) { key = key.substring(1); } if (key.startsWith("-")) { key = key.substring(1); } String value = arg.substring(index + 1); String old = map.put(toLowerCase(key), value); if (old != null) throw new IllegalArgumentException("Pair '" + toLowerCase(key) + "'='" + value + "' not possible to " + "add to the CmdArgs-object as the key already exists with '" + old + "'"); } return new CmdArgs(map); }
@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()); } }
@Override public CmdArgs deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { jsonParser.setCodec(new ObjectMapper()); Map<String, String> args = jsonParser.readValueAs(MAP_STRING_STRING); return new CmdArgs(args); } }
public static CmdArgs readFromSystemProperties() { CmdArgs cmdArgs = new CmdArgs(); for (Entry<Object, Object> e : System.getProperties().entrySet()) { String k = ((String) e.getKey()); String v = ((String) e.getValue()); if (k.startsWith("graphhopper.")) { k = k.substring("graphhopper.".length()); cmdArgs.put(k, v); } } return cmdArgs; }
public static CmdArgs read(String[] args) { Map<String, String> map = new LinkedHashMap<String, String>(); for (String arg : args) { int index = arg.indexOf("="); if (index <= 0) { continue; } String key = arg.substring(0, index); if (key.startsWith("-")) { key = key.substring(1); } if (key.startsWith("-")) { key = key.substring(1); } String value = arg.substring(index + 1); map.put(key.toLowerCase(), value); } return new CmdArgs(map); }
public static CmdArgs read( String[] args ) { Map<String, String> map = new LinkedHashMap<String, String>(); for (String arg : args) { int index = arg.indexOf("="); if (index <= 0) { continue; } String key = arg.substring(0, index); if (key.startsWith("-")) { key = key.substring(1); } if (key.startsWith("-")) { key = key.substring(1); } String value = arg.substring(index + 1); map.put(key.toLowerCase(), value); } return new CmdArgs(map); }
/** * This method creates a CmdArgs object from the specified string array (a list of key=value pairs). */ public static CmdArgs read(String[] args) { Map<String, String> map = new LinkedHashMap<>(); for (String arg : args) { int index = arg.indexOf("="); if (index <= 0) { continue; } String key = arg.substring(0, index); if (key.startsWith("-")) { key = key.substring(1); } if (key.startsWith("-")) { key = key.substring(1); } String value = arg.substring(index + 1); String old = map.put(toLowerCase(key), value); if (old != null) throw new IllegalArgumentException("Pair '" + toLowerCase(key) + "'='" + value + "' not possible to " + "add to the CmdArgs-object as the key already exists with '" + old + "'"); } return new CmdArgs(map); }
/** * @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; }
@Override public void run(Bootstrap bootstrap, Namespace args) { CmdArgs graphHopperConfiguration = new CmdArgs(); graphHopperConfiguration.put("graph.location", "graph-cache"); seed = args.getLong("seed");
@Override public void run(Bootstrap bootstrap, Namespace args) { CmdArgs graphHopperConfiguration = new CmdArgs(); graphHopperConfiguration.put("graph.location", "graph-cache"); GraphHopper hopper = new GraphHopperOSM().init(graphHopperConfiguration);
@Override public void run(Bootstrap<?> bootstrap, Namespace args) { CmdArgs graphHopperConfiguration = new CmdArgs(); graphHopperConfiguration.put("graph.flag_encoders", args.getString("vehicle")); graphHopperConfiguration.put("datareader.file", args.getString("datasource")); graphHopperConfiguration.put("graph.location", "graph-cache"); GraphHopper hopper = new GraphHopperOSM().init(graphHopperConfiguration); hopper.getCHFactoryDecorator().setEnabled(false); hopper.importOrLoad(); }