I have found the solution,
private boolean filterDistance(Position position, Position last) {
position.getAttributes().containsKey(Position.KEY_IGNITION);
if (filterDistance != 0 && last != null && !last.getBoolean(last.KEY_MOTION)
&& position.getAttributes().get(Position.KEY_IGNITION).equals(false)) {
return position.getDouble(Position.KEY_DISTANCE) < filterDistance;
}
return false;
}
With this, you do not need to use skipattributes for ignition, even when the vehicle is stoped , if ignition is on, it will not be filtered out.
Hi, I have changed the code for better use on all devices. Because some devices do not send the attribute ignition all the time.
private boolean filterDistance(Position position, Position last) {
if (position.getAttributes().containsKey(position.KEY_IGNITION)) {
if (filterDistance != 0 && last != null && !last.getBoolean(last.KEY_MOTION)
&& position.getAttributes().get(position.KEY_IGNITION).equals(false)) {
return position.getDouble(Position.KEY_DISTANCE) < filterDistance;
}
} else if (filterDistance != 0 && last != null && !last.getBoolean(last.KEY_MOTION)) {
return position.getDouble(Position.KEY_DISTANCE) < filterDistance;
}
return false;
}
Hi, I have found the code below about filterdistance, this code works only when the position has the motion different of the last position, and it works ok, but I would like it to work with ignition == false, Somebody can help me how to do that ? Because with this, I dont need to use skipattributes, and its better, because a lot of devices send ignition attributes all the time. thanks.
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; }