diff --git a/R/mstList.R b/R/mstList.R index f4eb314..43791f3 100644 --- a/R/mstList.R +++ b/R/mstList.R @@ -48,7 +48,7 @@ mstList<- function(sim, roadsConnected){ mst.adj <- cbind(rbind(lnd_to_lnd,t(lnd_to_rd)), rbind(lnd_to_rd, 0)) } else { - both.v <- c(lnd.v, rd.v) + both.v <- unique(c(lnd.v, rd.v)) mst.adj <- igraph::distances(sim$g, both.v, both.v) dimnames(mst.adj) <- list(both.v, both.v) } diff --git a/tests/testthat/test-projectRoads.R b/tests/testthat/test-projectRoads.R index 3ea2693..49b9ae8 100644 --- a/tests/testthat/test-projectRoads.R +++ b/tests/testthat/test-projectRoads.R @@ -148,6 +148,21 @@ test_that("duplicate roads are not created", { }) +test_that("landings on road or multiple landings in same cell work", { + CLUSexample <- prepExData(CLUSexample) + + CLUSexample$landings <- bind_rows(CLUSexample$landings, + list(sf::st_point(c(1.5, 4.2)), sf::st_point(c(1.5, 0.6))) %>% + sf::st_as_sfc() %>% + sf::st_as_sf(crs = sf::st_crs(CLUSexample$landings)) %>% + rename(geometry = x)) + expect_type( + projectRoads(CLUSexample$landings, CLUSexample$cost, CLUSexample$roads, + roadMethod = "mst"), + "list") + + +}) if(FALSE){ # checking memory allocations