/** * This creates a date formatter for yyyy-MM-dd'T'HH:mm:ss'Z' which is has to be identical to * buildDate used in pom.xml */ public static DateFormat createFormatter() { return createFormatter("yyyy-MM-dd'T'HH:mm:ss'Z'"); }
public GHDirectory(String _location, DAType defaultType) { this.defaultType = defaultType; if (isEmpty(_location)) _location = new File("").getAbsolutePath(); if (!_location.endsWith("/")) _location += "/"; location = _location; File dir = new File(location); if (dir.exists() && !dir.isDirectory()) throw new RuntimeException("file '" + dir + "' exists but is not a directory"); }
protected String getJson(String url) throws IOException { Request okRequest = new Request.Builder().url(url).build(); ResponseBody body = null; try { body = downloader.newCall(okRequest).execute().body(); return body.string(); } finally { Helper.close(body); } }
public static String getMemInfo() { return "totalMB:" + getTotalMB() + ", usedMB:" + getUsedMB(); }
String get(String key) { if (Helper.isEmpty(key)) return ""; // query accepts camelCase and under_score String val = map.get(Helper.camelCaseToUnderScore(key)); if (val == null) return ""; return val; }
@Override public String tr(String key, Object... params) { String val = map.get(toLowerCase(key)); if (isEmpty(val)) return key; return String.format(Locale.ROOT, val, params); }
/** * @return array containing this bounding box. Attention: GeoJson is lon,lat! If 3D is gets even * worse: lon,lat,ele */ public List<Double> toGeoJson() { List<Double> list = new ArrayList<>(4); list.add(Helper.round6(minLon)); list.add(Helper.round6(minLat)); // hmh if (elevation) list.add(Helper.round2(minEle)); list.add(Helper.round6(maxLon)); list.add(Helper.round6(maxLat)); if (elevation) list.add(Helper.round2(maxEle)); return list; }
if (!isEmpty(tmpOsmFile)) dataReaderFile = tmpOsmFile; if (isEmpty(graphHopperFolder) && isEmpty(ghLocation)) { if (isEmpty(dataReaderFile)) throw new IllegalArgumentException("If no graph.location is provided you need to specify an OSM file."); graphHopperFolder = pruneFileEnd(dataReaderFile) + "-gh"; String eleProviderStr = toLowerCase(args.get("graph.elevation.provider", "noop")); this.smoothElevation = args.getBool("graph.elevation.smoothing", false);
public GHRequest setLocale(String localeStr) { return setLocale(Helper.getLocale(localeStr)); }
String timeStamp = new SimpleDateFormat("yyyy-MM-dd_HH_mm_ss").format(new Date()); put("measurement.timestamp", timeStamp); if (isEmpty(propLocation)) { propLocation = "measurement" + timeStamp + ".properties"; put("measurement.time", sw.stop().getMillis()); System.gc(); put("measurement.totalMB", getTotalMB()); put("measurement.usedMB", getUsedMB());
if (!Helper.isEmpty(tmpOsmFile)) dataReaderFile = tmpOsmFile; if (Helper.isEmpty(graphHopperFolder) && Helper.isEmpty(ghLocation)) { if (Helper.isEmpty(dataReaderFile)) throw new IllegalArgumentException("You need to specify an OSM file."); graphHopperFolder = Helper.pruneFileEnd(dataReaderFile) + "-gh";
public void createRteptBlock(StringBuilder output, Instruction instruction, Instruction nextI) { output.append("\n<rtept lat=\"").append(Helper.round6(instruction.getFirstLat())). append("\" lon=\"").append(Helper.round6(instruction.getFirstLon())).append("\">"); if (!instruction.getName().isEmpty()) output.append("<desc>").append(simpleXMLEscape(instruction.getTurnDescription(tr))).append("</desc>"); output.append("<extensions>"); output.append("<gh:distance>").append(Helper.round(instruction.getDistance(), 1)).append("</gh:distance>"); output.append("<gh:time>").append(instruction.getTime()).append("</gh:time>"); String direction = instruction.calcDirection(nextI); if (!direction.isEmpty()) output.append("<gh:direction>").append(direction).append("</gh:direction>"); double azimuth = instruction.calcAzimuth(nextI); if (!Double.isNaN(azimuth)) output.append("<gh:azimuth>").append(Helper.round2(azimuth)).append("</gh:azimuth>"); output.append("<gh:sign>").append(instruction.getSign()).append("</gh:sign>"); output.append("</extensions>"); output.append("</rtept>"); }
public static boolean removeDir(File file) { if (!file.exists()) { return true; } if (file.isDirectory()) { for (File f : file.listFiles()) { removeDir(f); } } return file.delete(); }
@Override public void run() { if (plm.loadExisting()) return; LOGGER.info(tmpCounter + "/" + getPreparations().size() + " calling LM prepare.doWork for " + plm.getWeighting() + " ... (" + getMemInfo() + ")"); prepared.set(true); Thread.currentThread().setName(name); plm.doWork(); properties.put(Landmark.PREPARE + "date." + name, createFormatter().format(new Date())); } }, name);
protected void flush() { logger.info("flushing graph " + ghStorage.toString() + ", details:" + ghStorage.toDetailsString() + ", " + getMemInfo() + ")"); ghStorage.flush(); logger.info("flushed graph " + getMemInfo() + ")"); fullyLoaded = true; }
private void logStats(int updateCounter) { logger.info(String.format(Locale.ROOT, "nodes: %10s, shortcuts: %10s, updates: %2d, checked-nodes: %10s, %s, %s, %s", nf(sortedNodes.getSize()), nf(nodeContractor.getAddedShortcutsCount()), updateCounter, nf(checkCounter), getTimesAsString(), nodeContractor.getStatisticsString(), Helper.getMemInfo())); }
public String createGPX(String trackName, long startTimeMillis, boolean includeElevation, boolean withRoute, boolean withTrack, boolean withWayPoints, String version) { DateFormat formatter = Helper.createFormatter(); gpxOutput.append("\" lon=\"").append(decimalFormat.format(entry.getLon())).append("\">"); if (includeElevation) gpxOutput.append("<ele>").append(Helper.round2(entry.getEle())).append("</ele>"); gpxOutput.append("<time>").append(formatter.format(startTimeMillis + entry.getTime())).append("</time>"); gpxOutput.append("</trkpt>");
public void unzip(String from, boolean remove) throws IOException { String to = Helper.pruneFileEnd(from); unzip(from, to, remove); }