Answer the question
In order to leave comments, you need to log in
What is the best way to store list of GPS points in PostgreSQL 9.6 with postgis extension?
We implement GPS tracking
We are thinking about how to store routes - a set of points We
do not plan to search for points, we only need to display them and build a curve at a certain moment
We disagreed with a colleague:
1. I suggest storing each point as a separate record
2. He suggests storing points in an array ( or in json format) on one line. Those. route - one line in the database with all
points
I don’t have any arguments in defense of my version at all, except for the principles of normalization =)
Tell me, please, which option would you choose and why
Answer the question
In order to leave comments, you need to log in
You mentioned postgis, so you need to use its geom format via st_makeline(). Well, or geojson in postgres jsonb fields.
These are the best options. The second is preferable for quick feedback to clients, and the first for filtering or processing in postgis. Since a true geojson can contain several geometries and you need to write a custom function for converting to postgis geometry, I would store and process it in postgis, and then convert it to geojson or another desired format afterward
. And the points themselves without a track do not carry any useful information, after all.
Your approach is much better, at least in that at some point you will probably want to intersect along the tracks, or select points inside the polygon. And you can deal with the performance problem by partitioning tables, for example, by the start time of the track. Erase old partitions and transfer them to the archive. Your version is at least much more flexible.
IMHO wif recursive coupled with a bunch of id, key, parent_id, route_id are much more convenient to maintain ...
Necroposthitis.
Your question googles pretty well, so I'll add my own answer.
The key is that you are tracking. The following entities are important for the subject area:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question