So I'm tracking a number of vessels as they travel across the ocean, creating a LINESTRING() in MySQL once I've gotten all the known GPS points from departure to arrival. Sometimes, however, I'm able to find additional points after creating the linestring, sometimes without associated time data.
So my question is: What would be the simplest way to take a linestring and add a point to it? It's reasonable to assume that, point by point, the LINESTRING doesn't change direction much and that it should be possible to deduce mathematically between which points the new point should be placed; but I can't seem to figure it out.
My solution so far finds which given coordinate on the LINESTRING is the closest, but I haven't been able to figure out the math that decides whether it should come before or after. Maybe the solution involves finding out which part of the linestring the point is closest to and then inserting it between the two coordinates that define that part of the line?