Can DistanceHandler be put before FilterHandler?

jmdiazlr8 years ago

OsmAnd Protocol does not transmit speed, distance, etc. Maybe some devices neither (don't know).

Filter.Distance calculates distance..
CoordinatesHandler calculates distance.
DistanceHandler calculates distance..

Currently, BasePipelineFactory put DistanceHandler after distance an coordinate handler... could it be put before FilterHandler ?... so filling all position's attributes as soon as possible y simplify later handlers ensuring all attributes are in place.

I am considering modify DistanceHandler to calculate speed, an modify FilterHandler to add a filter.speed.

What do you think ? Could it have a negative effect on other handlers?

Anton Tananaev8 years ago

OsmAnd protocol does support speed. I guess you device just doesn't report it. Most likely it means that network location provider is used.

It doesn't make sense to put distance handler before filter handler. Filtering is intended to remove incorrect coordinates. Why would you want to use those for any calculations?

jmdiazlr8 years ago

OsmAnd Protocol is the protocol of traccar client.

FilterHandler calculates the distance any way (if filtering by distance), if I put DistanceHandler before, FilterHandlres can use precalculated distance (calculated if the position does not come from device, other example is TK103 that reports some events without distance or any other attributes).

I think DistanceHandler could be better placed first in the pipeline, to concentrate a better logic to calculate distance so other handlers depending on distance can take advance of this.

One more analisys, CoordinateHandler calculates the distance between de previous (last) and current position, but what happens when the device was turned off for a period and moved to a far position? in the current pipeline, CoordinateHandler calculates the distance and, depending on configuration, it can replace this new position because is to far from the previous... and that situation will propagate to all future positions. I have not tested this, only code review.

More over, Filter and CoordinateHandler calculate distance always while DistanceHandler calculates it only if the attribute does not comes in the data from the device, it could be better to use only one distance far all calculations or decisions.

Anton Tananaev8 years ago

Please submit your suggestion on GitHub.