Skip to content

Commit 22c1c11

Browse files
committed
closes #499
1 parent f1a9df8 commit 22c1c11

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

r-package/tests/testthat/test-scenarios_LTS.R

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ meta_fun <- function(
3232

3333

3434

35-
# car speeds with osm ids -------------------------------------------------------------------
36-
test_that("success in increasing travel times", {
35+
# LTS with osm ids -------------------------------------------------------------------
36+
test_that("success in increasing travel times with osm ids", {
3737

3838
# calculate travel times / access *before* changing road speeds
3939
ttm_pre <- meta_fun(r5r::travel_time_matrix)
@@ -80,6 +80,53 @@ test_that("success in increasing travel times", {
8080
})
8181

8282

83+
# LTS with sf linestrings -------------------------------------------------------------------
84+
test_that("success in increasing travel times with sf linestrings", {
85+
86+
# calculate travel times / access *before* changing road speeds
87+
ttm_pre <- meta_fun(r5r::travel_time_matrix)
88+
expanded_ttm_pre <- meta_fun(r5r::expanded_travel_time_matrix)
89+
det_pre <- meta_fun(r5r::detailed_itineraries)
90+
arrival_ttm_pre <- r5r::arrival_travel_time_matrix(
91+
r5r_network = r5r_network,
92+
origins = pois[1,],
93+
destinations = pois[13,],
94+
mode = 'car',
95+
arrival_datetime = Sys.time(),
96+
max_trip_duration = 60
97+
)
98+
# to do: r5r::accessibility
99+
100+
# plot(det_pre['total_duration'])
101+
# mapview(network$edges) + network$vertices + det
102+
103+
104+
# calculate travel times / access *before* changing road speeds
105+
ttm_pos <- meta_fun(r5r::travel_time_matrix, new_lts = lts_lines)
106+
expanded_ttm_pos <- meta_fun(r5r::expanded_travel_time_matrix, new_lts = lts_lines)
107+
det_pos <- meta_fun(r5r::detailed_itineraries, new_lts = lts_lines)
108+
arrival_ttm_pos <- r5r::arrival_travel_time_matrix(
109+
r5r_network = r5r_network,
110+
origins = pois[1,],
111+
destinations = pois[13,],
112+
mode = 'BICYCLE',
113+
arrival_datetime = Sys.time(),
114+
max_trip_duration = 60,
115+
new_lts = lts_lines
116+
)
117+
118+
119+
# mapview::mapview(det_pre) + det_pos
120+
121+
# checking for longer travel times
122+
testthat::expect_true(ttm_pos$travel_time_p50 < ttm_pre$travel_time_p50)
123+
testthat::expect_true(all(expanded_ttm_pos$total_time < expanded_ttm_pre$total_time))
124+
# testthat::expect_true(arrival_ttm_pos$total_time < arrival_ttm_pre$total_time)
125+
testthat::expect_true(det_pos$total_duration < det_pre$total_duration)
126+
testthat::expect_true(det_pos$total_distance < det_pre$total_distance)
127+
128+
})
129+
83130
# LTS with spatial sf -------------------------------------------------------------------
84131

85132
test_that("errors in lts sf", {

0 commit comments

Comments
 (0)