Ramer-Douglas-Peucker algorithm