ropensci / stplanr

Sustainable transport planning with R
https://docs.ropensci.org/stplanr
Other
419 stars 66 forks source link

refactor mats2line() for speed enhancement #540

Closed JosiahParry closed 1 year ago

JosiahParry commented 1 year ago

This PR closes #539.

It refactors mats2line() by utilizing vec_interleave() and sfheaders::sfc_linestring(). It adds an explicit dependency on vctrs (minimum version 0.4.0 as that is when vec_interleave() was added).

Note that vctrs is implicitly imported at present, this just makes it explicit.

An additional test is added to verify the validity of the linestrings that are created by mats2line(). Checks are additionally added to verify that mat1 and mat2 are of compatible sizes.