public static String toAddress(Address a) { StringBuilder sb = new StringBuilder(); // if (Strings.isNotEmpty(a.getPostalCode())) { // sb.append(a.getPostalCode()).append(' '); // } // if (Strings.isNotEmpty(a.getCountryName())) { // sb.append(a.getCountryName()).append(' '); // } // if (Strings.isNotEmpty(a.getAdminArea())) { // sb.append(a.getAdminArea()).append(' '); // } // if (Strings.isNotEmpty(a.getSubAdminArea())) { // sb.append(a.getSubAdminArea()).append(' '); // } // if (Strings.isNotEmpty(a.getLocality())) { // sb.append(a.getLocality()).append(' '); // } // if (Strings.isNotEmpty(a.getSubLocality())) { // sb.append(a.getSubLocality()).append(' '); // } // if (Strings.isNotEmpty(a.getThoroughfare())) { // sb.append(a.getThoroughfare()).append(' '); // } for (int i = 0; i <= a.getMaxAddressLineIndex(); i++) { String line = a.getAddressLine(i); if (Strings.isEmpty(line)) { continue; } sb.append(line).append(' '); } return sb.toString().trim(); }
public static void loadTrackings(Calendar c) { trackings.clear(); File file = new File(getTrackingFile(c)); if (!file.exists()) { log.warn(file + "does not exist"); return; } log.info("Loading " + file); float[] results = new float[1]; LineIterator li = null; try { li = Files.lineIterator(file); while (li.hasNext()) { String line = li.next(); if (Strings.isEmpty(line)) { continue; } TrackingData td = Jsons.fromJson(line, TrackingData.class); TrackingData ltd = getLastLocation(); if (ltd != null) { Location.distanceBetween( ltd.getLatitude(), ltd.getLongitude(), td.getLatitude(), td.getLongitude(), results); td.setDistance(results[0]); td.setSpeed(td.getDistance() / DateTimes.subSeconds(td.getDate(), ltd.getDate())); } trackings.add(td); } } catch (IOException e) { log.error(e); } finally { Streams.safeClose(li); } }