Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement to distance filter #3462

Open
socstur opened this issue Aug 21, 2017 · 12 comments
Open

improvement to distance filter #3462

socstur opened this issue Aug 21, 2017 · 12 comments

Comments

@socstur
Copy link

socstur commented Aug 21, 2017

Hi Anton,
I'm seeing devices that are stationary but traccar shows them having motion = yes. I believe whats causing that is the distance filter configuration which filters out the data when the device actually comes to a stop (ie speed~0) since the coordinates are within the distance filter.

To explain more...when a device reports position right before a stop it'll have a speed not equal to 0 (sometimes I see speeds as high as 5 mph). When the device reports its next position which could be several second later ( no less than 10s in my case) it'll have a speed ~0 but the coordinates will be the same as before or within the distance filter. This position and any other subsequent position gets filtered out by the distance filter so traccar never gets a position data where speed ~0 even though the device has stopped. This will affect any functions that uses the device motion state for calculations.

Two solutions come to mind..one is to increase the speed threshold. In my case I'll probably have to put it close to 10mph which is not ideal. Another solution is to allow the distance filter to only come into effect after certain number of reported positions are within the range of filtering. Lets say we can let the first two or three positions within the distance filter to not get filtered out.

what are your thought on this?

@tananaev
Copy link
Member

You should probably explain what the problem is. What functions does it affect in your case?

@socstur
Copy link
Author

socstur commented Aug 21, 2017

As an example I have implemented a function that only requests for geocoding when the device is stationary(ie when motion = no ). I can imagine any future functions that uses motion will have similar issues if motion is reported as yes when the device is actually stationary.

@tananaev
Copy link
Member

I would need an example from official version of Traccar.

@socstur
Copy link
Author

socstur commented Aug 21, 2017

I cannot think of an official traccar function besides that the fact that if you use the distance filter the "motion" state of the device will be incorrect sometimes. I hope atleast you follow why that is the case. Maybe it might not need resolution but but keep in mind for the future if the motion attribute gets more use.

Do you mind pointing me to where the distance filter is implemented? I'll like to do a simple modification to my version of code where it looks at the previous position data to make sure there was no motion before it implements the distance filter.

@tananaev
Copy link
Member

It's in FilterHandler.

@socstur
Copy link
Author

socstur commented Aug 22, 2017

Thanks! I made this modification below. It basically makes sure the device has come to a stop before it starts filtering the position. I don't know if its of any value to be included in the official traccar code.

    private boolean filterDistance(Position position, Position last) {
        if (filterDistance != 0 && last != null && !last.getBoolean(last.KEY_MOTION) ) {
            return position.getDouble(Position.KEY_DISTANCE) < filterDistance;
        }
        return false;
    }

@tananaev
Copy link
Member

Thanks for sharing the code. We will consider including something like that into official version.

@mongaru
Copy link

mongaru commented Feb 22, 2018

Regarding the distance filter I have a real scenario that I am having trouble with.
Scenario: let's say the vehicle stops when the driver gets home at 10 pm. With the distance filter set to any value lets say "50m", no record will be considered since the vehicule is parked. In the morning I check the system but it says that the vehicle haven't been reporting for the last 7 or 8 hours.
Is there a way to update the last connection or maybe accept one record after 1 hour, so it doesn't seem that there is something wrong with the device?

@tananaev
Copy link
Member

Yes, the is a configuration parameter specifically for that purpose. Read official documentation.

@mongaru
Copy link

mongaru commented Feb 22, 2018

Thanks for the reply Anton. Knowing that I found it in the documentation. I am assuming filter.skipLimit is the property.

@tananaev
Copy link
Member

Yes, that's the parameter.

@CarlosBrazil
Copy link

Thanks! I made this modification below. It basically makes sure the device has come to a stop before it starts filtering the position. I don't know if its of any value to be included in the official traccar code.

    private boolean filterDistance(Position position, Position last) {
        if (filterDistance != 0 && last != null && !last.getBoolean(last.KEY_MOTION) ) {
            return position.getDouble(Position.KEY_DISTANCE) < filterDistance;
        }
        return false;
    }

Hi there, I have had the same problem like socstur, and I have used the code that he shared here, and thanks, it woked fine, but is there a way to get this code work with ignition status ?

like this:

if (filterDistance != 0 && last != null && !last.getBoolean(last.KEY_MOTION) && **ignition == false** )   

is that possible ? if yes, how to do it the correct way ?

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants