aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/ReverseGeocoderHandler.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-12-31 11:17:50 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-12-31 11:17:50 +1300
commitd13f618ee3b8463d063b7f67e039299560245597 (patch)
treea59177abc8a4f9c74680dd15b3d1c6c0c1231c9d /src/org/traccar/ReverseGeocoderHandler.java
parent2c6c6eccf2c45bf87e16c45e3bac9872f53c12c3 (diff)
downloadtrackermap-server-d13f618ee3b8463d063b7f67e039299560245597.tar.gz
trackermap-server-d13f618ee3b8463d063b7f67e039299560245597.tar.bz2
trackermap-server-d13f618ee3b8463d063b7f67e039299560245597.zip
Implement geocoding error handling
Diffstat (limited to 'src/org/traccar/ReverseGeocoderHandler.java')
-rw-r--r--src/org/traccar/ReverseGeocoderHandler.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/org/traccar/ReverseGeocoderHandler.java b/src/org/traccar/ReverseGeocoderHandler.java
index 88875fb3a..7304234cc 100644
--- a/src/org/traccar/ReverseGeocoderHandler.java
+++ b/src/org/traccar/ReverseGeocoderHandler.java
@@ -22,6 +22,7 @@ import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.MessageEvent;
import org.traccar.geocode.AddressFormat;
import org.traccar.geocode.ReverseGeocoder;
+import org.traccar.helper.Log;
import org.traccar.model.Position;
public class ReverseGeocoderHandler implements ChannelUpstreamHandler {
@@ -49,24 +50,30 @@ public class ReverseGeocoderHandler implements ChannelUpstreamHandler {
return;
}
- final MessageEvent e = (MessageEvent) evt;
- Object message = e.getMessage();
+ final MessageEvent event = (MessageEvent) evt;
+ Object message = event.getMessage();
if (message instanceof Position) {
final Position position = (Position) message;
if (processInvalidPositions || position.getValid()) {
geocoder.getAddress(addressFormat, position.getLatitude(), position.getLongitude(),
new ReverseGeocoder.ReverseGeocoderCallback() {
@Override
- public void onResult(String address) {
+ public void onSuccess(String address) {
position.setAddress(address);
- Channels.fireMessageReceived(ctx, position, e.getRemoteAddress());
+ Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
+ }
+
+ @Override
+ public void onFailure(Throwable e) {
+ Log.warning("Geocoding failed", e);
+ Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
}
});
} else {
- Channels.fireMessageReceived(ctx, position, e.getRemoteAddress());
+ Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
}
} else {
- Channels.fireMessageReceived(ctx, message, e.getRemoteAddress());
+ Channels.fireMessageReceived(ctx, message, event.getRemoteAddress());
}
}