r-spatial / sf
Showing 2 of 5 files from the diff.

@@ -649,7 +649,7 @@
Loading
649 649
# after checking identical crs,
650 650
# call geos_op2 function op on x and y:
651 651
# DE-9IM compliant should use model = "closed", more robust seems:
652 -
geos_op2_geom = function(op, x, y, s2_model = "semi-open", ...) {
652 +
geos_op2_geom = function(op, x, y, model = "semi-open", ...) {
653 653
	stopifnot(st_crs(x) == st_crs(y))
654 654
	x = st_geometry(x)
655 655
	y = st_geometry(y)
@@ -660,7 +660,7 @@
Loading
660 660
				sym_difference = s2::s2_sym_difference,
661 661
				union = s2::s2_union, stop("invalid operator"))
662 662
		# to be optimized -- this doesn't index on y:
663 -
		lst = structure(unlist(lapply(y, function(yy) fn(x, yy, s2::s2_options(model = s2_model, ...))),
663 +
		lst = structure(unlist(lapply(y, function(yy) fn(x, yy, s2::s2_options(model = model, ...))),
664 664
			recursive = FALSE), class = "s2_geography")
665 665
		e = s2::s2_is_empty(lst)
666 666
		idx = cbind(rep(seq_along(x), length(y)), rep(seq_along(y), each = length(x)))
@@ -696,6 +696,8 @@
Loading
696 696
#' @export
697 697
#' @note To find whether pairs of simple feature geometries intersect, use
698 698
#' the function \code{\link{st_intersects}} instead of \code{st_intersection}.
699 +
#'
700 +
#' When using GEOS and not using s2 polygons contain their boundary. When using s2 this is determined by the \code{model} defaults of \link[s2]{s2_options}, which can be overriden via the ... argument, e.g. \code{model = "closed"} to force DE-9IM compliant behaviour of polygons (and reproduce GEOS results).
699 701
#' @examples
700 702
#' set.seed(131)
701 703
#' library(sf)

@@ -33,16 +33,16 @@
Loading
33 33
34 34
# returning matrix, distance or relation string -- the work horse is:
35 35
st_geos_binop = function(op, x, y, par = 0.0, pattern = NA_character_,
36 -
		sparse = TRUE, prepared = FALSE, s2_model = "closed", ...) {
36 +
		sparse = TRUE, prepared = FALSE, model = "closed", ...) {
37 37
	if (missing(y))
38 38
		y = x
39 39
	else if (inherits(x, c("sf", "sfc")) && inherits(y, c("sf", "sfc")))
40 40
		stopifnot(st_crs(x) == st_crs(y))
41 41
	longlat = inherits(x, "s2geography") || isTRUE(st_is_longlat(x))
42 -
	if (longlat && sf_use_s2() && op %in% c("intersects", "contains", "within", 
42 +
	if (longlat && sf_use_s2() && op %in% c("intersects", "contains", "within",
43 43
			"covers", "covered_by", "disjoint", "equals", "touches")) {
44 44
		fn = get(paste0("s2_", op, "_matrix"), envir = getNamespace("s2")) # get op function
45 -
		lst = fn(x, y, s2::s2_options(model = s2_model, ...)) # call function
45 +
		lst = fn(x, y, s2::s2_options(model = model, ...)) # call function
46 46
		id = if (is.null(row.names(x)))
47 47
				as.character(seq_along(lst))
48 48
			else
@@ -177,16 +177,16 @@
Loading
177 177
178 178
#' @name geos_binary_pred
179 179
#' @export
180 -
st_within		= function(x, y, sparse = TRUE, prepared = TRUE, ...)
180 +
st_within	= function(x, y, sparse = TRUE, prepared = TRUE, ...)
181 181
	st_geos_binop("within", x, y, sparse = sparse, prepared = prepared, ...)
182 182
183 183
#' @name geos_binary_pred
184 -
#' @param s2_model character; polygon/polyline model; one of 
184 +
#' @param model character; polygon/polyline model; one of
185 185
#' "open", "semi-open" or "closed"; see Details.
186 -
#' @details for \code{s2_model}, see https://github.com/r-spatial/s2/issues/32
186 +
#' @details for \code{model}, see https://github.com/r-spatial/s2/issues/32
187 187
#' @export
188 -
st_contains		= function(x, y, sparse = TRUE, prepared = TRUE, ..., s2_model = "open")
189 -
	st_geos_binop("contains", x, y, sparse = sparse, prepared = prepared, ..., s2_model = s2_model)
188 +
st_contains	= function(x, y, sparse = TRUE, prepared = TRUE, ..., model = "open")
189 +
	st_geos_binop("contains", x, y, sparse = sparse, prepared = prepared, ..., model = model)
190 190
191 191
#' @name geos_binary_pred
192 192
#' @export
@@ -214,13 +214,13 @@
Loading
214 214
215 215
#' @name geos_binary_pred
216 216
#' @export
217 -
st_covers		= function(x, y, sparse = TRUE, prepared = TRUE, ..., s2_model = "closed")
218 -
	st_geos_binop("covers", x, y, sparse = sparse, prepared = prepared, ..., s2_model = s2_model)
217 +
st_covers = function(x, y, sparse = TRUE, prepared = TRUE, ..., model = "closed")
218 +
	st_geos_binop("covers", x, y, sparse = sparse, prepared = prepared, ..., model = model)
219 219
220 220
221 221
#' @name geos_binary_pred
222 222
#' @export
223 -
st_covered_by	= function(x, y = x, sparse = TRUE, prepared = TRUE, ..., s2_model = "closed")
223 +
st_covered_by = function(x, y = x, sparse = TRUE, prepared = TRUE, ..., model = "closed")
224 224
	st_geos_binop("covered_by", x, y, sparse = sparse, prepared = prepared, ...)
225 225
226 226
Files Coverage
R 87.88%
src 77.62%
Project Totals (66 files) 83.63%
1
comment: false
2
ignore:
3
  - "inst/include/sf_RcppExports.h" 
4
  - "sf/R/stars.R"
5
  - "sf/R/gdal_utils.R"
6
  - "sf/src/raster2sf.cpp"
7
  - "sf/src/gdal_utils.cpp"
8
  - "sf/src/stars.cpp"
9

10
coverage:
11
  status:
12
    patch:
13
      default:
14
        target: 0
15
        threshold: 100
16
    project:
17
      default:
18
        target: 70
19
        threshold: 100
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading