Reset TotalDistance based on geofenceEvent

ssan7 years ago

Hi Anton,

I am trying to reset TotalDistance based on source/destination(used geofence to create source/destination points) of the vehicle. When the vehicle reaches the destination point, total distance will be reset to zero. I tried calling resetTotalDistance() method in the geofenceEventHandler.java after the "geofence enter event" is fired. It has added a record in the database with reset value to zero. But after analyzing position for all the other events, MainEventHandler.java's messagereceived() method updates position objects TotalDistance field to the previous value(before reset value). So this approach does not seem to work. What is the correct approach to reset total distance based on the event? Does eventforwarding would help here?

Anton Tananaev7 years ago

Probably distance is already calculated for the new position at the time when you reset it. You can try to reset it on the current position as well.

ssan7 years ago

Thanks Anton. It worked.