aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/BaseProtocolDecoder.java18
-rw-r--r--src/org/traccar/Config.java5
-rw-r--r--src/org/traccar/model/Data.java25
-rw-r--r--src/org/traccar/protocol/AutoFonProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/OrionProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/ProgressProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/SkypatrolProtocolDecoder.java6
9 files changed, 44 insertions, 47 deletions
diff --git a/src/org/traccar/BaseProtocolDecoder.java b/src/org/traccar/BaseProtocolDecoder.java
index c47c0dc69..f5b549e24 100644
--- a/src/org/traccar/BaseProtocolDecoder.java
+++ b/src/org/traccar/BaseProtocolDecoder.java
@@ -16,9 +16,12 @@
package org.traccar;
import java.net.SocketAddress;
+import java.util.Date;
+
import org.jboss.netty.channel.Channel;
import org.traccar.helper.Log;
import org.traccar.model.Device;
+import org.traccar.model.Position;
public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
@@ -71,4 +74,19 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
this.protocol = protocol;
}
+ public void initPositionDetails(Position position) {
+ Position last = Context.getConnectionManager().getLastPosition(getDeviceId());
+ if (last != null) {
+ position.setFixTime(last.getFixTime());
+ position.setValid(last.getValid());
+ position.setLatitude(last.getLatitude());
+ position.setLongitude(last.getLongitude());
+ position.setAltitude(last.getAltitude());
+ position.setSpeed(last.getSpeed());
+ position.setCourse(last.getCourse());
+ } else {
+ position.setFixTime(new Date(0));
+ }
+ }
+
}
diff --git a/src/org/traccar/Config.java b/src/org/traccar/Config.java
index 719f23038..49d6e4fde 100644
--- a/src/org/traccar/Config.java
+++ b/src/org/traccar/Config.java
@@ -17,6 +17,7 @@ package org.traccar;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.Properties;
public class Config {
@@ -24,7 +25,9 @@ public class Config {
private final Properties properties = new Properties();
public void load(String file) throws IOException {
- properties.loadFromXML(new FileInputStream(file));
+ try (InputStream inputStream = new FileInputStream(file)) {
+ properties.loadFromXML(inputStream);
+ }
}
public boolean hasKey(String key) {
diff --git a/src/org/traccar/model/Data.java b/src/org/traccar/model/Data.java
deleted file mode 100644
index 4777543ff..000000000
--- a/src/org/traccar/model/Data.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2013 - 2015 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.model;
-
-public class Data extends Event implements Factory {
-
- @Override
- public Data create() {
- return new Data();
- }
-
-}
diff --git a/src/org/traccar/protocol/AutoFonProtocolDecoder.java b/src/org/traccar/protocol/AutoFonProtocolDecoder.java
index 322ebd06e..29748f489 100644
--- a/src/org/traccar/protocol/AutoFonProtocolDecoder.java
+++ b/src/org/traccar/protocol/AutoFonProtocolDecoder.java
@@ -39,9 +39,9 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_HISTORY = 0x12;
private static double convertCoordinate(int raw) {
- double result = raw / 1000000;
- result += (raw % 1000000) / 600000.0;
- return result;
+ int degrees = raw / 1000000;
+ double minutes = (raw % 1000000) / 10000.0;
+ return degrees + minutes / 60;
}
private Position decodePosition(ChannelBuffer buf, boolean history) {
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index 6ce282988..184c96c97 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -34,6 +34,12 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
+ private static double convertCoordinate(int raw) {
+ int degrees = raw / 1000000;
+ double minutes = (raw % 1000000) / 10000.0;
+ return degrees + minutes / 60;
+ }
+
private Position decodeNormalMessage(ChannelBuffer buf, Channel channel) {
Position position = new Position();
@@ -66,14 +72,8 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
position.setTime(time.getTime());
// Coordinates
- int temp = ChannelBufferTools.readHexInteger(buf, 8);
- double latitude = temp % 1000000;
- latitude /= 60 * 10000;
- latitude += temp / 1000000;
- temp = ChannelBufferTools.readHexInteger(buf, 9);
- double longitude = temp % 1000000;
- longitude /= 60 * 10000;
- longitude += temp / 1000000;
+ double latitude = convertCoordinate(ChannelBufferTools.readHexInteger(buf, 8));
+ double longitude = convertCoordinate(ChannelBufferTools.readHexInteger(buf, 9));
// Flags
byte flags = buf.readByte();
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 82cba08a5..7c5399a37 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -252,7 +252,8 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
command.append(imei).append(",CCC,").append(positions.size()).append("*");
int checksum = 0;
for (int i = 0; i < command.length(); i += 1) checksum += command.charAt(i);
- command.append(String.format("%02x\r\n", checksum & 0xff).toUpperCase());
+ command.append(String.format("%02x", checksum & 0xff).toUpperCase());
+ command.append("\r\n");
channel.write(command.toString());
}
diff --git a/src/org/traccar/protocol/OrionProtocolDecoder.java b/src/org/traccar/protocol/OrionProtocolDecoder.java
index 6dcc19db5..b2e1699c3 100644
--- a/src/org/traccar/protocol/OrionProtocolDecoder.java
+++ b/src/org/traccar/protocol/OrionProtocolDecoder.java
@@ -48,9 +48,9 @@ public class OrionProtocolDecoder extends BaseProtocolDecoder {
}
}
- private static double convertCoordinate(int value) {
- double degrees = value / 1000000;
- double minutes = (value % 1000000) / 10000.0;
+ private static double convertCoordinate(int raw) {
+ int degrees = raw / 1000000;
+ double minutes = (raw % 1000000) / 10000.0;
return degrees + minutes / 60;
}
diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java
index bf7c649ce..51cf6951c 100644
--- a/src/org/traccar/protocol/ProgressProtocolDecoder.java
+++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java
@@ -125,13 +125,13 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder {
position.setLongitude(buf.readInt() * 180.0 / 0x7FFFFFFF);
// Speed
- position.setSpeed(buf.readUnsignedInt() / 100);
+ position.setSpeed(buf.readUnsignedInt() / 100.0);
// Course
- position.setCourse(buf.readUnsignedShort() / 100);
+ position.setCourse(buf.readUnsignedShort() / 100.0);
// Altitude
- position.setAltitude(buf.readUnsignedShort() / 100);
+ position.setAltitude(buf.readUnsignedShort() / 100.0);
// Satellites
int satellitesNumber = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
index 0879d86be..9d5b499cc 100644
--- a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
+++ b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
@@ -44,10 +44,10 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder {
coordinate = 0xffffffffl - coordinate;
}
- double degrees = coordinate / 1000000;
- degrees += (coordinate % 1000000) / 600000.0;
+ long degrees = coordinate / 1000000;
+ double minutes = (coordinate % 1000000) / 10000.0;
- return sign * degrees;
+ return sign * (degrees + minutes / 60);
}
@Override