aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/location
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-18 22:04:41 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-18 22:04:41 +1300
commita7f7df0ebdf56a6dbaa5a17600c05c5b6d3033a4 (patch)
tree23eb64d9a56b62db63b0154ee2e40a37b9727fa0 /src/org/traccar/location
parenta0bc8e67dba450ab1ba3a61340f6c06bf0fa448b (diff)
downloadtraccar-server-a7f7df0ebdf56a6dbaa5a17600c05c5b6d3033a4.tar.gz
traccar-server-a7f7df0ebdf56a6dbaa5a17600c05c5b6d3033a4.tar.bz2
traccar-server-a7f7df0ebdf56a6dbaa5a17600c05c5b6d3033a4.zip
Support GSM based locations (fix #346)
Diffstat (limited to 'src/org/traccar/location')
-rw-r--r--src/org/traccar/location/BaseLocationProvider.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/org/traccar/location/BaseLocationProvider.java b/src/org/traccar/location/BaseLocationProvider.java
index 80b10b33c..d6eddc1cd 100644
--- a/src/org/traccar/location/BaseLocationProvider.java
+++ b/src/org/traccar/location/BaseLocationProvider.java
@@ -15,6 +15,7 @@
*/
package org.traccar.location;
+import org.traccar.Context;
import org.traccar.model.Event;
import java.util.Map;
@@ -23,13 +24,22 @@ public abstract class BaseLocationProvider implements LocationProvider {
@Override
public void getLocation(Map<String, Object> attributes, LocationProviderCallback callback) {
- if (attributes.containsKey(Event.KEY_MCC) || attributes.containsKey(Event.KEY_MNC)) {
- Number mcc = (Number) attributes.get(Event.KEY_MCC);
- Number mnc = (Number) attributes.get(Event.KEY_MNC);
- Number lac = (Number) attributes.get(Event.KEY_LAC);
- Number cid = (Number) attributes.get(Event.KEY_CID);
- getLocation(mcc.intValue(), mnc.intValue(), lac.longValue(), cid.longValue(), callback);
+
+ Number mcc = (Number) attributes.get(Event.KEY_MCC);
+ if (mcc == null) {
+ mcc = Context.getConfig().getInteger("location.mcc");
+ }
+
+ Number mnc = (Number) attributes.get(Event.KEY_MNC);
+ if (mnc == null) {
+ mnc = Context.getConfig().getInteger("location.mnc");
}
+
+ Number lac = (Number) attributes.get(Event.KEY_LAC);
+ Number cid = (Number) attributes.get(Event.KEY_CID);
+
+ getLocation(mcc.intValue(), mnc.intValue(), lac.longValue(), cid.longValue(), callback);
+
}
protected abstract void getLocation(int mcc, int mnc, long lac, long cid, LocationProviderCallback callback);