diff options
author | amilasilva88 <amilasilva88@gmail.com> | 2015-08-14 11:46:27 +0800 |
---|---|---|
committer | amilasilva88 <amilasilva88@gmail.com> | 2015-08-14 11:46:27 +0800 |
commit | a70f478740514e6e60ffbe49906a9c6150b2ec99 (patch) | |
tree | 23e06e979f88ca33609da50b41b2648fbe62469d | |
parent | 077b5a737cf735002e9bf74859c915444452f835 (diff) | |
download | trackermap-server-a70f478740514e6e60ffbe49906a9c6150b2ec99.tar.gz trackermap-server-a70f478740514e6e60ffbe49906a9c6150b2ec99.tar.bz2 trackermap-server-a70f478740514e6e60ffbe49906a9c6150b2ec99.zip |
Refactoring - tabs to spaces and naming conventions
-rw-r--r-- | debug.xml | 6 | ||||
-rw-r--r-- | src/org/traccar/BasePipelineFactory.java | 13 | ||||
-rw-r--r-- | src/org/traccar/OdometerHandler.java | 57 | ||||
-rw-r--r-- | src/org/traccar/model/Position.java | 6 | ||||
-rw-r--r-- | web/app/view/report/Report.js | 4 | ||||
-rw-r--r-- | web/app/view/state/StateController.js | 4 |
6 files changed, 40 insertions, 50 deletions
@@ -99,7 +99,7 @@ altitude FLOAT NOT NULL, speed FLOAT NOT NULL, course FLOAT NOT NULL, - odoMeter FLOAT NOT NULL, + odometer FLOAT NOT NULL, address VARCHAR(512), other VARCHAR(4096) NOT NULL, FOREIGN KEY (deviceId) REFERENCES device (id) ON DELETE CASCADE); @@ -235,8 +235,8 @@ </entry> <entry key='database.insertPosition'> - INSERT INTO position (deviceId, protocol, serverTime, deviceTime, fixTime, valid, latitude, longitude, altitude, speed, course, odoMeter, address, other) - VALUES (:deviceId, :protocol, CURRENT_TIMESTAMP(), :time, :time, :valid, :latitude, :longitude, :altitude, :speed, :course, :odoMeter, :address, :other); + INSERT INTO position (deviceId, protocol, serverTime, deviceTime, fixTime, valid, latitude, longitude, altitude, speed, course, odometer, address, other) + VALUES (:deviceId, :protocol, CURRENT_TIMESTAMP(), :time, :time, :valid, :latitude, :longitude, :altitude, :speed, :course, :odometer, :address, :other); </entry> <entry key='database.selectLatestPositions'> diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index 410b57318..6c4a6b5bd 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -25,7 +25,6 @@ import org.jboss.netty.channel.ChannelPipelineFactory; import org.jboss.netty.channel.ChannelStateEvent; import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.DownstreamMessageEvent; -import org.jboss.netty.channel.ExceptionEvent; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.SimpleChannelHandler; import org.jboss.netty.handler.logging.LoggingHandler; @@ -38,7 +37,7 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { private int resetDelay; private FilterHandler filterHandler; - private ODOMeterHandler odoMeterHandler; + private OdometerHandler odometerHandler; private ReverseGeocoderHandler reverseGeocoderHandler; protected class OpenChannelHandler extends SimpleChannelHandler { @@ -93,10 +92,6 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { filterHandler = new FilterHandler(); } - if (Context.getConfig().getBoolean("system.odometer.enable")) { - odoMeterHandler = new ODOMeterHandler(); - } - if (Context.getReverseGeocoder() != null) { reverseGeocoderHandler = new ReverseGeocoderHandler( Context.getReverseGeocoder(), Context.getConfig().getBoolean("geocode.processInvalidPositions")); @@ -119,11 +114,9 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { if (filterHandler != null) { pipeline.addLast("filter", filterHandler); } - - if (odoMeterHandler != null) { - pipeline.addLast("odoMeter", odoMeterHandler); + if (odometerHandler != null) { + pipeline.addLast("odometer", odometerHandler); } - if (reverseGeocoderHandler != null) { pipeline.addLast("geocoder", reverseGeocoderHandler); } diff --git a/src/org/traccar/OdometerHandler.java b/src/org/traccar/OdometerHandler.java index 781dd274d..5a813fc3a 100644 --- a/src/org/traccar/OdometerHandler.java +++ b/src/org/traccar/OdometerHandler.java @@ -9,44 +9,41 @@ import org.traccar.model.Position; /** * <p> - * Odometer handler + * Odometer - total mileage calculation handler * </p> * * @author Amila Silva * */ -public class ODOMeterHandler extends BaseDataHandler { +public class OdometerHandler extends BaseDataHandler { - public ODOMeterHandler() { - Log.debug("System based odometer calculation enabled for all devices"); - } + 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 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) { - double distance = DistanceCalculator.distance( - position.getLatitude(), position.getLongitude(), - last.getLatitude(), last.getLongitude()); - distance = Math.round((distance) * 100.0) / 100.0; - double odoMeter = distance + last.getOdoMeter(); -// Log.debug("::: Device Course : " + position.getDeviceId() -// + ", Distance :" + distance + "m, Odometer :" + odoMeter -// + " m"); - position.setOdoMeter(odoMeter); - } - return position; - } + private Position calculateDistance(Position position) { + Position last = getLastPosition(position.getDeviceId()); + if (last != null) { + double distance = DistanceCalculator.distance( + position.getLatitude(), position.getLongitude(), + last.getLatitude(), last.getLongitude()); + distance = Math.round((distance) * 100.0) / 100.0; + double odometer = distance + last.getOdometer(); + position.setOdometer(odometer); + } + return position; + } - @Override - protected Position handlePosition(Position position) { - return calculateDistance(position); - } + @Override + protected Position handlePosition(Position position) { + return calculateDistance(position); + } } diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index 8c3340d9c..0c928439c 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -57,9 +57,9 @@ public class Position extends Event implements Factory { public double getCourse() { return course; } public void setCourse(double course) { this.course = course; } - private double odoMeter; // value in meters - public double getOdoMeter() { return odoMeter; } - public void setOdoMeter(double odoMeter) { this.odoMeter = odoMeter; } + private double odometer; // value in meters + public double getOdometer() { return odometer; } + public void setOdometer(double odometer) { this.odometer = odometer; } private String address; public String getAddress() { return address; } diff --git a/web/app/view/report/Report.js b/web/app/view/report/Report.js index 6c43b9463..5466c7887 100644 --- a/web/app/view/report/Report.js +++ b/web/app/view/report/Report.js @@ -91,8 +91,8 @@ Ext.define('Traccar.view.report.Report', { } }, /* { text: strings.positionCourse, dataIndex: 'course', flex: 1 }, */ - { text: 'Odometer', dataIndex: 'odoMeter', flex: 1, - renderer: function(value) { + { text: 'Odometer', dataIndex: 'odometer', flex: 1, + renderer: function(value) { var distanceUnits = Ext.getStore('DistanceUnits'); var unit = Traccar.getApplication().getUser().get('distanceUnit') || Traccar.getApplication().getServer().get('distanceUnit') || ''; return distanceUnits.convert(value, unit) + ' ' + distanceUnits.getUnitName(unit); diff --git a/web/app/view/state/StateController.js b/web/app/view/state/StateController.js index 6f222f6a8..685805418 100644 --- a/web/app/view/state/StateController.js +++ b/web/app/view/state/StateController.js @@ -63,7 +63,7 @@ Ext.define('Traccar.view.state.StateController', { priority: 7, name: strings.positionCourse },*/ - 'odoMeter': { + 'odometer': { priority: 7, name: 'Odometer' }, @@ -92,7 +92,7 @@ Ext.define('Traccar.view.state.StateController', { value = speedUnits.convert(value, unit) + ' ' + speedUnits.getUnitName(unit); } - if (key === 'odoMeter') { + if (key === 'odometer') { var distanceUnits = Ext.getStore('DistanceUnits'); var unit = Traccar.getApplication().getUser().get('distanceUnit') || Traccar.getApplication().getServer().get('distanceUnit') || ''; value = distanceUnits.convert(value, unit) + ' ' + distanceUnits.getUnitName(unit); |