Understanding database / api / service

Ivan Mudryj5 years ago

Hi all! I 've installed Traccar on a Windows Server, over a SQL Server 2012 database. Everything looks very fine, but I wonder to know if it is possible to 'create new geofences' just inserting new rows on the database? I couldn't find any post where someone talk about it.

I've created a few geofences manually using the tool, and I started to see events/alerts when the devices enter or exit a geofence, cool.

My first try, was to create a new record (simple sql insert) on the tc_geofences table, using a manually created record as data reference. I understood the "Well-known text representation". For some reason I wasn't able to see it on the interface (I'm using admin account).

My second try was to restart the traccar service on services manager. Doing that I started to see the sql insert created geofence on the map, but I can't get their events (geofenceExit / geofenceEnter) to be raised.

I understand maybe working with the API would be the best practice, but I can't see any issue if I want to do it by manipulating the database directly.

May someone with experience just share your thoughts on this??? Thanks a lot!!!

Anton Tananaev5 years ago

Traccar has internal cache, so if you update database directly, Traccar won't pick it up.

Ivan Mudryj5 years ago

And what if a just restart the Service? Will the internal cache be refreshed?

Anton Tananaev5 years ago

Yes.

Ivan Mudryj5 years ago

Thanks Anton for your response!!!!!!! But it seems that restarting the Service do not do the trick. There should be something else. I've double checked every configuration and all seems to be ok, but I still can not see events rising from my (thru sql insert created) geofences.

I think I should start using the API and see if it works that way.

Basanta Shrestha5 years ago

I have traccar server installed on my VPS. I want to be able to let a friend use the apis available. He just need to track device id and current location. This is possible through api/devices. But my problem is he needs to get the latitude and longitude of the device but he only gets "positionId". Is there a way we can get lagitude and longitude ?

Ernesto Vallejo5 years ago

There are some options for this.

1- You can use socket connection for live updates on your device.
2- Once you get positionId from api call, launch a second call to get the details of that position.
3- Use config parameters forward. You can read more information about this here.

Hope this helps.

Ivan Mudryj5 years ago

Thanks Ernesto!!!!! Gracias Maestro!