diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-02-24 10:45:26 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-02-24 10:45:26 -0800 |
commit | 98993ee219b6c0cb31f2f3b1608d378b2e028535 (patch) | |
tree | 77a6e8366c27b8b3851e52b6ab81ff62920b970c /src/org/traccar/Context.java | |
parent | a129cfd3159c02b4f3996dbdfb5299ac95a6720c (diff) | |
download | traccar-server-98993ee219b6c0cb31f2f3b1608d378b2e028535.tar.gz traccar-server-98993ee219b6c0cb31f2f3b1608d378b2e028535.tar.bz2 traccar-server-98993ee219b6c0cb31f2f3b1608d378b2e028535.zip |
Refactor geolocation
Diffstat (limited to 'src/org/traccar/Context.java')
-rw-r--r-- | src/org/traccar/Context.java | 75 |
1 files changed, 11 insertions, 64 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index d9fed22ec..e507406e8 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -17,25 +17,22 @@ package org.traccar; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.Properties; - import com.fasterxml.jackson.datatype.jsr353.JSR353Module; import org.apache.velocity.app.VelocityEngine; import org.eclipse.jetty.util.URIUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.traccar.config.Config; -import org.traccar.database.CalendarManager; -import org.traccar.database.CommandsManager; import org.traccar.database.AttributesManager; import org.traccar.database.BaseObjectManager; +import org.traccar.database.CalendarManager; +import org.traccar.database.CommandsManager; import org.traccar.database.ConnectionManager; import org.traccar.database.DataManager; import org.traccar.database.DeviceManager; import org.traccar.database.DriversManager; +import org.traccar.database.GeofenceManager; +import org.traccar.database.GroupsManager; import org.traccar.database.IdentityManager; import org.traccar.database.LdapProvider; import org.traccar.database.MailManager; @@ -43,27 +40,23 @@ import org.traccar.database.MaintenancesManager; import org.traccar.database.MediaManager; import org.traccar.database.NotificationManager; import org.traccar.database.PermissionsManager; -import org.traccar.database.GeofenceManager; -import org.traccar.database.GroupsManager; -import org.traccar.database.StatisticsManager; import org.traccar.database.UsersManager; import org.traccar.events.MotionEventHandler; import org.traccar.events.OverspeedEventHandler; import org.traccar.geocoder.AddressFormat; +import org.traccar.geocoder.BanGeocoder; import org.traccar.geocoder.BingMapsGeocoder; import org.traccar.geocoder.FactualGeocoder; import org.traccar.geocoder.GeocodeFarmGeocoder; import org.traccar.geocoder.GeocodeXyzGeocoder; +import org.traccar.geocoder.Geocoder; import org.traccar.geocoder.GisgraphyGeocoder; -import org.traccar.geocoder.BanGeocoder; import org.traccar.geocoder.GoogleGeocoder; import org.traccar.geocoder.HereGeocoder; import org.traccar.geocoder.MapQuestGeocoder; +import org.traccar.geocoder.MapmyIndiaGeocoder; import org.traccar.geocoder.NominatimGeocoder; import org.traccar.geocoder.OpenCageGeocoder; -import org.traccar.geocoder.MapmyIndiaGeocoder; -import org.traccar.geocoder.Geocoder; -import org.traccar.geolocation.UnwiredGeolocationProvider; import org.traccar.helper.Log; import org.traccar.helper.SanitizerModule; import org.traccar.model.Attribute; @@ -77,10 +70,6 @@ import org.traccar.model.Group; import org.traccar.model.Maintenance; import org.traccar.model.Notification; import org.traccar.model.User; -import org.traccar.geolocation.GoogleGeolocationProvider; -import org.traccar.geolocation.GeolocationProvider; -import org.traccar.geolocation.MozillaGeolocationProvider; -import org.traccar.geolocation.OpenCellIdGeolocationProvider; import org.traccar.notification.EventForwarder; import org.traccar.notification.JsonTypeEventForwarder; import org.traccar.notification.NotificatorManager; @@ -92,6 +81,9 @@ import org.traccar.web.WebServer; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.ext.ContextResolver; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.Properties; public final class Context { @@ -100,10 +92,6 @@ public final class Context { private Context() { } - public static String getAppVersion() { - return Context.class.getPackage().getImplementationVersion(); - } - private static Config config; public static Config getConfig() { @@ -182,12 +170,6 @@ public final class Context { return geocoder; } - private static GeolocationProvider geolocationProvider; - - public static GeolocationProvider getGeolocationProvider() { - return geolocationProvider; - } - private static WebServer webServer; public static WebServer getWebServer() { @@ -266,12 +248,6 @@ public final class Context { return maintenancesManager; } - private static StatisticsManager statisticsManager; - - public static StatisticsManager getStatisticsManager() { - return statisticsManager; - } - private static SmsManager smsManager; public static SmsManager getSmsManager() { @@ -385,7 +361,6 @@ public final class Context { client = ClientBuilder.newClient().register(new ObjectMapperContextResolver()); - if (config.hasKey("database.url")) { dataManager = new DataManager(config); } @@ -410,10 +385,6 @@ public final class Context { geocoder = initGeocoder(); } - if (config.getBoolean("geolocation.enable")) { - initGeolocationModule(); - } - if (config.getBoolean("web.enable")) { webServer = new WebServer(config); } @@ -449,30 +420,6 @@ public final class Context { commandsManager = new CommandsManager(dataManager, config.getBoolean("commands.queueing")); - statisticsManager = new StatisticsManager(); - - } - - private static void initGeolocationModule() { - - String type = config.getString("geolocation.type", "mozilla"); - String url = config.getString("geolocation.url"); - String key = config.getString("geolocation.key"); - - switch (type) { - case "google": - geolocationProvider = new GoogleGeolocationProvider(key); - break; - case "opencellid": - geolocationProvider = new OpenCellIdGeolocationProvider(key); - break; - case "unwired": - geolocationProvider = new UnwiredGeolocationProvider(url, key); - break; - default: - geolocationProvider = new MozillaGeolocationProvider(key); - break; - } } private static void initEventsModule() { |