-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#' Boolean within | ||
#' | ||
#' returns `TRUE` if the first geometry is completely within the second | ||
#' geometry | ||
#' | ||
#' @export | ||
#' @param feature1,feature2 any [data-Geometry]/[data-Feature] objects | ||
#' @family boolean functions | ||
#' @return a logical (`TRUE`/`FALSE`) | ||
#' @examples | ||
#' pt1 <- '[1, 2]' | ||
#' l1 <- '[[1, 1], [1, 2], [1, 3], [1, 4]]' | ||
#' lawn_boolean_within(lawn_point(pt1), lawn_linestring(l1)) | ||
lawn_boolean_within <- function(feature1, feature2, lint = FALSE) { | ||
lawnlint(list(feature1, feature2), lint) | ||
ct$eval(sprintf("var bdj = turf.booleanWithin(%s, %s);", | ||
convert(feature1), convert(feature2))) | ||
ct$get("bdj") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#' Minimum distance between a point and a lineString | ||
#' | ||
#' Returns the minimum distance between a [data-Point] and a [data-LineString], | ||
#' being the distance from a line the minimum distance between the | ||
#' point and any segment of the LineString. | ||
#' | ||
#' @export | ||
#' @param point ([data-Feature]<([data-Point])>) feature or geometry | ||
#' @param line Line to measure, a [data-Feature]<([data-LineString])>, | ||
#' or [data-FeatureCollection]<([data-LineString])> | ||
#' @param units (character) Can be degrees, radians, miles, or kilometers | ||
#' (default) | ||
#' @param mercator (logical) if distance should be on Mercator or WGS84 | ||
#' projection. Default: `FALSE` | ||
#' @template lint | ||
#' @family measurements | ||
#' @return distance between point and line (numeric) | ||
#' @examples | ||
#' pt <- lawn_point("[0, 0]") | ||
#' ln <- lawn_linestring("[[1, 1],[-1, 1]]") | ||
#' | ||
#' lawn_pt2line_distance(pt, ln) | ||
#' lawn_pt2line_distance(pt, ln, mercator = TRUE) | ||
#' | ||
#' lawn_pt2line_distance(pt, ln, 'miles') | ||
#' lawn_pt2line_distance(pt, ln, 'radians') | ||
#' lawn_pt2line_distance(pt, ln, 'degrees') | ||
#' lawn_pt2line_distance(pt, ln, mercator = TRUE) | ||
lawn_pt2line_distance <- function(point, line, units = "kilometers", | ||
mercator = FALSE, lint = FALSE) { | ||
|
||
point <- convert(point) | ||
line <- convert(line) | ||
lawnlint(list(point, line), lint) | ||
assert(units, "character") | ||
assert(mercator, "logical") | ||
ct$eval(sprintf("var xxx = turf.pointToLineDistance(%s, %s, '%s', %s);", | ||
point, line, units, convert(mercator))) | ||
ct$get("xxx") | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.