From 9129b6f4eb6ab58a83107e47c888bb4a3bbf0f90 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 20 Jun 2017 13:44:35 +0500 Subject: - Combine 'DistanceHandler' and 'CoordinatesHandler' - Move 'DistanceHandler' closer to beginning of pipeline - Use KEY_DISTANCE instead of distance recalculation --- src/org/traccar/BasePipelineFactory.java | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/org/traccar/BasePipelineFactory.java') diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index 45213c1a1..0997e6f11 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -49,7 +49,6 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { private int timeout; private FilterHandler filterHandler; - private CoordinatesHandler coordinatesHandler; private DistanceHandler distanceHandler; private MotionHandler motionHandler; private GeocoderHandler geocoderHandler; @@ -126,14 +125,14 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { } } + distanceHandler = new DistanceHandler(Context.getConfig().getBoolean("coordinates.filter"), + Context.getConfig().getInteger("coordinates.minError"), + Context.getConfig().getInteger("coordinates.maxError")); + if (Context.getConfig().getBoolean("filter.enable")) { filterHandler = new FilterHandler(); } - if (Context.getConfig().getBoolean("coordinates.filter")) { - coordinatesHandler = new CoordinatesHandler(); - } - if (Context.getGeocoder() != null) { geocoderHandler = new GeocoderHandler( Context.getGeocoder(), @@ -146,8 +145,6 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { Context.getConfig().getBoolean("geolocation.processInvalidPositions")); } - distanceHandler = new DistanceHandler(); - motionHandler = new MotionHandler(Context.getConfig().getDouble("event.motion.speedThreshold", 0.01)); if (Context.getConfig().hasKey("location.latitudeHemisphere") @@ -196,6 +193,11 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { if (hemisphereHandler != null) { pipeline.addLast("hemisphere", hemisphereHandler); } + + if (distanceHandler != null) { + pipeline.addLast("distance", distanceHandler); + } + if (geocoderHandler != null) { pipeline.addLast("geocoder", geocoderHandler); } @@ -207,14 +209,6 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { pipeline.addLast("filter", filterHandler); } - if (coordinatesHandler != null) { - pipeline.addLast("coordinatesHandler", coordinatesHandler); - } - - if (distanceHandler != null) { - pipeline.addLast("distance", distanceHandler); - } - if (motionHandler != null) { pipeline.addLast("motion", motionHandler); } -- cgit v1.2.3