Calculating distance covered and time data is sent

realnumber7 years ago

I am using traccar to forward data to mongodb and i have extracted this data

{
        "_id" : "beaWbQ2K5vHJhagJc",
        "id" : "1",
        "deviceId" : "1",
        "valid" : "true",
        "fixTime" : "1481144435000",
        "deviceTime" : "1481144435000",
        "protocol" : "osmand",
        "name" : "UNEP",
        "latitude" : "-1.2870456",
        "longitude" : "36.8939355",
        "altitude" : "0.0",
        "speed" : "0.0",
        "course" : "0.0",
        "statusCode" : "0xF020",
        "address" : "Donholm, KE",
        "gprmc" : "$GPRMC,210035.000,A,0117.2227,S,03653.6361,E,0.00,0.00,071216,,*1B",
        "attributes" : "{\"battery\":\"11.0\",\"ip\":\"197.237.199.232\",\"distance\":0.65,\"totalDistance\":1878.26}"
}

My two questions are:

Which of the two dates represent the time that the data was sent

        "fixTime" : "1481144435000",
        "deviceTime" : "1481144435000",

Second, how can i calculate the distance covered?.

Anton Tananaev7 years ago

"fixTime" - time of the GPS fix.
"deviceTime" - time reported by the device. Usually the same value as "fixTime", but can be different if device doesn't have a GPS fix and reports old location.

Distance is already calculated. See attributes field.

realnumber7 years ago

Thanks for the info. Lets say my client is updating after every 10 seconds.

After 10 minutes, will the attribute totalDistance contain the total kilomteres covered after 10 minutes or should i add the distance attribute from the data sent by the device from the time the device started sending data to the 10th minute?.

Anton Tananaev7 years ago

Total distance attribute will contain accumulated distance since you've added the device.