Skip to content

Commit

Permalink
add first prototype for #153
Browse files Browse the repository at this point in the history
  • Loading branch information
agila5 committed Jul 6, 2021
1 parent bc24b93 commit de88a09
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export(oe_download_directory)
export(oe_find)
export(oe_get)
export(oe_get_keys)
export(oe_get_transport)
export(oe_match)
export(oe_match_pattern)
export(oe_providers)
Expand Down
84 changes: 84 additions & 0 deletions R/get-transport.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#' Import road network according to a specific mode of transport
#'
#' TODO
#'
#' @inheritParams oe_get
#' @param mode The mode of transport. Can be abbreviated.
#' @param ... IGNORED FOR THE MOMENT. Additional arguments passed to `oe_get()`.
#' Please note that the arguments `layer` and `vectortranslate_options` cannot
#' be provided since are set according to the `mode` parameter.
#'
#' @return An `sf` object.
#' @export
#'
#' @details TODO (precisely describe the functions)
#'
#' @seealso [`oe_get()`]
#'
#' @examples
#' 1 + 1
oe_get_transport <- function(
place,
mode = c("cycling", "walking"),
...
) {
mode = match.arg(mode)
oe_get_options = switch(
mode,
cycling = load_options_cycling(place, mode),
walking = load_options_walking(place, mode)
)

do.call(oe_get, oe_get_options)
}

# List options that are used by oe_get_transport
load_options_cycling <- function(place, mode) {
list(
place = place,
layer = "lines",
extra_tags = c("access", "area", "bicycle", "service"),
vectortranslate_options = c(
"-where", "
(area IS NULL OR area != 'yes')
AND
(access IS NULL OR access NOT IN ('private', 'no'))
AND
(highway IS NOT NULL AND
highway NOT IN (
'abandonded', 'bus_guideway', 'construction', 'corridor', 'elevator', 'escalator', 'footway',
'planned', 'platform', 'proposed', 'raceway', 'steps'
))
AND
(bicycle IS NULL OR bicycle != 'no')
AND
(service IS NULL OR service != 'private')
"
)
)
}
load_options_walking <- function(place, mode) {
list(
place = place,
layer = "lines",
extra_tags = c("access", "area", "foot", "service"),
vectortranslate_options = c(
"-where", "
(area IS NULL OR area != 'yes')
AND
(access IS NULL OR access NOT IN ('private', 'no'))
AND
(highway IS NOT NULL AND
highway NOT IN (
'abandonded', 'bus_guideway', 'construction', 'cycleway',
'planned', 'platform', 'proposed', 'raceway'
))
AND
(foot IS NULL OR foot != 'no')
AND
(service IS NULL OR service != 'private')
"
)
)
}

37 changes: 37 additions & 0 deletions man/oe_get_transport.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de88a09

Please sign in to comment.