Returns a new array of waypoints with each new waypoint inserted at its optimal position.
Multi-waypoint variant of withInsertedWaypoint. Unlike a sequential one-at-a-time
insertion, this function projects every existing and new waypoint onto the route exactly
once, then merges them by:
Within each slot, ranking the new waypoints by their along-route location (with a stable
tie-break on input order when multiple waypoints project to the same location).
The result is the existing waypoints with newcomers spliced in at the right positions and in
natural along-route order — accurate regardless of input order.
Returns a new array of waypoints with each new waypoint inserted at its optimal position.
Multi-waypoint variant of withInsertedWaypoint. Unlike a sequential one-at-a-time insertion, this function projects every existing and new waypoint onto the route exactly once, then merges them by:
The result is the existing waypoints with newcomers spliced in at the right positions and in natural along-route order — accurate regardless of input order.