how to calculate trip using php from the data collected in the database?

Jean Freitas7 years ago

I am using the Traccar api to receive device data, however I am interfacing with php to manipulate the information, at this point in the project I am working with the Trip report and I am not able to determine travel snippets.

Data in position table:

id	protocol	deviceid	servertime		devicetime		fixtime			valid	latitude		longitude		altitude	speed	course	address							attributes							accuaracy	network
443	gps103		2		2018-06-08 07:42:22	2018-06-08 11:42:22	2018-06-08 11:39:27	0	-16.473443333333332	-54.59475333333334	0		14.04	166.79	229 Av. Jucelino Kubitschek, RondonĂ³polis, MT, BR	{"distance":0.0,"totalDistance":163940.92,"motion":true}	0		{"radioType":"gsm","considerIp":false,"cellTowers":[{"cellId":3272,"locationAreaCode":2066,"mobileCountryCode":0,"mobileNetworkCode":0}]}

I have a lot of information in this tutorial, but I could not build an algorithm with the data.
Motion, Trips and Stops

jaimzj7 years ago

If you want to achieve it directly from database, you can write a query to retrieve position records between the required time-stamp and write a simple if loop which will check a combination of time difference between each position record along with ignition status (if available) or motion status.

If you require to do it via API, it is already available, you just need to optimize your configuration using the documentation to match your required criterias. and you can use the reports api and retrieve trips detail.

However as you have already mentioned you want to do it with the records from database. You can confirm the same, and I can share some previous PHP -> MySQL reports I had done. which maybe could be of help.

Jean Freitas7 years ago

Hello James, thanks for the quick reply, looking for something in github I found your repository traccar-api-php where I could observe how it is done through api as you commented, I think this way it is easier to reproduce the reports.

The logic of your api already helps me a lot, I think it will suffice, thank you for sharing!

jaimzj7 years ago

Thats Great. You are most welcome.