Open kirantpatil opened 7 years ago
You have to provide a bit more information why you need it and what the use cases can be for this feature. And how exactly you want it to work.
Yes Sir,
Use cases are Taxi, Pizza delivery :) and any delivery related apps.
I would like to see the Assets nearest in order, so that I can make a call to get in touch with.
Current situation is we have to get all devices and then compute to get nearest devices in our Application, and I felt Traccar is best place to compute it, with this (nearest devices) API Traccar can be used for host of different applications.
We can use Traccar application instead of building our solution on top it.
Regards, Kiran.
We can add two apis.
1) Global search: Here the api will search all devices from the current DB.
API: GET /near_devices
2) Group based search: Here the api will search from the specific group id supplied. That way we can minimize the search scope as well.
Here I may assign all two wheeler devices in one group and four wheeler devices in another group and so on.
API: GET /near_devices/groups/{id}
Let me know your thoughts.
Thanks.
It might be useful to have something like this, but there are some more important things to work on at the moment.
I agree with you.
If you provide some guidance on how to approach to add this feature, I will look around if there are any junior developers to work on it and send PR.
Thanks.
There are plenty of examples in the code. Just look at other APIs in Traccar and do the same thing.
Is it possible to implement the point datatype for storing lat/lng which is supported in both Postgresql and Mysql, which will help us to get the nearest devices using sql query as below?
select * , ( point(lat, lng) <-> point($lat, $lng) )*111.325 AS distance
order by distance
https://tapoueh.org/blog/2018/05/postgresql-data-types-point/ https://stackoverflow.com/questions/47619397/find-nearest-items-from-lat-lng-in-postgresql
https://dev.mysql.com/doc/refman/8.0/en/gis-mysql-specific-functions.html#function_point
Else why can't we go with PostGis(Spatial and Geographic objects for PostgreSQL) ?
https://gis.stackexchange.com/questions/31094/how-to-find-the-nearest-point-by-using-postgis-function https://stackoverflow.com/questions/8150721/which-data-type-for-latitude-and-longitude
I suggested using a time series database to store locations some time ago (https://github.com/traccar/traccar/issues/3768).
Since then, TimescaleDB has appeared, which is based on PostgreSQL, so using it you would get time series and geolocation queries.
Hi,
I would like to get nearest devices list with (1 .. 6 KM) range from current location supplied.
Thanks, Kiran.