aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-10-16 07:38:12 -0700
committerAnton Tananaev <anton@traccar.org>2023-10-16 07:38:12 -0700
commitd3631eb7286338a0ea046a511aa5cbfce470c7b7 (patch)
treecd8baed039ced5f9fd0a78058551c7803fb0ca1a /src/main/java/org/traccar/handler
parent33d01cda7bb678bb604404f18c8f4e66a40eaa55 (diff)
downloadtrackermap-server-d3631eb7286338a0ea046a511aa5cbfce470c7b7.tar.gz
trackermap-server-d3631eb7286338a0ea046a511aa5cbfce470c7b7.tar.bz2
trackermap-server-d3631eb7286338a0ea046a511aa5cbfce470c7b7.zip
Option to require Wi-Fi geolocation
Diffstat (limited to 'src/main/java/org/traccar/handler')
-rw-r--r--src/main/java/org/traccar/handler/GeolocationHandler.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/handler/GeolocationHandler.java b/src/main/java/org/traccar/handler/GeolocationHandler.java
index e7389f22d..a54ea03e3 100644
--- a/src/main/java/org/traccar/handler/GeolocationHandler.java
+++ b/src/main/java/org/traccar/handler/GeolocationHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2023 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,6 +37,7 @@ public class GeolocationHandler extends ChannelInboundHandlerAdapter {
private final StatisticsManager statisticsManager;
private final boolean processInvalidPositions;
private final boolean reuse;
+ private final boolean requireWifi;
public GeolocationHandler(
Config config, GeolocationProvider geolocationProvider, CacheManager cacheManager,
@@ -46,6 +47,7 @@ public class GeolocationHandler extends ChannelInboundHandlerAdapter {
this.statisticsManager = statisticsManager;
processInvalidPositions = config.getBoolean(Keys.GEOLOCATION_PROCESS_INVALID_POSITIONS);
reuse = config.getBoolean(Keys.GEOLOCATION_REUSE);
+ requireWifi = config.getBoolean(Keys.GEOLOCATION_REQUIRE_WIFI);
}
@Override
@@ -53,7 +55,8 @@ public class GeolocationHandler extends ChannelInboundHandlerAdapter {
if (message instanceof Position) {
final Position position = (Position) message;
if ((position.getOutdated() || processInvalidPositions && !position.getValid())
- && position.getNetwork() != null) {
+ && position.getNetwork() != null
+ && (!requireWifi || position.getNetwork().getWifiAccessPoints() != null)) {
if (reuse) {
Position lastPosition = cacheManager.getPosition(position.getDeviceId());
if (lastPosition != null && position.getNetwork().equals(lastPosition.getNetwork())) {