Skip to content

Commit

Permalink
Merge pull request #69 from r-spatial/dewey-dev
Browse files Browse the repository at this point in the history
s2_latlng --> s2_lnglat?
  • Loading branch information
paleolimbot authored Jul 9, 2020
2 parents fc03f2a + 35bb0d4 commit c228b9a
Show file tree
Hide file tree
Showing 33 changed files with 565 additions and 554 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: s2
Title: Spherical Geometry Operators Using the S2 Geometry Library
Version: 1.0.0.9000
Version: 1.0.1
Authors@R: c(
person(given = "Dewey",
family = "Dunnington",
Expand Down
40 changes: 20 additions & 20 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,59 @@

S3method("[",s2_xptr)
S3method("[<-",s2_geography)
S3method("[<-",s2_latlng)
S3method("[<-",s2_lnglat)
S3method("[<-",s2_point)
S3method("[[",s2_xptr)
S3method("[[<-",s2_geography)
S3method("[[<-",s2_latlng)
S3method("[[<-",s2_lnglat)
S3method("[[<-",s2_point)
S3method(as.character,s2_geography)
S3method(as.data.frame,s2_latlng)
S3method(as.data.frame,s2_lnglat)
S3method(as.data.frame,s2_point)
S3method(as.matrix,s2_latlng)
S3method(as.matrix,s2_lnglat)
S3method(as.matrix,s2_point)
S3method(as_s2_geography,WKB)
S3method(as_s2_geography,blob)
S3method(as_s2_geography,character)
S3method(as_s2_geography,default)
S3method(as_s2_geography,logical)
S3method(as_s2_geography,s2_geography)
S3method(as_s2_geography,s2_latlng)
S3method(as_s2_geography,s2_lnglat)
S3method(as_s2_geography,s2_point)
S3method(as_s2_geography,wk_wkb)
S3method(as_s2_geography,wk_wkt)
S3method(as_s2_latlng,character)
S3method(as_s2_latlng,matrix)
S3method(as_s2_latlng,s2_geography)
S3method(as_s2_latlng,s2_latlng)
S3method(as_s2_latlng,s2_point)
S3method(as_s2_latlng,wk_wkb)
S3method(as_s2_latlng,wk_wkt)
S3method(as_s2_lnglat,character)
S3method(as_s2_lnglat,matrix)
S3method(as_s2_lnglat,s2_geography)
S3method(as_s2_lnglat,s2_lnglat)
S3method(as_s2_lnglat,s2_point)
S3method(as_s2_lnglat,wk_wkb)
S3method(as_s2_lnglat,wk_wkt)
S3method(as_s2_point,matrix)
S3method(as_s2_point,s2_geography)
S3method(as_s2_point,s2_latlng)
S3method(as_s2_point,s2_lnglat)
S3method(as_s2_point,s2_point)
S3method(as_wkb,s2_geography)
S3method(as_wkb,s2_latlng)
S3method(as_wkb,s2_lnglat)
S3method(as_wkt,s2_geography)
S3method(as_wkt,s2_latlng)
S3method(as_wkt,s2_lnglat)
S3method(c,s2_xptr)
S3method(format,s2_geography)
S3method(format,s2_latlng)
S3method(format,s2_lnglat)
S3method(format,s2_point)
S3method(print,s2_xptr)
S3method(rep,s2_xptr)
S3method(rep_len,s2_xptr)
export(as_s2_geography)
export(as_s2_latlng)
export(as_s2_lnglat)
export(as_s2_point)
export(s2_area)
export(s2_as_binary)
export(s2_as_text)
export(s2_boundary)
export(s2_bounds_cap)
export(s2_bounds_rect)
export(s2_buffer_cells)
export(s2_cap)
export(s2_centroid)
export(s2_centroid_agg)
export(s2_closest_feature)
Expand Down Expand Up @@ -88,9 +89,8 @@ export(s2_intersects_box)
export(s2_intersects_matrix)
export(s2_is_collection)
export(s2_is_empty)
export(s2_lat_lng_rect)
export(s2_latlng)
export(s2_length)
export(s2_lnglat)
export(s2_make_line)
export(s2_make_polygon)
export(s2_max_distance)
Expand Down
12 changes: 11 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# s2 (development version)
# s2 1.0.1

* Added layer creation options to `s2_options()`, which now uses strings
rather than numeric codes to specify boolean operation options, geography
construction options, and builder options (#70).
* Added `s2_rebuild()` and `s2_simplify()`, which wrap the S2 C++ `S2Builder`
class to provide simplification and fixing of invalid geographies (#70).
* The s2 package now builds and passes the CMD check on Solaris (#66, #67).
* Renamed `s2_latlng()` to `s2_lnglat()` to keep axis order consistent
throughout the package (#69).
* Added `s2_bounds_cap()` and `s2_bounds_rect()` to compute bounding areas
using geographic coordinates (@edzer, #63).
* `s2_*_matrix()` predicates now efficiently use indexing to compute the
results of many predicate comparisons (#61).

Expand Down
24 changes: 12 additions & 12 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ cpp_s2_max_distance <- function(geog1, geog2) {
.Call(`_s2_cpp_s2_max_distance`, geog1, geog2)
}

cpp_s2_cap <- function(geog) {
.Call(`_s2_cpp_s2_cap`, geog)
cpp_s2_bounds_cap <- function(geog) {
.Call(`_s2_cpp_s2_bounds_cap`, geog)
}

cpp_s2_lat_lng_rect <- function(geog) {
.Call(`_s2_cpp_s2_lat_lng_rect`, geog)
cpp_s2_bounds_rect <- function(geog) {
.Call(`_s2_cpp_s2_bounds_rect`, geog)
}

cpp_s2_geog_point <- function(x, y) {
Expand Down Expand Up @@ -93,16 +93,16 @@ s2_geography_format <- function(s2_geography, maxCoords) {
.Call(`_s2_s2_geography_format`, s2_geography, maxCoords)
}

s2_latlng_from_numeric <- function(lat, lng) {
.Call(`_s2_s2_latlng_from_numeric`, lat, lng)
s2_lnglat_from_numeric <- function(lng, lat) {
.Call(`_s2_s2_lnglat_from_numeric`, lng, lat)
}

s2_latlng_from_s2_point <- function(s2_point) {
.Call(`_s2_s2_latlng_from_s2_point`, s2_point)
s2_lnglat_from_s2_point <- function(s2_point) {
.Call(`_s2_s2_lnglat_from_s2_point`, s2_point)
}

data_frame_from_s2_latlng <- function(xptr) {
.Call(`_s2_data_frame_from_s2_latlng`, xptr)
data_frame_from_s2_lnglat <- function(xptr) {
.Call(`_s2_data_frame_from_s2_lnglat`, xptr)
}

cpp_s2_closest_feature <- function(geog1, geog2) {
Expand Down Expand Up @@ -173,8 +173,8 @@ s2_point_from_numeric <- function(x, y, z) {
.Call(`_s2_s2_point_from_numeric`, x, y, z)
}

s2_point_from_s2_latlng <- function(s2_latlng) {
.Call(`_s2_s2_point_from_s2_latlng`, s2_latlng)
s2_point_from_s2_lnglat <- function(s2_lnglat) {
.Call(`_s2_s2_point_from_s2_lnglat`, s2_lnglat)
}

data_frame_from_s2_point <- function(s2_point) {
Expand Down
35 changes: 35 additions & 0 deletions R/s2-bounds.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

#' Compute feature-wise and aggregate bounds
#'
#' [s2_bounds_rect()] returns a bounding latitude-longitude
#' rectangle that contains the region; [s2_bounds_cap()] returns a bounding circle
#' represented by a centre point (lat, lng) and an angle. The bound may not be tight
#' for points, polylines and geometry collections. The rectangle returned may depend on
#' the order of points or polylines. `lng_lo` values larger than `lng_hi` indicate
#' regions that span the antimeridian, see the Fiji example.
#'
#' @inheritParams s2_is_collection
#' @export
#' @return Both functions return a `data.frame`:
#'
#' - [s2_bounds_rect()]: Columns `minlng`, `minlat`, `maxlng`, `maxlat` (degrees)
#' - [s2_bounds_cap()]: Columns `lng`, `lat`, `angle` (degrees)
#'
#' @examples
#' s2_bounds_cap(s2_data_countries("Antarctica"))
#' s2_bounds_cap(s2_data_countries("Netherlands"))
#' s2_bounds_cap(s2_data_countries("Fiji"))
#'
#' s2_bounds_rect(s2_data_countries("Antarctica"))
#' s2_bounds_rect(s2_data_countries("Netherlands"))
#' s2_bounds_rect(s2_data_countries("Fiji"))
#'
s2_bounds_cap <- function(x) {
cpp_s2_bounds_cap(as_s2_geography(x))
}

#' @rdname s2_bounds_cap
#' @export
s2_bounds_rect <- function(x) {
cpp_s2_bounds_rect(as_s2_geography(x))
}
31 changes: 0 additions & 31 deletions R/s2-cap.R

This file was deleted.

8 changes: 4 additions & 4 deletions R/s2-geography.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ as_s2_geography.s2_geography <- function(x, ...) {

#' @rdname as_s2_geography
#' @export
as_s2_geography.s2_latlng <- function(x, ...) {
df <- data_frame_from_s2_latlng(x)
new_s2_xptr(cpp_s2_geog_point(df[[2]], df[[1]]), "s2_geography")
as_s2_geography.s2_lnglat <- function(x, ...) {
df <- data_frame_from_s2_lnglat(x)
new_s2_xptr(cpp_s2_geog_point(df[[1]], df[[2]]), "s2_geography")
}

#' @rdname as_s2_geography
#' @export
as_s2_geography.s2_point <- function(x, ...) {
as_s2_geography(as_s2_latlng(x))
as_s2_geography(as_s2_lnglat(x))
}

#' @rdname as_s2_geography
Expand Down
111 changes: 0 additions & 111 deletions R/s2-latlng.R

This file was deleted.

Loading

0 comments on commit c228b9a

Please sign in to comment.