From dd21f4151cedfa34b673f3552d14a20ddc11a6a4 Mon Sep 17 00:00:00 2001 From: robinlovelace Date: Wed, 1 May 2024 15:24:19 +0100 Subject: [PATCH 1/2] Demo of #560 --- DESCRIPTION | 2 +- R/linefuns.R | 2 ++ man/angle_diff.Rd | 2 +- man/bbox_scale.Rd | 2 +- man/bind_sf.Rd | 2 +- man/cents_sf.Rd | 2 +- man/destinations_sf.Rd | 2 +- man/flow_dests.Rd | 2 +- man/flowlines_sf.Rd | 2 +- man/geo_buffer.Rd | 2 +- man/geo_length.Rd | 2 +- man/geo_projected.Rd | 2 +- man/geo_select_aeq.Rd | 2 +- man/geo_toptail.Rd | 2 +- man/is_linepoint.Rd | 2 +- man/line2df.Rd | 2 +- man/line2points.Rd | 2 +- man/line_bearing.Rd | 2 +- man/line_breakup.Rd | 2 +- man/line_midpoint.Rd | 2 +- man/line_segment.Rd | 2 ++ man/line_via.Rd | 2 +- man/mats2line.Rd | 2 +- man/n_segments.Rd | 2 +- man/n_vertices.Rd | 2 +- man/od2line.Rd | 4 ++-- man/od2odf.Rd | 4 ++-- man/od_aggregate_from.Rd | 4 ++-- man/od_aggregate_to.Rd | 4 ++-- man/od_coords.Rd | 2 +- man/od_coords2line.Rd | 2 +- man/od_data_lines.Rd | 2 +- man/od_data_routes.Rd | 2 +- man/od_data_sample.Rd | 2 +- man/od_id.Rd | 2 +- man/od_id_order.Rd | 2 +- man/od_oneway.Rd | 4 ++-- man/od_to_odmatrix.Rd | 4 ++-- man/odmatrix_to_od.Rd | 4 ++-- man/onewaygeo.Rd | 2 +- man/osm_net_example.Rd | 2 +- man/points2flow.Rd | 4 ++-- man/points2line.Rd | 2 +- man/points2odf.Rd | 4 ++-- man/quadrant.Rd | 2 +- man/read_table_builder.Rd | 2 +- man/route_dodgr.Rd | 4 ++-- man/route_network_sf.Rd | 2 +- man/route_network_small.Rd | 2 +- man/route_osrm.Rd | 4 ++-- man/routes_fast_sf.Rd | 2 +- man/routes_slow_sf.Rd | 2 +- man/toptail_buff.Rd | 2 +- man/zones_sf.Rd | 2 +- 54 files changed, 67 insertions(+), 63 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 30f56d0b..e651b82a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -88,5 +88,5 @@ VignetteBuilder: Encoding: UTF-8 LazyData: yes Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 SystemRequirements: GNU make diff --git a/R/linefuns.R b/R/linefuns.R index 57fa30d9..558063d0 100644 --- a/R/linefuns.R +++ b/R/linefuns.R @@ -174,6 +174,8 @@ line_midpoint <- function(l, tolerance = NULL) { #' library(sf) #' l <- routes_fast_sf[2:4, ] #' l_seg_multi <- line_segment(l, segment_length = 1000, use_rsgeo = FALSE) +#' l_seg_n <- line_segment(l, n_segments = 2) +#' l_seg_n <- line_segment(l, n_segments = c(1:3)) #' # Number of subsegments #' table(l_seg_multi$ID) #' plot(l_seg_multi["ID"]) diff --git a/man/angle_diff.Rd b/man/angle_diff.Rd index 1d0e3091..defba511 100644 --- a/man/angle_diff.Rd +++ b/man/angle_diff.Rd @@ -48,8 +48,8 @@ Other lines: \code{\link{line_bearing}()}, \code{\link{line_breakup}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{mats2line}()}, \code{\link{n_segments}()}, diff --git a/man/bbox_scale.Rd b/man/bbox_scale.Rd index d44421f9..ad5f784a 100644 --- a/man/bbox_scale.Rd +++ b/man/bbox_scale.Rd @@ -29,8 +29,8 @@ points(bb[1, ], bb[2, ], col = "red") \seealso{ Other geo: \code{\link{bind_sf}()}, -\code{\link{geo_bb_matrix}()}, \code{\link{geo_bb}()}, +\code{\link{geo_bb_matrix}()}, \code{\link{geo_buffer}()}, \code{\link{geo_length}()}, \code{\link{geo_projected}()}, diff --git a/man/bind_sf.Rd b/man/bind_sf.Rd index 900d7b17..dca95714 100644 --- a/man/bind_sf.Rd +++ b/man/bind_sf.Rd @@ -18,8 +18,8 @@ Rapid row-binding of sf objects \seealso{ Other geo: \code{\link{bbox_scale}()}, -\code{\link{geo_bb_matrix}()}, \code{\link{geo_bb}()}, +\code{\link{geo_bb_matrix}()}, \code{\link{geo_buffer}()}, \code{\link{geo_length}()}, \code{\link{geo_projected}()}, diff --git a/man/cents_sf.Rd b/man/cents_sf.Rd index 6739356f..9e391b93 100644 --- a/man/cents_sf.Rd +++ b/man/cents_sf.Rd @@ -26,9 +26,9 @@ cents_sf \seealso{ Other data: \code{\link{destinations_sf}}, +\code{\link{flow}}, \code{\link{flow_dests}}, \code{\link{flowlines_sf}}, -\code{\link{flow}}, \code{\link{od_data_lines}}, \code{\link{od_data_routes}}, \code{\link{od_data_sample}}, diff --git a/man/destinations_sf.Rd b/man/destinations_sf.Rd index bd258bd7..483ea3c4 100644 --- a/man/destinations_sf.Rd +++ b/man/destinations_sf.Rd @@ -17,9 +17,9 @@ destinations_sf \seealso{ Other data: \code{\link{cents_sf}}, +\code{\link{flow}}, \code{\link{flow_dests}}, \code{\link{flowlines_sf}}, -\code{\link{flow}}, \code{\link{od_data_lines}}, \code{\link{od_data_routes}}, \code{\link{od_data_sample}}, diff --git a/man/flow_dests.Rd b/man/flow_dests.Rd index 85faa4e9..4d08d431 100644 --- a/man/flow_dests.Rd +++ b/man/flow_dests.Rd @@ -28,8 +28,8 @@ devtools::use_data(flow_dests) Other data: \code{\link{cents_sf}}, \code{\link{destinations_sf}}, -\code{\link{flowlines_sf}}, \code{\link{flow}}, +\code{\link{flowlines_sf}}, \code{\link{od_data_lines}}, \code{\link{od_data_routes}}, \code{\link{od_data_sample}}, diff --git a/man/flowlines_sf.Rd b/man/flowlines_sf.Rd index 0abcd33f..a8ab5766 100644 --- a/man/flowlines_sf.Rd +++ b/man/flowlines_sf.Rd @@ -14,8 +14,8 @@ Flow data after conversion to a spatial format.. Other data: \code{\link{cents_sf}}, \code{\link{destinations_sf}}, -\code{\link{flow_dests}}, \code{\link{flow}}, +\code{\link{flow_dests}}, \code{\link{od_data_lines}}, \code{\link{od_data_routes}}, \code{\link{od_data_sample}}, diff --git a/man/geo_buffer.Rd b/man/geo_buffer.Rd index ce8a4504..b41b649f 100644 --- a/man/geo_buffer.Rd +++ b/man/geo_buffer.Rd @@ -38,8 +38,8 @@ if (lib_versions[3] >= "6.3.1") { Other geo: \code{\link{bbox_scale}()}, \code{\link{bind_sf}()}, -\code{\link{geo_bb_matrix}()}, \code{\link{geo_bb}()}, +\code{\link{geo_bb_matrix}()}, \code{\link{geo_length}()}, \code{\link{geo_projected}()}, \code{\link{geo_select_aeq}()}, diff --git a/man/geo_length.Rd b/man/geo_length.Rd index 52c1a928..14ed4c54 100644 --- a/man/geo_length.Rd +++ b/man/geo_length.Rd @@ -24,8 +24,8 @@ if (lib_versions[3] >= "6.3.1") { Other geo: \code{\link{bbox_scale}()}, \code{\link{bind_sf}()}, -\code{\link{geo_bb_matrix}()}, \code{\link{geo_bb}()}, +\code{\link{geo_bb_matrix}()}, \code{\link{geo_buffer}()}, \code{\link{geo_projected}()}, \code{\link{geo_select_aeq}()}, diff --git a/man/geo_projected.Rd b/man/geo_projected.Rd index 57748fad..3bb41817 100644 --- a/man/geo_projected.Rd +++ b/man/geo_projected.Rd @@ -35,8 +35,8 @@ if (lib_versions[3] >= "6.3.1") { Other geo: \code{\link{bbox_scale}()}, \code{\link{bind_sf}()}, -\code{\link{geo_bb_matrix}()}, \code{\link{geo_bb}()}, +\code{\link{geo_bb_matrix}()}, \code{\link{geo_buffer}()}, \code{\link{geo_length}()}, \code{\link{geo_select_aeq}()}, diff --git a/man/geo_select_aeq.Rd b/man/geo_select_aeq.Rd index 7ed98421..b779b420 100644 --- a/man/geo_select_aeq.Rd +++ b/man/geo_select_aeq.Rd @@ -27,8 +27,8 @@ geo_select_aeq(shp) Other geo: \code{\link{bbox_scale}()}, \code{\link{bind_sf}()}, -\code{\link{geo_bb_matrix}()}, \code{\link{geo_bb}()}, +\code{\link{geo_bb_matrix}()}, \code{\link{geo_buffer}()}, \code{\link{geo_length}()}, \code{\link{geo_projected}()}, diff --git a/man/geo_toptail.Rd b/man/geo_toptail.Rd index 8e6ebed6..84c7194b 100644 --- a/man/geo_toptail.Rd +++ b/man/geo_toptail.Rd @@ -47,8 +47,8 @@ Other lines: \code{\link{line_bearing}()}, \code{\link{line_breakup}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{mats2line}()}, \code{\link{n_segments}()}, diff --git a/man/is_linepoint.Rd b/man/is_linepoint.Rd index 0045e5dc..66c8443d 100644 --- a/man/is_linepoint.Rd +++ b/man/is_linepoint.Rd @@ -34,8 +34,8 @@ Other lines: \code{\link{line_bearing}()}, \code{\link{line_breakup}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{mats2line}()}, \code{\link{n_segments}()}, diff --git a/man/line2df.Rd b/man/line2df.Rd index f4aa2c9a..6bd2f5ae 100644 --- a/man/line2df.Rd +++ b/man/line2df.Rd @@ -25,8 +25,8 @@ Other lines: \code{\link{line_bearing}()}, \code{\link{line_breakup}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{mats2line}()}, \code{\link{n_segments}()}, diff --git a/man/line2points.Rd b/man/line2points.Rd index 516e85e7..34439462 100644 --- a/man/line2points.Rd +++ b/man/line2points.Rd @@ -50,8 +50,8 @@ Other lines: \code{\link{line_bearing}()}, \code{\link{line_breakup}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{mats2line}()}, \code{\link{n_segments}()}, diff --git a/man/line_bearing.Rd b/man/line_bearing.Rd index 2d2d6e07..5a6b8e67 100644 --- a/man/line_bearing.Rd +++ b/man/line_bearing.Rd @@ -38,8 +38,8 @@ Other lines: \code{\link{line2points}()}, \code{\link{line_breakup}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{mats2line}()}, \code{\link{n_segments}()}, diff --git a/man/line_breakup.Rd b/man/line_breakup.Rd index 9d3b805d..0081db3d 100644 --- a/man/line_breakup.Rd +++ b/man/line_breakup.Rd @@ -41,8 +41,8 @@ Other lines: \code{\link{line2points}()}, \code{\link{line_bearing}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{mats2line}()}, \code{\link{n_segments}()}, diff --git a/man/line_midpoint.Rd b/man/line_midpoint.Rd index b9ce490b..e12c30b3 100644 --- a/man/line_midpoint.Rd +++ b/man/line_midpoint.Rd @@ -33,8 +33,8 @@ Other lines: \code{\link{line2points}()}, \code{\link{line_bearing}()}, \code{\link{line_breakup}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{mats2line}()}, \code{\link{n_segments}()}, diff --git a/man/line_segment.Rd b/man/line_segment.Rd index 04e3da14..78b902ea 100644 --- a/man/line_segment.Rd +++ b/man/line_segment.Rd @@ -37,6 +37,8 @@ but does not always return the number of segments requested. library(sf) l <- routes_fast_sf[2:4, ] l_seg_multi <- line_segment(l, segment_length = 1000, use_rsgeo = FALSE) +l_seg_n <- line_segment(l, n_segments = 2) +l_seg_n <- line_segment(l, n_segments = c(1:3)) # Number of subsegments table(l_seg_multi$ID) plot(l_seg_multi["ID"]) diff --git a/man/line_via.Rd b/man/line_via.Rd index 210fbc62..9df803c2 100644 --- a/man/line_via.Rd +++ b/man/line_via.Rd @@ -46,8 +46,8 @@ Other lines: \code{\link{line_bearing}()}, \code{\link{line_breakup}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{mats2line}()}, \code{\link{n_segments}()}, \code{\link{n_vertices}()}, diff --git a/man/mats2line.Rd b/man/mats2line.Rd index 7fa9a56e..bcd086e8 100644 --- a/man/mats2line.Rd +++ b/man/mats2line.Rd @@ -37,8 +37,8 @@ Other lines: \code{\link{line_bearing}()}, \code{\link{line_breakup}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{n_segments}()}, \code{\link{n_vertices}()}, diff --git a/man/n_segments.Rd b/man/n_segments.Rd index f639725d..21444ad3 100644 --- a/man/n_segments.Rd +++ b/man/n_segments.Rd @@ -30,8 +30,8 @@ Other lines: \code{\link{line_bearing}()}, \code{\link{line_breakup}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{mats2line}()}, \code{\link{n_vertices}()}, diff --git a/man/n_vertices.Rd b/man/n_vertices.Rd index 4db0c195..db72c847 100644 --- a/man/n_vertices.Rd +++ b/man/n_vertices.Rd @@ -27,8 +27,8 @@ Other lines: \code{\link{line_bearing}()}, \code{\link{line_breakup}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{mats2line}()}, \code{\link{n_segments}()}, diff --git a/man/od2line.Rd b/man/od2line.Rd index 9222befd..35883207 100644 --- a/man/od2line.Rd +++ b/man/od2line.Rd @@ -71,10 +71,10 @@ Other od: \code{\link{od2odf}()}, \code{\link{od_aggregate_from}()}, \code{\link{od_aggregate_to}()}, -\code{\link{od_coords2line}()}, \code{\link{od_coords}()}, -\code{\link{od_id_order}()}, +\code{\link{od_coords2line}()}, \code{\link{od_id}}, +\code{\link{od_id_order}()}, \code{\link{od_oneway}()}, \code{\link{od_to_odmatrix}()}, \code{\link{odmatrix_to_od}()}, diff --git a/man/od2odf.Rd b/man/od2odf.Rd index 02518bb1..68fd4a7b 100644 --- a/man/od2odf.Rd +++ b/man/od2odf.Rd @@ -38,10 +38,10 @@ Other od: \code{\link{od2line}()}, \code{\link{od_aggregate_from}()}, \code{\link{od_aggregate_to}()}, -\code{\link{od_coords2line}()}, \code{\link{od_coords}()}, -\code{\link{od_id_order}()}, +\code{\link{od_coords2line}()}, \code{\link{od_id}}, +\code{\link{od_id_order}()}, \code{\link{od_oneway}()}, \code{\link{od_to_odmatrix}()}, \code{\link{odmatrix_to_od}()}, diff --git a/man/od_aggregate_from.Rd b/man/od_aggregate_from.Rd index 38c12294..8b7a1573 100644 --- a/man/od_aggregate_from.Rd +++ b/man/od_aggregate_from.Rd @@ -39,10 +39,10 @@ Other od: \code{\link{od2line}()}, \code{\link{od2odf}()}, \code{\link{od_aggregate_to}()}, -\code{\link{od_coords2line}()}, \code{\link{od_coords}()}, -\code{\link{od_id_order}()}, +\code{\link{od_coords2line}()}, \code{\link{od_id}}, +\code{\link{od_id_order}()}, \code{\link{od_oneway}()}, \code{\link{od_to_odmatrix}()}, \code{\link{odmatrix_to_od}()}, diff --git a/man/od_aggregate_to.Rd b/man/od_aggregate_to.Rd index d9a68fe9..e4020fab 100644 --- a/man/od_aggregate_to.Rd +++ b/man/od_aggregate_to.Rd @@ -39,10 +39,10 @@ Other od: \code{\link{od2line}()}, \code{\link{od2odf}()}, \code{\link{od_aggregate_from}()}, -\code{\link{od_coords2line}()}, \code{\link{od_coords}()}, -\code{\link{od_id_order}()}, +\code{\link{od_coords2line}()}, \code{\link{od_id}}, +\code{\link{od_id_order}()}, \code{\link{od_oneway}()}, \code{\link{od_to_odmatrix}()}, \code{\link{odmatrix_to_od}()}, diff --git a/man/od_coords.Rd b/man/od_coords.Rd index 0d90aed2..0e23df7d 100644 --- a/man/od_coords.Rd +++ b/man/od_coords.Rd @@ -32,8 +32,8 @@ Other od: \code{\link{od_aggregate_from}()}, \code{\link{od_aggregate_to}()}, \code{\link{od_coords2line}()}, -\code{\link{od_id_order}()}, \code{\link{od_id}}, +\code{\link{od_id_order}()}, \code{\link{od_oneway}()}, \code{\link{od_to_odmatrix}()}, \code{\link{odmatrix_to_od}()}, diff --git a/man/od_coords2line.Rd b/man/od_coords2line.Rd index fd18774b..3c321c1e 100644 --- a/man/od_coords2line.Rd +++ b/man/od_coords2line.Rd @@ -44,8 +44,8 @@ Other od: \code{\link{od_aggregate_from}()}, \code{\link{od_aggregate_to}()}, \code{\link{od_coords}()}, -\code{\link{od_id_order}()}, \code{\link{od_id}}, +\code{\link{od_id_order}()}, \code{\link{od_oneway}()}, \code{\link{od_to_odmatrix}()}, \code{\link{odmatrix_to_od}()}, diff --git a/man/od_data_lines.Rd b/man/od_data_lines.Rd index 657657c6..d7652271 100644 --- a/man/od_data_lines.Rd +++ b/man/od_data_lines.Rd @@ -17,9 +17,9 @@ od_data_lines Other data: \code{\link{cents_sf}}, \code{\link{destinations_sf}}, +\code{\link{flow}}, \code{\link{flow_dests}}, \code{\link{flowlines_sf}}, -\code{\link{flow}}, \code{\link{od_data_routes}}, \code{\link{od_data_sample}}, \code{\link{osm_net_example}}, diff --git a/man/od_data_routes.Rd b/man/od_data_routes.Rd index d7a17c9f..cbe7c6d9 100644 --- a/man/od_data_routes.Rd +++ b/man/od_data_routes.Rd @@ -19,9 +19,9 @@ od_data_routes Other data: \code{\link{cents_sf}}, \code{\link{destinations_sf}}, +\code{\link{flow}}, \code{\link{flow_dests}}, \code{\link{flowlines_sf}}, -\code{\link{flow}}, \code{\link{od_data_lines}}, \code{\link{od_data_sample}}, \code{\link{osm_net_example}}, diff --git a/man/od_data_sample.Rd b/man/od_data_sample.Rd index 8930e8d8..029b4358 100644 --- a/man/od_data_sample.Rd +++ b/man/od_data_sample.Rd @@ -17,9 +17,9 @@ od_data_sample Other data: \code{\link{cents_sf}}, \code{\link{destinations_sf}}, +\code{\link{flow}}, \code{\link{flow_dests}}, \code{\link{flowlines_sf}}, -\code{\link{flow}}, \code{\link{od_data_lines}}, \code{\link{od_data_routes}}, \code{\link{osm_net_example}}, diff --git a/man/od_id.Rd b/man/od_id.Rd index 3dc434b1..b3e79b2f 100644 --- a/man/od_id.Rd +++ b/man/od_id.Rd @@ -50,8 +50,8 @@ Other od: \code{\link{od2odf}()}, \code{\link{od_aggregate_from}()}, \code{\link{od_aggregate_to}()}, -\code{\link{od_coords2line}()}, \code{\link{od_coords}()}, +\code{\link{od_coords2line}()}, \code{\link{od_id_order}()}, \code{\link{od_oneway}()}, \code{\link{od_to_odmatrix}()}, diff --git a/man/od_id_order.Rd b/man/od_id_order.Rd index 7b2acdd9..53476de8 100644 --- a/man/od_id_order.Rd +++ b/man/od_id_order.Rd @@ -32,8 +32,8 @@ Other od: \code{\link{od2odf}()}, \code{\link{od_aggregate_from}()}, \code{\link{od_aggregate_to}()}, -\code{\link{od_coords2line}()}, \code{\link{od_coords}()}, +\code{\link{od_coords2line}()}, \code{\link{od_id}}, \code{\link{od_oneway}()}, \code{\link{od_to_odmatrix}()}, diff --git a/man/od_oneway.Rd b/man/od_oneway.Rd index d7fc4770..f51462ef 100644 --- a/man/od_oneway.Rd +++ b/man/od_oneway.Rd @@ -68,10 +68,10 @@ Other od: \code{\link{od2odf}()}, \code{\link{od_aggregate_from}()}, \code{\link{od_aggregate_to}()}, -\code{\link{od_coords2line}()}, \code{\link{od_coords}()}, -\code{\link{od_id_order}()}, +\code{\link{od_coords2line}()}, \code{\link{od_id}}, +\code{\link{od_id_order}()}, \code{\link{od_to_odmatrix}()}, \code{\link{odmatrix_to_od}()}, \code{\link{points2flow}()}, diff --git a/man/od_to_odmatrix.Rd b/man/od_to_odmatrix.Rd index b54ceec9..1c1f38fd 100644 --- a/man/od_to_odmatrix.Rd +++ b/man/od_to_odmatrix.Rd @@ -35,10 +35,10 @@ Other od: \code{\link{od2odf}()}, \code{\link{od_aggregate_from}()}, \code{\link{od_aggregate_to}()}, -\code{\link{od_coords2line}()}, \code{\link{od_coords}()}, -\code{\link{od_id_order}()}, +\code{\link{od_coords2line}()}, \code{\link{od_id}}, +\code{\link{od_id_order}()}, \code{\link{od_oneway}()}, \code{\link{odmatrix_to_od}()}, \code{\link{points2flow}()}, diff --git a/man/odmatrix_to_od.Rd b/man/odmatrix_to_od.Rd index e543debc..0111731d 100644 --- a/man/odmatrix_to_od.Rd +++ b/man/odmatrix_to_od.Rd @@ -33,10 +33,10 @@ Other od: \code{\link{od2odf}()}, \code{\link{od_aggregate_from}()}, \code{\link{od_aggregate_to}()}, -\code{\link{od_coords2line}()}, \code{\link{od_coords}()}, -\code{\link{od_id_order}()}, +\code{\link{od_coords2line}()}, \code{\link{od_id}}, +\code{\link{od_id_order}()}, \code{\link{od_oneway}()}, \code{\link{od_to_odmatrix}()}, \code{\link{points2flow}()}, diff --git a/man/onewaygeo.Rd b/man/onewaygeo.Rd index 02c32f2e..51bedf25 100644 --- a/man/onewaygeo.Rd +++ b/man/onewaygeo.Rd @@ -40,8 +40,8 @@ Other lines: \code{\link{line_bearing}()}, \code{\link{line_breakup}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{mats2line}()}, \code{\link{n_segments}()}, diff --git a/man/osm_net_example.Rd b/man/osm_net_example.Rd index 3652e4b6..1914dc62 100644 --- a/man/osm_net_example.Rd +++ b/man/osm_net_example.Rd @@ -17,9 +17,9 @@ osm_net_example Other data: \code{\link{cents_sf}}, \code{\link{destinations_sf}}, +\code{\link{flow}}, \code{\link{flow_dests}}, \code{\link{flowlines_sf}}, -\code{\link{flow}}, \code{\link{od_data_lines}}, \code{\link{od_data_routes}}, \code{\link{od_data_sample}}, diff --git a/man/points2flow.Rd b/man/points2flow.Rd index 753a7289..65a612ee 100644 --- a/man/points2flow.Rd +++ b/man/points2flow.Rd @@ -24,10 +24,10 @@ Other od: \code{\link{od2odf}()}, \code{\link{od_aggregate_from}()}, \code{\link{od_aggregate_to}()}, -\code{\link{od_coords2line}()}, \code{\link{od_coords}()}, -\code{\link{od_id_order}()}, +\code{\link{od_coords2line}()}, \code{\link{od_id}}, +\code{\link{od_id_order}()}, \code{\link{od_oneway}()}, \code{\link{od_to_odmatrix}()}, \code{\link{odmatrix_to_od}()}, diff --git a/man/points2line.Rd b/man/points2line.Rd index d63ebd16..e8a231b1 100644 --- a/man/points2line.Rd +++ b/man/points2line.Rd @@ -27,8 +27,8 @@ Other lines: \code{\link{line_bearing}()}, \code{\link{line_breakup}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{mats2line}()}, \code{\link{n_segments}()}, diff --git a/man/points2odf.Rd b/man/points2odf.Rd index 1f4c96b7..6f7cac69 100644 --- a/man/points2odf.Rd +++ b/man/points2odf.Rd @@ -23,10 +23,10 @@ Other od: \code{\link{od2odf}()}, \code{\link{od_aggregate_from}()}, \code{\link{od_aggregate_to}()}, -\code{\link{od_coords2line}()}, \code{\link{od_coords}()}, -\code{\link{od_id_order}()}, +\code{\link{od_coords2line}()}, \code{\link{od_id}}, +\code{\link{od_id_order}()}, \code{\link{od_oneway}()}, \code{\link{od_to_odmatrix}()}, \code{\link{odmatrix_to_od}()}, diff --git a/man/quadrant.Rd b/man/quadrant.Rd index e1ca2f71..1ee76599 100644 --- a/man/quadrant.Rd +++ b/man/quadrant.Rd @@ -28,8 +28,8 @@ plot(x$geometry, col = factor(quads)) Other geo: \code{\link{bbox_scale}()}, \code{\link{bind_sf}()}, -\code{\link{geo_bb_matrix}()}, \code{\link{geo_bb}()}, +\code{\link{geo_bb_matrix}()}, \code{\link{geo_buffer}()}, \code{\link{geo_length}()}, \code{\link{geo_projected}()}, diff --git a/man/read_table_builder.Rd b/man/read_table_builder.Rd index 35ae988f..fe827d84 100644 --- a/man/read_table_builder.Rd +++ b/man/read_table_builder.Rd @@ -44,9 +44,9 @@ package for this purpose. Other data: \code{\link{cents_sf}}, \code{\link{destinations_sf}}, +\code{\link{flow}}, \code{\link{flow_dests}}, \code{\link{flowlines_sf}}, -\code{\link{flow}}, \code{\link{od_data_lines}}, \code{\link{od_data_routes}}, \code{\link{od_data_sample}}, diff --git a/man/route_dodgr.Rd b/man/route_dodgr.Rd index 6e69683b..4f740b20 100644 --- a/man/route_dodgr.Rd +++ b/man/route_dodgr.Rd @@ -35,7 +35,7 @@ if (requireNamespace("dodgr")) { } \seealso{ Other routes: -\code{\link{route_osrm}()}, -\code{\link{route}()} +\code{\link{route}()}, +\code{\link{route_osrm}()} } \concept{routes} diff --git a/man/route_network_sf.Rd b/man/route_network_sf.Rd index f9255968..c89c21df 100644 --- a/man/route_network_sf.Rd +++ b/man/route_network_sf.Rd @@ -15,9 +15,9 @@ The flow of commuters using different segments of the road network represented i Other data: \code{\link{cents_sf}}, \code{\link{destinations_sf}}, +\code{\link{flow}}, \code{\link{flow_dests}}, \code{\link{flowlines_sf}}, -\code{\link{flow}}, \code{\link{od_data_lines}}, \code{\link{od_data_routes}}, \code{\link{od_data_sample}}, diff --git a/man/route_network_small.Rd b/man/route_network_small.Rd index 3b6ab221..9bb02cb1 100644 --- a/man/route_network_small.Rd +++ b/man/route_network_small.Rd @@ -15,9 +15,9 @@ See \code{data-raw/route_network_small.R} for details. Other data: \code{\link{cents_sf}}, \code{\link{destinations_sf}}, +\code{\link{flow}}, \code{\link{flow_dests}}, \code{\link{flowlines_sf}}, -\code{\link{flow}}, \code{\link{od_data_lines}}, \code{\link{od_data_routes}}, \code{\link{od_data_sample}}, diff --git a/man/route_osrm.Rd b/man/route_osrm.Rd index 1a4cf277..0a4f161f 100644 --- a/man/route_osrm.Rd +++ b/man/route_osrm.Rd @@ -51,7 +51,7 @@ slower R interface to OSRM routing services compared with the excellent } \seealso{ Other routes: -\code{\link{route_dodgr}()}, -\code{\link{route}()} +\code{\link{route}()}, +\code{\link{route_dodgr}()} } \concept{routes} diff --git a/man/routes_fast_sf.Rd b/man/routes_fast_sf.Rd index bc451361..1c249db3 100644 --- a/man/routes_fast_sf.Rd +++ b/man/routes_fast_sf.Rd @@ -19,9 +19,9 @@ objects. Other data: \code{\link{cents_sf}}, \code{\link{destinations_sf}}, +\code{\link{flow}}, \code{\link{flow_dests}}, \code{\link{flowlines_sf}}, -\code{\link{flow}}, \code{\link{od_data_lines}}, \code{\link{od_data_routes}}, \code{\link{od_data_sample}}, diff --git a/man/routes_slow_sf.Rd b/man/routes_slow_sf.Rd index 6365b4ba..b4182c29 100644 --- a/man/routes_slow_sf.Rd +++ b/man/routes_slow_sf.Rd @@ -15,9 +15,9 @@ representing the 'quietest' between \code{cents_sf}. Other data: \code{\link{cents_sf}}, \code{\link{destinations_sf}}, +\code{\link{flow}}, \code{\link{flow_dests}}, \code{\link{flowlines_sf}}, -\code{\link{flow}}, \code{\link{od_data_lines}}, \code{\link{od_data_routes}}, \code{\link{od_data_sample}}, diff --git a/man/toptail_buff.Rd b/man/toptail_buff.Rd index 4faf234e..e4b104b6 100644 --- a/man/toptail_buff.Rd +++ b/man/toptail_buff.Rd @@ -37,8 +37,8 @@ Other lines: \code{\link{line_bearing}()}, \code{\link{line_breakup}()}, \code{\link{line_midpoint}()}, -\code{\link{line_segment1}()}, \code{\link{line_segment}()}, +\code{\link{line_segment1}()}, \code{\link{line_via}()}, \code{\link{mats2line}()}, \code{\link{n_segments}()}, diff --git a/man/zones_sf.Rd b/man/zones_sf.Rd index 83f1ae77..b306dc80 100644 --- a/man/zones_sf.Rd +++ b/man/zones_sf.Rd @@ -21,9 +21,9 @@ plot(zones_sf) Other data: \code{\link{cents_sf}}, \code{\link{destinations_sf}}, +\code{\link{flow}}, \code{\link{flow_dests}}, \code{\link{flowlines_sf}}, -\code{\link{flow}}, \code{\link{od_data_lines}}, \code{\link{od_data_routes}}, \code{\link{od_data_sample}}, From dba1894790470cabcab6c9b2f95246ab24f9762f Mon Sep 17 00:00:00 2001 From: robinlovelace Date: Wed, 1 May 2024 15:33:37 +0100 Subject: [PATCH 2/2] Allow n_segments to be > 1, fix #560 --- R/linefuns.R | 6 +++--- man/line_segment.Rd | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/linefuns.R b/R/linefuns.R index 558063d0..098751af 100644 --- a/R/linefuns.R +++ b/R/linefuns.R @@ -172,7 +172,7 @@ line_midpoint <- function(l, tolerance = NULL) { #' @export #' @examples #' library(sf) -#' l <- routes_fast_sf[2:4, ] +#' l <- routes_fast_sf[2:4, "ID"] #' l_seg_multi <- line_segment(l, segment_length = 1000, use_rsgeo = FALSE) #' l_seg_n <- line_segment(l, n_segments = 2) #' l_seg_n <- line_segment(l, n_segments = c(1:3)) @@ -202,7 +202,7 @@ line_segment <- function( use_rsgeo = NULL, debug_mode = FALSE) { # Defensive programming: - if (is.na(segment_length) && is.na(n_segments)) { + if (any(is.na(segment_length)) && any(is.na(n_segments))) { rlang::abort( "segment_length or n_segments must be set.", call = rlang::caller_env() @@ -219,7 +219,7 @@ line_segment.sf <- function( debug_mode = FALSE ) { # Get n_segments if not provided: - if (is.na(n_segments)) { + if (all(is.na(n_segments))) { segment_lengths <- as.numeric(sf::st_length(l)) n_segments <- n_segments(segment_lengths, segment_length) } else { diff --git a/man/line_segment.Rd b/man/line_segment.Rd index 78b902ea..afe23612 100644 --- a/man/line_segment.Rd +++ b/man/line_segment.Rd @@ -35,7 +35,7 @@ but does not always return the number of segments requested. } \examples{ library(sf) -l <- routes_fast_sf[2:4, ] +l <- routes_fast_sf[2:4, "ID"] l_seg_multi <- line_segment(l, segment_length = 1000, use_rsgeo = FALSE) l_seg_n <- line_segment(l, n_segments = 2) l_seg_n <- line_segment(l, n_segments = c(1:3))