My pretty large dataset consists of AIS transmitted messages. I load the dataset to a table in my db. Among other columns in this table, there are a longitude and a latitude column. I already transformed them into a geometry column on a new table. New table consists of id, geometry(point), timestamp. I need to find a way to create trajectories for each id. Although, if I just st_makeline(points) ordered by timestamp and grouped by id, all I get is a linestring per id. What needs to be done is that each id must have several trajectories/linestrings corresponding to it. So there must be a way to detect stops of each id during the period of dataset-timestamping, store them in a way that helps you define in which point(s) to "cut" each linestring and in how many pieces.