aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/ReverseGeocoderHandler.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-11-23 11:41:55 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2014-11-23 11:41:55 +1300
commit146508be837b4c89eac752ef54c6902d017c3bd8 (patch)
treef2e609f80c755706ea76aabf2e6aa01c2ddfab4a /src/org/traccar/ReverseGeocoderHandler.java
parent7504fc5a35966079d9be08fee0482adf01a6a9f8 (diff)
parent419920eb18e775690736fd9eec048b3a186744e3 (diff)
downloadtrackermap-server-146508be837b4c89eac752ef54c6902d017c3bd8.tar.gz
trackermap-server-146508be837b4c89eac752ef54c6902d017c3bd8.tar.bz2
trackermap-server-146508be837b4c89eac752ef54c6902d017c3bd8.zip
Merge branch 'master' of github.com:tananaev/traccar
Diffstat (limited to 'src/org/traccar/ReverseGeocoderHandler.java')
-rw-r--r--src/org/traccar/ReverseGeocoderHandler.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/org/traccar/ReverseGeocoderHandler.java b/src/org/traccar/ReverseGeocoderHandler.java
index 8bdd7ebfc..7a3372dff 100644
--- a/src/org/traccar/ReverseGeocoderHandler.java
+++ b/src/org/traccar/ReverseGeocoderHandler.java
@@ -18,7 +18,6 @@ package org.traccar;
import java.util.List;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.handler.codec.oneone.OneToOneDecoder;
import org.traccar.geocode.ReverseGeocoder;
import org.traccar.model.Position;
@@ -26,9 +25,11 @@ import org.traccar.model.Position;
public class ReverseGeocoderHandler extends OneToOneDecoder {
private final ReverseGeocoder geocoder;
+ private final boolean processInvalidPositions;
- public ReverseGeocoderHandler(ReverseGeocoder geocoder) {
+ public ReverseGeocoderHandler(ReverseGeocoder geocoder, boolean processInvalidPositions ) {
this.geocoder = geocoder;
+ this.processInvalidPositions = processInvalidPositions;
}
@Override
@@ -39,13 +40,18 @@ public class ReverseGeocoderHandler extends OneToOneDecoder {
if (geocoder != null) {
if (msg instanceof Position) {
Position position = (Position) msg;
- position.setAddress(geocoder.getAddress(
- position.getLatitude(), position.getLongitude()));
+
+ if (processInvalidPositions || position.getValid()) {
+ position.setAddress(geocoder.getAddress(
+ position.getLatitude(), position.getLongitude()));
+ }
} else if (msg instanceof List) {
List<Position> positions = (List<Position>) msg;
for (Position position : positions) {
- position.setAddress(geocoder.getAddress(
- position.getLatitude(), position.getLongitude()));
+ if (processInvalidPositions || position.getValid()) {
+ position.setAddress(geocoder.getAddress(
+ position.getLatitude(), position.getLongitude()));
+ }
}
}
}