diff options
author | Abyss777 <abyss@fox5.ru> | 2017-11-08 15:43:13 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-11-08 15:43:13 +0500 |
commit | 404044342a9fc9891366fa4378b4b1330cbca6c3 (patch) | |
tree | 98a2bfc2b6998e006f874d30ee9976c68345fee1 /src/org/traccar/reports/ReportUtils.java | |
parent | 92f00d0da0dafd08ccf2a623406963e61fcde276 (diff) | |
download | trackermap-server-404044342a9fc9891366fa4378b4b1330cbca6c3.tar.gz trackermap-server-404044342a9fc9891366fa4378b4b1330cbca6c3.tar.bz2 trackermap-server-404044342a9fc9891366fa4378b4b1330cbca6c3.zip |
- Implement synchronous geocoding
- Implement retry geocoding for trips/stops reports
- Implement API for revers geocoding
Diffstat (limited to 'src/org/traccar/reports/ReportUtils.java')
-rw-r--r-- | src/org/traccar/reports/ReportUtils.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index f6f386e99..f0d6d40c2 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -190,13 +190,21 @@ public final class ReportUtils { trip.setStartLat(startTrip.getLatitude()); trip.setStartLon(startTrip.getLongitude()); trip.setStartTime(startTrip.getFixTime()); - trip.setStartAddress(startTrip.getAddress()); + String startAddress = startTrip.getAddress(); + if (startAddress == null && Context.getConfig().getBoolean("report.retryGeocoding")) { + startAddress = Context.getGeocoder().getAddress(startTrip.getLatitude(), startTrip.getLongitude()); + } + trip.setStartAddress(startAddress); trip.setEndPositionId(endTrip.getId()); trip.setEndLat(endTrip.getLatitude()); trip.setEndLon(endTrip.getLongitude()); trip.setEndTime(endTrip.getFixTime()); - trip.setEndAddress(endTrip.getAddress()); + String endAddress = endTrip.getAddress(); + if (endAddress == null && Context.getConfig().getBoolean("report.retryGeocoding")) { + endAddress = Context.getGeocoder().getAddress(startTrip.getLatitude(), startTrip.getLongitude()); + } + trip.setEndAddress(endAddress); trip.setDistance(calculateDistance(startTrip, endTrip, !ignoreOdometer)); trip.setDuration(tripDuration); @@ -224,7 +232,12 @@ public final class ReportUtils { stop.setLatitude(startStop.getLatitude()); stop.setLongitude(startStop.getLongitude()); stop.setStartTime(startStop.getFixTime()); - stop.setAddress(startStop.getAddress()); + String address = startStop.getAddress(); + if (address == null && Context.getConfig().getBoolean("report.retryGeocoding")) { + address = Context.getGeocoder().getAddress(stop.getLatitude(), stop.getLongitude()); + } + stop.setAddress(address); + stop.setEndTime(endStop.getFixTime()); long stopDuration = endStop.getFixTime().getTime() - startStop.getFixTime().getTime(); |