aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/MainModule.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-09-14 22:12:03 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-09-14 22:12:03 -0700
commite7b6993a0c142fb5a051d169fee2f7111c2884fe (patch)
tree1577d246c233ddc42d9d83fcf7a5ea6e087a0ea2 /src/main/java/org/traccar/MainModule.java
parentf4e7350ee5e15c0d463a4fcf83db877acc181f13 (diff)
downloadtrackermap-server-e7b6993a0c142fb5a051d169fee2f7111c2884fe.tar.gz
trackermap-server-e7b6993a0c142fb5a051d169fee2f7111c2884fe.tar.bz2
trackermap-server-e7b6993a0c142fb5a051d169fee2f7111c2884fe.zip
Add speed limit handler
Diffstat (limited to 'src/main/java/org/traccar/MainModule.java')
-rw-r--r--src/main/java/org/traccar/MainModule.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/MainModule.java b/src/main/java/org/traccar/MainModule.java
index de6ec5b87..e751cb453 100644
--- a/src/main/java/org/traccar/MainModule.java
+++ b/src/main/java/org/traccar/MainModule.java
@@ -61,6 +61,7 @@ import org.traccar.handler.GeolocationHandler;
import org.traccar.handler.HemisphereHandler;
import org.traccar.handler.MotionHandler;
import org.traccar.handler.RemoteAddressHandler;
+import org.traccar.handler.SpeedLimitHandler;
import org.traccar.handler.TimeHandler;
import org.traccar.handler.events.AlertEventHandler;
import org.traccar.handler.events.CommandResultEventHandler;
@@ -76,6 +77,8 @@ import org.traccar.reports.model.TripsConfig;
import javax.annotation.Nullable;
import javax.ws.rs.client.Client;
import io.netty.util.Timer;
+import org.traccar.speedlimit.OverpassSpeedLimitProvider;
+import org.traccar.speedlimit.SpeedLimitProvider;
public class MainModule extends AbstractModule {
@@ -211,6 +214,21 @@ public class MainModule extends AbstractModule {
@Singleton
@Provides
+ public static SpeedLimitProvider provideSpeedLimitProvider(Config config) {
+ if (config.getBoolean(Keys.SPEED_LIMIT_ENABLE)) {
+ String type = config.getString(Keys.SPEED_LIMIT_TYPE, "overpass");
+ String url = config.getString(Keys.SPEED_LIMIT_URL);
+ switch (type) {
+ case "overpass":
+ default:
+ return new OverpassSpeedLimitProvider(url);
+ }
+ }
+ return null;
+ }
+
+ @Singleton
+ @Provides
public static DistanceHandler provideDistanceHandler(Config config, IdentityManager identityManager) {
return new DistanceHandler(config, identityManager);
}
@@ -275,6 +293,15 @@ public class MainModule extends AbstractModule {
@Singleton
@Provides
+ public static SpeedLimitHandler provideSpeedLimitHandler(@Nullable SpeedLimitProvider speedLimitProvider) {
+ if (speedLimitProvider != null) {
+ return new SpeedLimitHandler(speedLimitProvider);
+ }
+ return null;
+ }
+
+ @Singleton
+ @Provides
public static MotionHandler provideMotionHandler(TripsConfig tripsConfig) {
return new MotionHandler(tripsConfig.getSpeedThreshold());
}