There are entire companies that solve basically this one problem. It turns out to be really tricky, because intersections, terrain features, traffic lights, guard rails, bridges versus embankments, shoulders, and a whole lot more end up requiring a lot of careful special cases to all work well with each other.
I think it sounds great that you want to build this tool, and I hope that you have a budget of several hundred thousand dollars to actually make it good!