I have a device that records GPS data. Reading is done every 2-10 seconds. For an activity that takes 2 hours, there are many GPS points.
Does anyone know of a data set compression algorithm by removing redundant data points. those. if the row of data points is in a straight line, then only the start and end points are required.
check out the Douglas Peucker Algorithm , which is used to simplify the polygon. I used this successfully to reduce the number of gps waypoints when they were handed over to clients for display purposes.
, , x (t), y (t) . - : http://www.youtube.com/watch?v=YtcZXlKbDJY???
, , .
, ++, :
struct Point { double x; double y; }; double calculate_slope(Point const& p1, Point const& p2) { // dy y2 - y1 // m = ---- = --------- // dx x2 - x1 return ((p2.y - p1.y) / (p2.x - p1.x)); } // 1. Read first two points from GPS stream source Point p0 = ... ; Point p1 = ... ; // 2. Accept p0 as it first point // 3. Calculate slope double m0 = calculate_slope(p0, p1); // 4. next point is now previous p0 = p1; // 5. Read another point p1 = ... ; double m1 = calculate_slope(p0, p1); // 6. Eliminate Compare slopes double const tolerance = 0.1; // choose your tolerance double const diff = m0 - m1; bool if (!((diff <= tolerance) && (diff >= -tolerance))) { // 7. Accept p0 and eliminate p1 m0 = m1; } // Repeat steps from 4 to 7 for the rest of points.
, .
GPS .
, CodeProject GPS. , , , - , . , .
, :
" " , , NNE-NNW , NE SE ( , y -).
, . ( , .) . .
, , ENE, ESE, , ENE ESE.
, , - , , . . . lib2geom bezier-utils.cpp. , (i) , ; (ii) , , , , ( - ).