Skip to content

Commit c228b9a

Browse files
authored
Merge pull request #69 from r-spatial/dewey-dev
s2_latlng --> s2_lnglat?
2 parents fc03f2a + 35bb0d4 commit c228b9a

33 files changed

+565
-554
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: s2
22
Title: Spherical Geometry Operators Using the S2 Geometry Library
3-
Version: 1.0.0.9000
3+
Version: 1.0.1
44
Authors@R: c(
55
person(given = "Dewey",
66
family = "Dunnington",

NAMESPACE

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,59 @@
22

33
S3method("[",s2_xptr)
44
S3method("[<-",s2_geography)
5-
S3method("[<-",s2_latlng)
5+
S3method("[<-",s2_lnglat)
66
S3method("[<-",s2_point)
77
S3method("[[",s2_xptr)
88
S3method("[[<-",s2_geography)
9-
S3method("[[<-",s2_latlng)
9+
S3method("[[<-",s2_lnglat)
1010
S3method("[[<-",s2_point)
1111
S3method(as.character,s2_geography)
12-
S3method(as.data.frame,s2_latlng)
12+
S3method(as.data.frame,s2_lnglat)
1313
S3method(as.data.frame,s2_point)
14-
S3method(as.matrix,s2_latlng)
14+
S3method(as.matrix,s2_lnglat)
1515
S3method(as.matrix,s2_point)
1616
S3method(as_s2_geography,WKB)
1717
S3method(as_s2_geography,blob)
1818
S3method(as_s2_geography,character)
1919
S3method(as_s2_geography,default)
2020
S3method(as_s2_geography,logical)
2121
S3method(as_s2_geography,s2_geography)
22-
S3method(as_s2_geography,s2_latlng)
22+
S3method(as_s2_geography,s2_lnglat)
2323
S3method(as_s2_geography,s2_point)
2424
S3method(as_s2_geography,wk_wkb)
2525
S3method(as_s2_geography,wk_wkt)
26-
S3method(as_s2_latlng,character)
27-
S3method(as_s2_latlng,matrix)
28-
S3method(as_s2_latlng,s2_geography)
29-
S3method(as_s2_latlng,s2_latlng)
30-
S3method(as_s2_latlng,s2_point)
31-
S3method(as_s2_latlng,wk_wkb)
32-
S3method(as_s2_latlng,wk_wkt)
26+
S3method(as_s2_lnglat,character)
27+
S3method(as_s2_lnglat,matrix)
28+
S3method(as_s2_lnglat,s2_geography)
29+
S3method(as_s2_lnglat,s2_lnglat)
30+
S3method(as_s2_lnglat,s2_point)
31+
S3method(as_s2_lnglat,wk_wkb)
32+
S3method(as_s2_lnglat,wk_wkt)
3333
S3method(as_s2_point,matrix)
3434
S3method(as_s2_point,s2_geography)
35-
S3method(as_s2_point,s2_latlng)
35+
S3method(as_s2_point,s2_lnglat)
3636
S3method(as_s2_point,s2_point)
3737
S3method(as_wkb,s2_geography)
38-
S3method(as_wkb,s2_latlng)
38+
S3method(as_wkb,s2_lnglat)
3939
S3method(as_wkt,s2_geography)
40-
S3method(as_wkt,s2_latlng)
40+
S3method(as_wkt,s2_lnglat)
4141
S3method(c,s2_xptr)
4242
S3method(format,s2_geography)
43-
S3method(format,s2_latlng)
43+
S3method(format,s2_lnglat)
4444
S3method(format,s2_point)
4545
S3method(print,s2_xptr)
4646
S3method(rep,s2_xptr)
4747
S3method(rep_len,s2_xptr)
4848
export(as_s2_geography)
49-
export(as_s2_latlng)
49+
export(as_s2_lnglat)
5050
export(as_s2_point)
5151
export(s2_area)
5252
export(s2_as_binary)
5353
export(s2_as_text)
5454
export(s2_boundary)
55+
export(s2_bounds_cap)
56+
export(s2_bounds_rect)
5557
export(s2_buffer_cells)
56-
export(s2_cap)
5758
export(s2_centroid)
5859
export(s2_centroid_agg)
5960
export(s2_closest_feature)
@@ -88,9 +89,8 @@ export(s2_intersects_box)
8889
export(s2_intersects_matrix)
8990
export(s2_is_collection)
9091
export(s2_is_empty)
91-
export(s2_lat_lng_rect)
92-
export(s2_latlng)
9392
export(s2_length)
93+
export(s2_lnglat)
9494
export(s2_make_line)
9595
export(s2_make_polygon)
9696
export(s2_max_distance)

NEWS.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
# s2 (development version)
1+
# s2 1.0.1
22

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

R/RcppExports.R

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ cpp_s2_max_distance <- function(geog1, geog2) {
4949
.Call(`_s2_cpp_s2_max_distance`, geog1, geog2)
5050
}
5151

52-
cpp_s2_cap <- function(geog) {
53-
.Call(`_s2_cpp_s2_cap`, geog)
52+
cpp_s2_bounds_cap <- function(geog) {
53+
.Call(`_s2_cpp_s2_bounds_cap`, geog)
5454
}
5555

56-
cpp_s2_lat_lng_rect <- function(geog) {
57-
.Call(`_s2_cpp_s2_lat_lng_rect`, geog)
56+
cpp_s2_bounds_rect <- function(geog) {
57+
.Call(`_s2_cpp_s2_bounds_rect`, geog)
5858
}
5959

6060
cpp_s2_geog_point <- function(x, y) {
@@ -93,16 +93,16 @@ s2_geography_format <- function(s2_geography, maxCoords) {
9393
.Call(`_s2_s2_geography_format`, s2_geography, maxCoords)
9494
}
9595

96-
s2_latlng_from_numeric <- function(lat, lng) {
97-
.Call(`_s2_s2_latlng_from_numeric`, lat, lng)
96+
s2_lnglat_from_numeric <- function(lng, lat) {
97+
.Call(`_s2_s2_lnglat_from_numeric`, lng, lat)
9898
}
9999

100-
s2_latlng_from_s2_point <- function(s2_point) {
101-
.Call(`_s2_s2_latlng_from_s2_point`, s2_point)
100+
s2_lnglat_from_s2_point <- function(s2_point) {
101+
.Call(`_s2_s2_lnglat_from_s2_point`, s2_point)
102102
}
103103

104-
data_frame_from_s2_latlng <- function(xptr) {
105-
.Call(`_s2_data_frame_from_s2_latlng`, xptr)
104+
data_frame_from_s2_lnglat <- function(xptr) {
105+
.Call(`_s2_data_frame_from_s2_lnglat`, xptr)
106106
}
107107

108108
cpp_s2_closest_feature <- function(geog1, geog2) {
@@ -173,8 +173,8 @@ s2_point_from_numeric <- function(x, y, z) {
173173
.Call(`_s2_s2_point_from_numeric`, x, y, z)
174174
}
175175

176-
s2_point_from_s2_latlng <- function(s2_latlng) {
177-
.Call(`_s2_s2_point_from_s2_latlng`, s2_latlng)
176+
s2_point_from_s2_lnglat <- function(s2_lnglat) {
177+
.Call(`_s2_s2_point_from_s2_lnglat`, s2_lnglat)
178178
}
179179

180180
data_frame_from_s2_point <- function(s2_point) {

R/s2-bounds.R

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
#' Compute feature-wise and aggregate bounds
3+
#'
4+
#' [s2_bounds_rect()] returns a bounding latitude-longitude
5+
#' rectangle that contains the region; [s2_bounds_cap()] returns a bounding circle
6+
#' represented by a centre point (lat, lng) and an angle. The bound may not be tight
7+
#' for points, polylines and geometry collections. The rectangle returned may depend on
8+
#' the order of points or polylines. `lng_lo` values larger than `lng_hi` indicate
9+
#' regions that span the antimeridian, see the Fiji example.
10+
#'
11+
#' @inheritParams s2_is_collection
12+
#' @export
13+
#' @return Both functions return a `data.frame`:
14+
#'
15+
#' - [s2_bounds_rect()]: Columns `minlng`, `minlat`, `maxlng`, `maxlat` (degrees)
16+
#' - [s2_bounds_cap()]: Columns `lng`, `lat`, `angle` (degrees)
17+
#'
18+
#' @examples
19+
#' s2_bounds_cap(s2_data_countries("Antarctica"))
20+
#' s2_bounds_cap(s2_data_countries("Netherlands"))
21+
#' s2_bounds_cap(s2_data_countries("Fiji"))
22+
#'
23+
#' s2_bounds_rect(s2_data_countries("Antarctica"))
24+
#' s2_bounds_rect(s2_data_countries("Netherlands"))
25+
#' s2_bounds_rect(s2_data_countries("Fiji"))
26+
#'
27+
s2_bounds_cap <- function(x) {
28+
cpp_s2_bounds_cap(as_s2_geography(x))
29+
}
30+
31+
#' @rdname s2_bounds_cap
32+
#' @export
33+
s2_bounds_rect <- function(x) {
34+
cpp_s2_bounds_rect(as_s2_geography(x))
35+
}

R/s2-cap.R

Lines changed: 0 additions & 31 deletions
This file was deleted.

R/s2-geography.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ as_s2_geography.s2_geography <- function(x, ...) {
5252

5353
#' @rdname as_s2_geography
5454
#' @export
55-
as_s2_geography.s2_latlng <- function(x, ...) {
56-
df <- data_frame_from_s2_latlng(x)
57-
new_s2_xptr(cpp_s2_geog_point(df[[2]], df[[1]]), "s2_geography")
55+
as_s2_geography.s2_lnglat <- function(x, ...) {
56+
df <- data_frame_from_s2_lnglat(x)
57+
new_s2_xptr(cpp_s2_geog_point(df[[1]], df[[2]]), "s2_geography")
5858
}
5959

6060
#' @rdname as_s2_geography
6161
#' @export
6262
as_s2_geography.s2_point <- function(x, ...) {
63-
as_s2_geography(as_s2_latlng(x))
63+
as_s2_geography(as_s2_lnglat(x))
6464
}
6565

6666
#' @rdname as_s2_geography

R/s2-latlng.R

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)