Skip to content

Commit

Permalink
Merge pull request #97 from richardellison/master
Browse files Browse the repository at this point in the history
Rebuild documentation for additional functions to fix Travis-CI build.
  • Loading branch information
richardellison authored Aug 29, 2016
2 parents 422345c + 840f0e0 commit dc369d0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion R/linefuns.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ line_bearing = function(l, bidirectional = FALSE){
#' @export
#' @examples
#' # find all routes going North-South
#' a = angle_diff(flowlines, angle = 0, bidirectional = T)
#' a = angle_diff(flowlines, angle = 0, bidirectional = TRUE, absolute = TRUE)
#' plot(flowlines)
#' plot(flowlines[a < 15,], add = TRUE, lwd = 3, col = "red")
#' # East-West
Expand Down
22 changes: 14 additions & 8 deletions R/od-funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ od2odf <- function(flow, zones){
fx = coordinates(zones)[,1], fy = coordinates(zones)[,2])
flowcode = dplyr::data_frame(code_o = as.character(flow[[1]]), code_d = as.character(flow[[2]]))
odf = dplyr::left_join(flowcode, coords, by = c("code_o" = "code"))
coords = dplyr::rename(coords, tx = fx, ty = fy)
coords = dplyr::rename_(coords, tx = quote(fx), ty = quote(fy))
odf = dplyr::left_join(odf, coords, by = c("code_d" = "code"))

data.frame(odf) # return data.frame as more compatible with spatial data
Expand Down Expand Up @@ -112,8 +112,8 @@ od2line2 <- function(flow, zones){
#' line2df(routes_fast[5:6,]) # beginning and end of routes
line2df <- function(l){
ldf_geom = raster::geom(l)
dplyr::group_by(as_data_frame(ldf_geom), object) %>%
summarise(fx = first(x), fy = first(y), tx = last(x), ty = last(y))
dplyr::group_by_(dplyr::as_data_frame(ldf_geom), 'object') %>%
summarise_(fx = quote(first(x)), fy = quote(first(y)), tx = quote(last(x)), ty = quote(last(y)))
}

#' Convert a SpatialLinesDataFrame to points
Expand All @@ -140,6 +140,11 @@ line2df <- function(l){
#' j = (2*i):((2*i)+1)
#' plot(flowlines[i,])
#' plot(lpoints[j,], add = TRUE)
#' @name line2points
NULL

#' @rdname line2points
#' @export
line2points <- function(l){
for(i in 1:length(l)){
l1 <- l[i,]
Expand All @@ -154,7 +159,8 @@ line2points <- function(l){
}
out
}
#' rdname line2points

#' @rdname line2points
#' @export
line2pointsn <- function(l){
spdf = raster::geom(l)
Expand Down Expand Up @@ -306,10 +312,10 @@ update_line_geometry <- function(l, nl){
#' data(cents)
#' od_dist(flow, cents)
od_dist <- function(flow, zones){
omatch = match(flow[[1]], cents@data[[1]])
dmatch = match(flow[[2]], cents@data[[1]])
cents_o = cents@coords[omatch,]
cents_d = cents@coords[dmatch,]
omatch = match(flow[[1]], zones@data[[1]])
dmatch = match(flow[[2]], zones@data[[1]])
cents_o = zones@coords[omatch,]
cents_d = zones@coords[dmatch,]
geosphere::distHaversine(p1 = cents_o, p2 = cents_d)
}

Expand Down
4 changes: 2 additions & 2 deletions R/overline.R
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,11 @@ onewayid <- function(x, attrib, id1 = names(x)[1], id2 = names(x)[2]){
dplyr::mutate_(stplanr.id1 = id1,
stplanr.id2 = id2,
stplanr.key = ~paste(pmin(stplanr.id1, stplanr.id2), pmax(stplanr.id1, stplanr.id2))) %>%
dplyr::group_by(stplanr.key) %>%
dplyr::group_by_(quote(stplanr.key)) %>%
dplyr::mutate(is_two_way = ifelse(n() > 1, TRUE, FALSE)) %>%
dplyr::mutate_each("sum", attrib) %>%
dplyr::summarise_each_(funs("stplanr.first"),c(id1, id2, attrib, ~is_two_way)) %>%
dplyr::select(-stplanr.key)
dplyr::select_(quote(-stplanr.key))

return(x_oneway)

Expand Down
10 changes: 6 additions & 4 deletions man/angle_diff.Rd

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

3 changes: 3 additions & 0 deletions man/line2points.Rd

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

12 changes: 0 additions & 12 deletions man/line2pointsn.Rd

This file was deleted.

0 comments on commit dc369d0

Please sign in to comment.