diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-08-18 13:22:16 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-08-18 13:22:16 +1200 |
commit | 17ff0791718807be18e9f63aa095ed86d4b82b1c (patch) | |
tree | 1e891f96c1b62e58f4de89def099def177af1b21 /src/org/traccar/OdometerHandler.java | |
parent | a90ce59795690267a0924c2b911f14fe0340a6b4 (diff) | |
download | trackermap-server-17ff0791718807be18e9f63aa095ed86d4b82b1c.tar.gz trackermap-server-17ff0791718807be18e9f63aa095ed86d4b82b1c.tar.bz2 trackermap-server-17ff0791718807be18e9f63aa095ed86d4b82b1c.zip |
Re-factor server side classes
Diffstat (limited to 'src/org/traccar/OdometerHandler.java')
-rw-r--r-- | src/org/traccar/OdometerHandler.java | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/src/org/traccar/OdometerHandler.java b/src/org/traccar/OdometerHandler.java deleted file mode 100644 index d5860c02e..000000000 --- a/src/org/traccar/OdometerHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * - */ -package org.traccar; - -import org.traccar.helper.DistanceCalculator; -import org.traccar.helper.Log; -import org.traccar.model.Position; - -/** - * <p> - * Odometer - total mileage calculation handler - * </p> - * - * @author Amila Silva - * - */ -public class OdometerHandler extends BaseDataHandler { - - public OdometerHandler() { - Log.debug("System based odometer calculation enabled for all devices"); - } - - private Position getLastPosition(long deviceId) { - if (Context.getConnectionManager() != null) { - return Context.getConnectionManager().getLastPosition(deviceId); - } - return null; - } - - private Position calculateDistance(Position position) { - Position last = getLastPosition(position.getDeviceId()); - if (last != null) { - // set odometer only on movement - double odometer = 0.0; - if (last.getSpeed() == 0 && position.getSpeed() == 0) { - odometer = last.getOdometer(); - } else { - double distance = DistanceCalculator.distance( - position.getLatitude(), position.getLongitude(), - last.getLatitude(), last.getLongitude()); - distance = Math.round((distance) * 100.0) / 100.0; - odometer = distance + last.getOdometer(); - } - position.setOdometer(odometer); - } - return position; - } - - @Override - protected Position handlePosition(Position position) { - return calculateDistance(position); - } - -} |