Adapt Ramer-Douglas-Peucker algorithm to handle NaN-points (i.e. jumps)