@@ -32,8 +32,8 @@ meta_fun <- function(
32
32
33
33
34
34
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 " , {
37
37
38
38
# calculate travel times / access *before* changing road speeds
39
39
ttm_pre <- meta_fun(r5r :: travel_time_matrix )
@@ -80,6 +80,53 @@ test_that("success in increasing travel times", {
80
80
})
81
81
82
82
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
+
83
130
# LTS with spatial sf -------------------------------------------------------------------
84
131
85
132
test_that(" errors in lts sf" , {
0 commit comments