aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/ReverseGeocoderHandler.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2012-08-12 13:28:41 +0400
committerAnton Tananaev <anton.tananaev@gmail.com>2012-08-12 13:28:41 +0400
commitafa255e4c319482a486230308214374afe842bb8 (patch)
treef5541a695a36b0499f11c7e99334b2099a80a460 /src/org/traccar/ReverseGeocoderHandler.java
parentff01e06a078e0e53791f7889f777e821d65c1766 (diff)
downloadtrackermap-server-afa255e4c319482a486230308214374afe842bb8.tar.gz
trackermap-server-afa255e4c319482a486230308214374afe842bb8.tar.bz2
trackermap-server-afa255e4c319482a486230308214374afe842bb8.zip
Fix reverse geocoding (fix #37)
Diffstat (limited to 'src/org/traccar/ReverseGeocoderHandler.java')
-rw-r--r--src/org/traccar/ReverseGeocoderHandler.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/org/traccar/ReverseGeocoderHandler.java b/src/org/traccar/ReverseGeocoderHandler.java
index a7123bcec..74dfd10e9 100644
--- a/src/org/traccar/ReverseGeocoderHandler.java
+++ b/src/org/traccar/ReverseGeocoderHandler.java
@@ -15,16 +15,17 @@
*/
package org.traccar;
+import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;
-import org.jboss.netty.channel.SimpleChannelHandler;
+import org.jboss.netty.handler.codec.oneone.OneToOneDecoder;
import org.traccar.geocode.ReverseGeocoder;
import org.traccar.model.Position;
/**
* Reverse geocoding channel event handler
*/
-public class ReverseGeocoderHandler extends SimpleChannelHandler {
+public class ReverseGeocoderHandler extends OneToOneDecoder {
/**
* Geocoder object
@@ -36,14 +37,19 @@ public class ReverseGeocoderHandler extends SimpleChannelHandler {
}
@Override
- public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
- if (e.getMessage() instanceof Position) {
- Position position = (Position) e.getMessage();
+ protected Object decode(
+ ChannelHandlerContext ctx, Channel channel, Object msg)
+ throws Exception {
+
+ if (msg instanceof Position) {
+ Position position = (Position) msg;
if (geocoder != null) {
position.setAddress(geocoder.getAddress(
position.getLatitude(), position.getLongitude()));
}
}
+
+ return msg;
}
}