Returns a new array of waypoints with the new waypoint inserted at the optimal position.
It finds the best insertion index and inserts the waypoint in one step, using
findBestWaypointInsertionIndex to find where the waypoint fits most naturally
along the route.
A new array with the waypoint inserted at the optimal position.
Remarks
It returns a new array and leaves the original waypoints array unmodified.
It places the waypoint with the same logic as findBestWaypointInsertionIndex, which says what it
does with a route of fewer than 2 coordinates or fewer than 2 waypoints.
Example
// A route from [4.9, 52.3] to [5.0, 52.4], through [4.95, 52.35] constupdatedWaypoints = withInsertedWaypoint(route, [[4.9, 52.3], [5.0, 52.4]], [4.95, 52.35]); // Returns: [[4.9, 52.3], [4.95, 52.35], [5.0, 52.4]]
Returns a new array of waypoints with the new waypoint inserted at the optimal position.
It finds the best insertion index and inserts the waypoint in one step, using findBestWaypointInsertionIndex to find where the waypoint fits most naturally along the route.