aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/Context.java
diff options
context:
space:
mode:
authorjon-stumpf <jon.stumpf@gmail.com>2017-02-20 10:54:34 -0500
committerjon-stumpf <jon.stumpf@gmail.com>2017-02-20 10:54:34 -0500
commit888c392af40187f3a0ecc3395495db9acd85b827 (patch)
treebeb74dff8b8052ffb4a7d3c894b2b4e5a4434973 /src/org/traccar/Context.java
parent38249673287b908c0ca55847a35ca16a7b6a0c50 (diff)
parent2449895139fa658d082c1085185003a001225bc3 (diff)
downloadtrackermap-server-888c392af40187f3a0ecc3395495db9acd85b827.tar.gz
trackermap-server-888c392af40187f3a0ecc3395495db9acd85b827.tar.bz2
trackermap-server-888c392af40187f3a0ecc3395495db9acd85b827.zip
Resolved conflict with master;
Diffstat (limited to 'src/org/traccar/Context.java')
-rw-r--r--src/org/traccar/Context.java32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java
index cd6820778..27e61d32d 100644
--- a/src/org/traccar/Context.java
+++ b/src/org/traccar/Context.java
@@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
import com.ning.http.client.AsyncHttpClient;
import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.Properties;
import org.apache.velocity.app.VelocityEngine;
@@ -208,15 +209,12 @@ public final class Context {
String type = config.getString("geocoder.type", "google");
String url = config.getString("geocoder.url");
String key = config.getString("geocoder.key");
+ String language = config.getString("geocoder.language");
int cacheSize = config.getInteger("geocoder.cacheSize");
switch (type) {
case "nominatim":
- if (key != null) {
- geocoder = new NominatimGeocoder(url, key, cacheSize);
- } else {
- geocoder = new NominatimGeocoder(url, cacheSize);
- }
+ geocoder = new NominatimGeocoder(url, key, cacheSize);
break;
case "gisgraphy":
geocoder = new GisgraphyGeocoder(url, cacheSize);
@@ -234,17 +232,10 @@ public final class Context {
geocoder = new FactualGeocoder(url, key, cacheSize);
break;
case "geocodefarm":
- if (key != null) {
- geocoder = new GeocodeFarmGeocoder(key, cacheSize);
- } else {
- geocoder = new GeocodeFarmGeocoder(cacheSize);
- }
+ geocoder = new GeocodeFarmGeocoder(key, cacheSize);
+ break;
default:
- if (key != null) {
- geocoder = new GoogleGeocoder(key, cacheSize);
- } else {
- geocoder = new GoogleGeocoder(cacheSize);
- }
+ geocoder = new GoogleGeocoder(key, language, cacheSize);
break;
}
}
@@ -291,9 +282,14 @@ public final class Context {
velocityProperties.setProperty("runtime.log.logsystem.class",
"org.apache.velocity.runtime.log.NullLogChute");
- String address = config.getString("web.address", InetAddress.getLocalHost().getHostAddress());
- int port = config.getInteger("web.port", 8082);
- String webUrl = URIUtil.newURI("http", address, port, "", "");
+ String address;
+ try {
+ address = config.getString("web.address", InetAddress.getLocalHost().getHostAddress());
+ } catch (UnknownHostException e) {
+ address = "localhost";
+ }
+
+ String webUrl = URIUtil.newURI("http", address, config.getInteger("web.port", 8082), "", "");
webUrl = Context.getConfig().getString("web.url", webUrl);
velocityProperties.setProperty("web.url", webUrl);