I have a PostGIS table with position data of numerous vehicles and want to create lines from these points.
Data can be selected by vehicle id and ordered by timestamp but how to create lines from the result?
What I basically need is one line segment from point 1 to point 2, finalize the line and then again from point 2 to point 3. Of course all that under consideration of the vehicle id.
The latter one is needed because I want to calculate the cruise direction and speed of the vehicle from one point to the next.
SELECT ais_data.mmsi, ST_MakeLine(ais_data.geom) AS newgeom INTO ais_lines FROM (SELECT * FROM ais_data ORDER BY ais_data.mmsi, ais_data.bs_ts ASC) AS ais_data GROUP BY ais_data.mmsi;
That will give me the track of every vehicle, and is not exactly what I need. How to tell ST_MakeLine() to create a line from point 1 to point 2, finalize the line and start a new one from point 2 to point 3... ?ORDER BY ais_data.bs_ts
- is it possible? So, point 1, point 2 and so forth are basically the point information given in each line as the result of the Select statement.