Skip to content

Commit cc3385b

Browse files
committed
fix #234 fix ecoengine bug in bbox usage
use wellknown instead of wicket for doing wkt manipulation #235
1 parent 2217923 commit cc3385b

11 files changed

+98
-138
lines changed

DESCRIPTION

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Description: A programmatic interface to many species occurrence data sources,
88
System ('OBIS'), and Atlas of Living Australia ('ALA'). Includes
99
functionality for retrieving species occurrence data, and combining
1010
those data.
11-
Version: 1.1.0
11+
Version: 1.1.1.91
1212
License: MIT + file LICENSE
1313
Authors@R:
1414
c(person(given = "Scott", family = "Chamberlain",
@@ -40,13 +40,14 @@ Imports:
4040
jsonlite (>= 1.4),
4141
data.table (>= 1.9.6),
4242
tibble (>= 1.2),
43-
wicket (>= 0.4.0)
43+
wellknown
4444
Suggests:
4545
testthat,
4646
knitr,
4747
rmarkdown,
4848
taxize (>= 0.8.4),
4949
vcr
50+
Remotes: ropensci/wellknown
5051
RoxygenNote: 7.1.1
5152
X-schema.org-applicationCategory: Biodiversity
5253
X-schema.org-keywords: specimens, API, web-services, occurrences, species, taxonomy, GBIF, INAT, BISON, Vertnet, eBird, Ecoengine, iDigBio, OBIS, ALA

R/handle_sp.R

+3-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
# row.names=row.names(sppoly)))
3434
# handle_sp(sppoly_df)
3535
# handle_sp(sppoly_df, group = FALSE)[[1]]
36-
37-
handle_sp <- function(spobj, group = TRUE) { # nocov start
38-
wicket::sp_convert(spobj, group = group)
39-
} # nocov end
36+
# handle_sp <- function(spobj, group = TRUE) { # nocov start
37+
# wicket::sp_convert(spobj, group = group)
38+
# } # nocov end

R/occ_funs.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ strip_classes <- function(x, z) {
145145
occ_geom <- function(x) {
146146
if (!is.null(x)) {
147147
if (inherits(x, c('SpatialPolygons', 'SpatialPolygonsDataFrame'))) {
148-
x <- as.list(handle_sp(x))
148+
# x <- as.list(handle_sp(x))
149+
stop("'sp' classes no longer supported; convert to sf")
149150
}
150151
if (inherits(x, c('sf', 'sfc', 'sfg', 'POLYGON', 'MULTIPOLYGON'))) {
151152
x <- strip_classes(x, c("XY", "data.frame", "sfc_POLYGON"))

R/plugins.r

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ foo_ecoengine <- function(sources, query, limit, page, geometry, has_coords,
116116
collapse = " "))) {
117117
paste0(wkt2bbox(geometry), collapse = ",")
118118
} else {
119-
geometry
119+
paste0(geometry, collapse = ",")
120120
}
121121
}
122122
if (!is.null(date)) {

R/wkt_bbox.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ bbox2wkt <- function(minx=NA, miny=NA, maxx=NA, maxy=NA, bbox=NULL) {
5555
)
5656
}
5757

58-
#' @param wkt A Well Known Text object.
58+
#' @param wkt A Well Known Text string
5959
#' @export
6060
#' @family bbox
6161
#' @rdname bbox2wkt
62-
wkt2bbox <- function(wkt){
63-
wicket::wkt_bounding(wkt)
62+
wkt2bbox <- function(wkt) {
63+
wellknown::wkt_bounding(wkt)
6464
}

R/wkt_vis.r

+7-4
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ wkt_vis <- function(x, zoom = 6, maptype = "terrain", browse = TRUE) {
3636
stopifnot(!is.null(x))
3737
stopifnot(is.character(x))
3838
x <- gsub("\n|\n\\s+", "", strtrim(x))
39-
out <- wicket::wkt_coords(x)
40-
centroid <- wicket::wkt_centroid(x)
39+
# out <- wicket::wkt_coords(x)
40+
out <- wellknown::wkt_coords(x)
41+
# centroid <- wicket::wkt_centroid(x)
42+
centroid <- wellknown::wkt_centroid(x)
4143
dfs <- unname(lapply(split(out, out$ring), function(z) {
4244
unname(
4345
apply(z, 1, function(x) {
@@ -66,8 +68,9 @@ map_header <- '
6668
<meta charset=utf-8 />
6769
<title>spocc WKT Viewer</title>
6870
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
69-
<script src="https://api.tiles.mapbox.com/mapbox.js/v3.0.1/mapbox.js"></script>
70-
<link href="https://api.tiles.mapbox.com/mapbox.js/v3.0.1/mapbox.css" rel="stylesheet" />
71+
<script src="https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.js"></script>
72+
<link href="https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.css" rel="stylesheet" />
73+
7174
<style>
7275
body { margin:0; padding:0; }
7376
#map { position:absolute; top:0; bottom:0; width:100%; }

man-roxygen/occ_egs.R

+4-33
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
#' occ(query='Accipiter striatus', from='gbif', geometry=c(-125.0,38.4,-121.8,40.9))
114114
#'
115115
#' ## Bounding box constraint with ecoengine
116-
#' ## Use this website: http://boundingbox.klokantech.com/ to quickly grab a bbox.
116+
#' ## Use this website: https://boundingbox.klokantech.com/ to quickly grab a bbox.
117117
#' ## Just set the format on the bottom left to CSV.
118118
#' occ(query='Accipiter striatus', from='ecoengine', limit=10,
119119
#' geometry=c(-125.0,38.4,-121.8,40.9))
@@ -186,32 +186,6 @@
186186
#' (ids <- get_tsn('Accipiter striatus'))
187187
#' occ(ids = ids, from='bison', limit=20)
188188
#'
189-
#' # SpatialPolygons/SpatialPolygonsDataFrame integration
190-
#' library("sp")
191-
#' ## Single polygon in SpatialPolygons class
192-
#' one <- Polygon(cbind(c(91,90,90,91), c(30,30,32,30)))
193-
#' spone = Polygons(list(one), "s1")
194-
#' sppoly = SpatialPolygons(list(spone), as.integer(1))
195-
#' out <- occ(geometry = sppoly, limit=50)
196-
#' out$gbif$data
197-
#'
198-
#' ## Two polygons in SpatialPolygons class
199-
#' one <- Polygon(cbind(c(-121.0,-117.9,-121.0,-121.0), c(39.4, 37.1, 35.1, 39.4)))
200-
#' two <- Polygon(cbind(c(-123.0,-121.2,-122.3,-124.5,-123.5,-124.1,-123.0),
201-
#' c(44.8,42.9,41.9,42.6,43.3,44.3,44.8)))
202-
#' spone = Polygons(list(one), "s1")
203-
#' sptwo = Polygons(list(two), "s2")
204-
#' sppoly = SpatialPolygons(list(spone, sptwo), 1:2)
205-
#' out <- occ(geometry = sppoly, limit=50)
206-
#' out$gbif$data
207-
#'
208-
#' ## Two polygons in SpatialPolygonsDataFrame class
209-
#' sppoly_df <- SpatialPolygonsDataFrame(sppoly,
210-
#' data.frame(a=c(1,2), b=c("a","b"), c=c(TRUE,FALSE),
211-
#' row.names=row.names(sppoly)))
212-
#' out <- occ(geometry = sppoly_df, limit=50)
213-
#' out$gbif$data
214-
#'
215189
#' ## sf classes
216190
#' library("sp")
217191
#' library("sf")
@@ -323,12 +297,9 @@
323297
#' res$obis
324298
#'
325299
#' ## Pass in spatial classes
326-
#' library("sp")
327-
#' one <- Polygon(cbind(c(45,30,30,45), c(35,35,30,30)))
328-
#' spone = Polygons(list(one), "s1")
329-
#' sppoly = SpatialPolygons(list(spone), as.integer(1))
330-
#' (res <- occ(from = 'obis', geometry = sppoly, limit = 50))
331-
#' ## Do paging
300+
#' ## sp classes no longer supported
301+
#'
302+
#' ## Paging
332303
#' (res1 <- occ(query = 'Mola mola', from = 'obis', limit = 10))
333304
#' occ_ids <- res1$obis$data$Mola_mola$id
334305
#' (res2 <- occ(query = 'Mola mola', from = 'obis',

man-roxygen/occtemp.r

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#' @param start,page (integer) Record to start at or page to start at. See `Paging` in
1414
#' Details for how these parameters are used internally. Optional
1515
#' @param geometry (character or nmeric) One of a Well Known Text (WKT) object, a vector of
16-
#' length 4 specifying a bounding box, an sp object (SpatialPolygons or SpatialPolygonsDataFrame),
17-
#' or an sf object (sfg, sfc, or sf). This parameter searches for occurrences inside a
16+
#' length 4 specifying a bounding box, or an sf object (sfg, sfc, or sf). This parameter
17+
#' searches for occurrences inside a
1818
#' polygon - converted to a polygon from whatever user input is given. A WKT shape written as
1919
#' `POLYGON((30.1 10.1, 20 40, 40 40, 30.1 10.1))` would be queried as is,
2020
#' i.e. http://bit.ly/HwUSif. See Details for more examples of WKT objects. The format of a

man/bbox2wkt.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/occ.Rd

+6-35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)