aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/ReverseGeocoderHandler.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-07-12 13:05:10 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-07-12 13:05:10 +1200
commitf304021d16e433b261226a8293f03e7de30a08a4 (patch)
treebb908a0e437a4d80b7e5043346545d02e8b235af /src/org/traccar/ReverseGeocoderHandler.java
parent639b427eba5738534c10f591e285d707e8b060e5 (diff)
downloadtrackermap-server-f304021d16e433b261226a8293f03e7de30a08a4.tar.gz
trackermap-server-f304021d16e433b261226a8293f03e7de30a08a4.tar.bz2
trackermap-server-f304021d16e433b261226a8293f03e7de30a08a4.zip
Re-factor all channel handlers
Diffstat (limited to 'src/org/traccar/ReverseGeocoderHandler.java')
-rw-r--r--src/org/traccar/ReverseGeocoderHandler.java33
1 files changed, 6 insertions, 27 deletions
diff --git a/src/org/traccar/ReverseGeocoderHandler.java b/src/org/traccar/ReverseGeocoderHandler.java
index aaa491ae7..bb4f5cedd 100644
--- a/src/org/traccar/ReverseGeocoderHandler.java
+++ b/src/org/traccar/ReverseGeocoderHandler.java
@@ -15,14 +15,11 @@
*/
package org.traccar;
-import java.net.SocketAddress;
-import java.util.List;
-import org.jboss.netty.channel.Channel;
import org.traccar.geocode.AddressFormat;
import org.traccar.geocode.ReverseGeocoder;
import org.traccar.model.Position;
-public class ReverseGeocoderHandler extends ExtendedObjectDecoder {
+public class ReverseGeocoderHandler extends BaseDataHandler {
private final ReverseGeocoder geocoder;
private final boolean processInvalidPositions;
@@ -35,30 +32,12 @@ public class ReverseGeocoderHandler extends ExtendedObjectDecoder {
}
@Override
- protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
-
- if (geocoder != null) {
- if (msg instanceof Position) {
- Position position = (Position) msg;
-
- if (processInvalidPositions || position.getValid()) {
- position.setAddress(geocoder.getAddress(
- addressFormat, position.getLatitude(), position.getLongitude()));
- }
- } else if (msg instanceof List) {
- List<Position> positions = (List<Position>) msg;
- for (Position position : positions) {
- if (processInvalidPositions || position.getValid()) {
- position.setAddress(geocoder.getAddress(
- addressFormat, position.getLatitude(), position.getLongitude()));
- }
- }
- }
+ protected Position handlePosition(Position position) {
+ if (geocoder != null && (processInvalidPositions || position.getValid())) {
+ position.setAddress(geocoder.getAddress(
+ addressFormat, position.getLatitude(), position.getLongitude()));
}
-
- return msg;
+ return position;
}
}