mirror of
https://gitlab.com/oeffi/oeffi.git
synced 2025-07-07 06:08:51 +00:00
GeocoderThread: Log the geo coordinate to reverse-lookup.
This commit is contained in:
parent
ee99146c97
commit
e82d4d5df2
1 changed files with 14 additions and 10 deletions
|
@ -82,28 +82,32 @@ public class GeocoderThread extends Thread {
|
||||||
try {
|
try {
|
||||||
if (Geocoder.isPresent()) {
|
if (Geocoder.isPresent()) {
|
||||||
final List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
|
final List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
|
||||||
|
if (addresses.size() >= 1) {
|
||||||
if (addresses.size() >= 1)
|
final Address address = addresses.get(0);
|
||||||
onResult(addresses.get(0));
|
log.info("Geocoder took {} ms, for {}/{} returned {}", System.currentTimeMillis() - startTime,
|
||||||
else
|
latitude, longitude, address);
|
||||||
onFail(new IllegalStateException("No addresses."));
|
onResult(address);
|
||||||
|
} else {
|
||||||
|
final String msg = "Geocoder returned no addresses";
|
||||||
|
log.info(msg);
|
||||||
|
onFail(new IllegalStateException(msg));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
onFail(new UnsupportedOperationException("Geocoder not implemented."));
|
final String msg = "Geocoder not implemented";
|
||||||
|
log.info(msg);
|
||||||
|
onFail(new UnsupportedOperationException(msg));
|
||||||
}
|
}
|
||||||
} catch (final IOException x) {
|
} catch (final IOException x) {
|
||||||
|
log.info("Geocoder failed: {}",x.getMessage());
|
||||||
onFail(x);
|
onFail(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onResult(final Address address) {
|
private void onResult(final Address address) {
|
||||||
log.info("Geocoder took {} ms, returned {}", System.currentTimeMillis() - startTime, address);
|
|
||||||
|
|
||||||
callbackHandler.post(() -> callback.onGeocoderResult(address));
|
callbackHandler.post(() -> callback.onGeocoderResult(address));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onFail(final Exception exception) {
|
private void onFail(final Exception exception) {
|
||||||
log.info("Geocoder failed: {}", exception.getMessage());
|
|
||||||
|
|
||||||
callbackHandler.post(() -> callback.onGeocoderFail(exception));
|
callbackHandler.post(() -> callback.onGeocoderFail(exception));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue