Implemented in sp here: https://github.com/ropensci/stplanr/blob/v0.8.5/R/linefuns.R