aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-09-11 21:52:13 -0700
committerAnton Tananaev <anton@traccar.org>2023-09-11 21:52:13 -0700
commite000421d9e67960d28666471bf8ea8c7b629dd9d (patch)
treec427c23f26431cee0027818db14daefb28801856 /src/main/java/org/traccar
parent023ab3249c1cbeb89e44af0d9f6c98130519a67d (diff)
downloadtrackermap-server-e000421d9e67960d28666471bf8ea8c7b629dd9d.tar.gz
trackermap-server-e000421d9e67960d28666471bf8ea8c7b629dd9d.tar.bz2
trackermap-server-e000421d9e67960d28666471bf8ea8c7b629dd9d.zip
Add speed limit accuracy (fix #5175)
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/MainModule.java2
-rw-r--r--src/main/java/org/traccar/config/Keys.java8
-rw-r--r--src/main/java/org/traccar/speedlimit/OverpassSpeedLimitProvider.java9
3 files changed, 15 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/MainModule.java b/src/main/java/org/traccar/MainModule.java
index 6ed240d2c..9559b3a90 100644
--- a/src/main/java/org/traccar/MainModule.java
+++ b/src/main/java/org/traccar/MainModule.java
@@ -303,7 +303,7 @@ public class MainModule extends AbstractModule {
switch (type) {
case "overpass":
default:
- return new OverpassSpeedLimitProvider(client, url);
+ return new OverpassSpeedLimitProvider(config, client, url);
}
}
return null;
diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java
index 27f5f0921..23a983e7b 100644
--- a/src/main/java/org/traccar/config/Keys.java
+++ b/src/main/java/org/traccar/config/Keys.java
@@ -1678,6 +1678,14 @@ public final class Keys {
List.of(KeyType.CONFIG));
/**
+ * Search radius for speed limit. Value is in meters. Default value is 100.
+ */
+ public static final ConfigKey<Integer> SPEED_LIMIT_ACCURACY = new IntegerConfigKey(
+ "speedLimit.accuracy",
+ List.of(KeyType.CONFIG),
+ 100);
+
+ /**
* Override latitude sign / hemisphere. Useful in cases where value is incorrect because of device bug. Value can be
* N for North or S for South.
*/
diff --git a/src/main/java/org/traccar/speedlimit/OverpassSpeedLimitProvider.java b/src/main/java/org/traccar/speedlimit/OverpassSpeedLimitProvider.java
index 60ad65f9e..a25eedb2c 100644
--- a/src/main/java/org/traccar/speedlimit/OverpassSpeedLimitProvider.java
+++ b/src/main/java/org/traccar/speedlimit/OverpassSpeedLimitProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 - 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2020 - 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.
@@ -15,6 +15,8 @@
*/
package org.traccar.speedlimit;
+import org.traccar.config.Config;
+import org.traccar.config.Keys;
import org.traccar.helper.UnitsConverter;
import jakarta.json.JsonArray;
@@ -28,9 +30,10 @@ public class OverpassSpeedLimitProvider implements SpeedLimitProvider {
private final Client client;
private final String url;
- public OverpassSpeedLimitProvider(Client client, String url) {
+ public OverpassSpeedLimitProvider(Config config, Client client, String url) {
+ int accuracy = config.getInteger(Keys.SPEED_LIMIT_ACCURACY);
this.client = client;
- this.url = url + "?data=[out:json];way[maxspeed](around:100.0,%f,%f);out%%20tags;";
+ this.url = url + "?data=[out:json];way[maxspeed](around:" + accuracy + ",%f,%f);out%%20tags;";
}
private Double parseSpeed(String value) {