aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/BasePipelineFactory.java3
-rw-r--r--src/org/traccar/LocationProviderHandler.java8
-rw-r--r--src/org/traccar/ReverseGeocoderHandler.java4
3 files changed, 9 insertions, 6 deletions
diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java
index a41e59778..31d3fe420 100644
--- a/src/org/traccar/BasePipelineFactory.java
+++ b/src/org/traccar/BasePipelineFactory.java
@@ -106,7 +106,8 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
}
if (Context.getLocationProvider() != null) {
- locationProviderHandler = new LocationProviderHandler(Context.getLocationProvider());
+ locationProviderHandler = new LocationProviderHandler(
+ Context.getLocationProvider(), Context.getConfig().getBoolean("location.processInvalidPositions"));
}
if (Context.getConfig().getBoolean("distance.enable")) {
diff --git a/src/org/traccar/LocationProviderHandler.java b/src/org/traccar/LocationProviderHandler.java
index 62d5f1d04..c59427474 100644
--- a/src/org/traccar/LocationProviderHandler.java
+++ b/src/org/traccar/LocationProviderHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,9 +27,11 @@ import org.traccar.model.Position;
public class LocationProviderHandler implements ChannelUpstreamHandler {
private final LocationProvider locationProvider;
+ private final boolean processInvalidPositions;
- public LocationProviderHandler(LocationProvider locationProvider) {
+ public LocationProviderHandler(LocationProvider locationProvider, boolean processInvalidPositions) {
this.locationProvider = locationProvider;
+ this.processInvalidPositions = processInvalidPositions;
}
@Override
@@ -43,7 +45,7 @@ public class LocationProviderHandler implements ChannelUpstreamHandler {
Object message = e.getMessage();
if (message instanceof Position) {
final Position position = (Position) message;
- if (locationProvider != null && position.getOutdated()) {
+ if (position.getOutdated() || (processInvalidPositions && !position.getValid())) {
locationProvider.getLocation(position.getAttributes(), new LocationProvider.LocationProviderCallback() {
@Override
public void onSuccess(double latitude, double longitude) {
diff --git a/src/org/traccar/ReverseGeocoderHandler.java b/src/org/traccar/ReverseGeocoderHandler.java
index 4851b3281..0b4fd53ce 100644
--- a/src/org/traccar/ReverseGeocoderHandler.java
+++ b/src/org/traccar/ReverseGeocoderHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2014 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ public class ReverseGeocoderHandler implements ChannelUpstreamHandler {
Object message = e.getMessage();
if (message instanceof Position) {
final Position position = (Position) message;
- if (geocoder != null && (processInvalidPositions || position.getValid())) {
+ if (processInvalidPositions || position.getValid()) {
geocoder.getAddress(addressFormat, position.getLatitude(), position.getLongitude(),
new ReverseGeocoder.ReverseGeocoderCallback() {
@Override