aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/model
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-12-20 08:42:20 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-12-20 08:42:20 +1300
commit13c1b5a0f68cf3f9a6a8fee43a4e5c1406dac32a (patch)
treea7d3450db8ccb6698ed4e7794f27ceaf939807c9 /src/org/traccar/model
parent301b44775fb4ed66fae5c801da3c52f7b88b9697 (diff)
downloadtrackermap-server-13c1b5a0f68cf3f9a6a8fee43a4e5c1406dac32a.tar.gz
trackermap-server-13c1b5a0f68cf3f9a6a8fee43a4e5c1406dac32a.tar.bz2
trackermap-server-13c1b5a0f68cf3f9a6a8fee43a4e5c1406dac32a.zip
Refactor protocols for network location
Diffstat (limited to 'src/org/traccar/model')
-rw-r--r--src/org/traccar/model/CellTower.java42
-rw-r--r--src/org/traccar/model/Network.java7
2 files changed, 46 insertions, 3 deletions
diff --git a/src/org/traccar/model/CellTower.java b/src/org/traccar/model/CellTower.java
index 3447bb921..e572dfb10 100644
--- a/src/org/traccar/model/CellTower.java
+++ b/src/org/traccar/model/CellTower.java
@@ -16,17 +16,43 @@
package org.traccar.model;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import org.traccar.Context;
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class CellTower {
- private Integer cellId;
+ public static CellTower from(int mcc, int mnc, int lac, long cid) {
+ CellTower cellTower = new CellTower();
+ cellTower.setMobileCountryCode(mcc);
+ cellTower.setMobileNetworkCode(mnc);
+ cellTower.setLocationAreaCode(lac);
+ cellTower.setCellId(cid);
+ return cellTower;
+ }
+
+ public static CellTower from(int mcc, int mnc, int lac, long cid, int rssi) {
+ CellTower cellTower = CellTower.from(mcc, mnc, lac, cid);
+ cellTower.setSignalStrength(rssi);
+ return cellTower;
+ }
+
+ public static CellTower fromLacCid(int lac, long cid) {
+ return from(
+ Context.getConfig().getInteger("location.mcc"),
+ Context.getConfig().getInteger("location.mnc"), lac, cid);
+ }
+
+ public static CellTower fromCidLac(long cid, int lac) {
+ return fromLacCid(lac, cid);
+ }
- public Integer getCellId() {
+ private Long cellId;
+
+ public Long getCellId() {
return cellId;
}
- public void setCellId(Integer cellId) {
+ public void setCellId(Long cellId) {
this.cellId = cellId;
}
@@ -60,4 +86,14 @@ public class CellTower {
this.mobileNetworkCode = mobileNetworkCode;
}
+ private Integer signalStrength;
+
+ public Integer getSignalStrength() {
+ return signalStrength;
+ }
+
+ public void setSignalStrength(Integer signalStrength) {
+ this.signalStrength = signalStrength;
+ }
+
}
diff --git a/src/org/traccar/model/Network.java b/src/org/traccar/model/Network.java
index 9dd315640..389ce1fdd 100644
--- a/src/org/traccar/model/Network.java
+++ b/src/org/traccar/model/Network.java
@@ -23,6 +23,13 @@ import java.util.Collection;
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class Network {
+ public Network() {
+ }
+
+ public Network(CellTower cellTower) {
+ addCellTower(cellTower);
+ }
+
private Integer homeMobileCountryCode;
public Integer getHomeMobileCountryCode() {