Calculating distance with accuracy

bruno9 years ago

Hi everyone,

I am trying to create some reports based on the positions in my custom interface. I have managed to calculate distance but I realised it isn't accurate due to the frequency of the devices logging the positions. I have a few questions and would love to know how you guys/girls went about solving them:

  1. What is a reasonable frequency for a device in a car to log it's position without straining the MySQL database with unneccessary logs? Mine is set at every 10 seconds, is this too much or can I use 5 seconds?

  2. When it comes to calculating distance, if it is at 10 seconds, when the car goes around a curved road, the polyline draws a straight line between the two positions instead of sticking to the path of the road. I am currently measuring distance by calculating the length of the polyline between the two points using leaflet. How would you recommend I solve this issue?

  3. Is there a way to stop logging positions if speed is < 0 for longer than 3 minutes? Where can I adjust this code in the source?

I would like to hear what your thoughts are. Thanks!

Anton Tananaev9 years ago
  1. 10 seconds is pretty high number. I wouldn't go any higher unless distance values you get are really inaccurate.

  2. Some devices can calculate distance on device which is more accurate because GPS reports location every second. Other devices can report location by angle which means you get a point every time vehicle turns over specified angle threshold.

  3. You can enable filtering by distance. More info on filtering config parameters here:

https://www.traccar.org/configuration-file/

bruno9 years ago

Thanks for your response Anton.

So if I understand correctly, I should be fine with 10 seconds in order to get reasonably accurate distance.

I will be using a cheap Chinese tracking device. I don't understand what you mean by "GPS reports location every second". Doesn't the frequency you set on the device (eg. 10 seconds) determine if it is logged or not? It will only send it's location depending on how often I set it to send, correct? I'm sorry if I misunderstood what you are saying.

Also, i'm very very new to the world of GPS stuff so I don't understand this:

On a normal gps device, there is no sim card, so how does it send it's location? Because the cheap chinese tracking devices say "GPS/GSM/GPRS" so it needs data on the sim card to send it's location to the server, correct?

Anton Tananaev9 years ago

Yes, I think 10 seconds should be enough to get accurate distance.

What I meant is that internally device gets location every second from GPS chip, so it can calculate distance more accurately.

bruno9 years ago

Oh ok great. Thanks Anton

jaimzj9 years ago

Sharing info on what I have done.

Wherever Possible I set the update frequency to '5 seconds' provided the device is the type, which stops sending location data when the vehicle is stationary (And starts sending location updates only while moving, and for alerts). and even with this frequent update while moving (there is maybe excess data compared to 10 second interval) But I am able to calculate more accurate distance reports with 1 to 2 miles difference every 100 mile.

Another thing is, Some devices such as the cheap chineese devices still send location udpates when the vehicle is stationary. What I have done in this case is. I have set such devices to '10 seconds' interval.
And every night have set a script to delete data for such devices where their speed value is = 0! Thus maybe on the long run reducing junk data in the db.

bruno9 years ago

Thanks for sharing that nefertiti! I think I will follow your advice regarding the script to delete redundant values. Have you found a way to split "trips"? By that I mean, if the device is always sending it's location even when the car is off, how can you programmatically determine each trip the car makes for reporting purposes? I was thinking I could get records between where speed=0 for longer than 2 minutes (for example), then I can classify that as one trip. Any ideas?

jaimzj9 years ago

I have done something like this, considering that i am deleting records for such devices where the speed value is 0, thus Cant use speed as point of reference to identify trips. I use the time-diff between two points as the differentiation for end trip (if less than 10 minutes) then its a usual stop between a trip. and if more than 10 minutes stop, then Its a new trip. (This is not the best method, nor the right way) but the only Way I could achieve something quick :D

bruno9 years ago

Ah that makes sense. So a combination of difference in time and speed would be a quick solution as you say. Thanks!

ssan8 years ago

Hi @bruno,

Above you have mentioned about running script with speed = 0 to remove junk data. Instead of this, I am thinking to filter records based on distance. For example, set filter.distance= 10 mtrs. What could be disadvantage of this method?