Skip to content

Commit 8b1f67c

Browse files
author
SymbolixAU
committed
cran readY'
1 parent 33248f6 commit 8b1f67c

File tree

4 files changed

+110
-148
lines changed

4 files changed

+110
-148
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: googleway
22
Type: Package
33
Title: Accesses Google Maps APIs to Retrieve Data and Plot Maps
4-
Version: 2.6.1004
5-
Date: 2018-04-29
4+
Version: 2.7.0
5+
Date: 2018-05-25
66
Authors@R: c(
77
person("David", "Cooley", ,"dcooley@symbolix.com.au", role = c("aut", "cre")),
88
person("Paulo", "Barcelos", role = "ctb", comment = "Author of c++ decode_pl"),

README.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,14 @@ Provides a mechanism to access various [Google Maps APIs](https://developers.goo
1212

1313
![Google Maps](./vignettes/img/polygon_legend.png)
1414

15-
## v2.6
15+
## v2.7
1616

1717
see [News](https://github.com/SymbolixAU/googleway/blob/master/NEWS.md) for a full list of changes and additions
1818

19-
For specific examples, see the blog posts for
20-
21-
* [sf objects](https://www.symbolix.com.au/blog-main/2018)
22-
* [Colours](https://www.symbolix.com.au/blog-main/sgh8lg7gwfe7kw98df7jh6897dmbge)
23-
* [Legends](https://www.symbolix.com.au/blog-main/rg72j9l8tm85dpz7278ms76ys48gp6)
24-
* [Result Accessors](https://www.symbolix.com.au/blog-main/fhcs36y9h8zftenfhwpsredbeyf3zf)
25-
* [Drag & Drop GeoJSON](https://www.symbolix.com.au/blog-main/b9z2z337hzzfc4hws8gf8lk358473z)
26-
* [API Keys](https://www.symbolix.com.au/blog-main/2018-1)
27-
* [Load Interval](https://www.symbolix.com.au/blog-main/5376khrw92a7cwz7ah4cewbaltjtsn)
28-
2919

3020
See the [**vignette**](https://github.com/SymbolixAU/googleway/blob/master/vignettes/googleway-vignette.Rmd) for instructions and examples.
3121

32-
## v2.7.0 (development)
22+
## v2.7.0001+ (dev)
3323

3424

3525

cran-comments.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
## Release summary
33

4-
* Updates v2.4.0 to v2.6.0
5-
# Removed all source / C++ code
4+
* Updates v2.6.0 to v2.7.0
5+
* Removed dependencies on undeclared packages from unit tests, as per CRAN request - email "CRAN packages maintained by you" from Kurt Hornik, 2018-05-18
66

77

88
## Test Environments
99

10-
* local OS X 15.6.0 (High Sierra) install, R 3.4.4
11-
* ubuntu 12.04.5 (on travis-ci), R 3.3.0
10+
* local OS X 15.6.0 (High Sierra) install, R 3.5.0
11+
* travis-ci (ubuntu 14.04.5, R Under development r74781)
1212
* win-builder (devel and release)
1313

1414

Lines changed: 102 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,102 @@
1-
# context("sf")
2-
#
3-
#
4-
# test_that("sf objects encoded", {
5-
#
6-
# df <- data.frame(
7-
# myId = c(1,1,1,1,1,1,1,1,2,2,2,2)
8-
# , lineId = c(1,1,1,1,2,2,2,2,1,1,1,2)
9-
# , lon = c(-80.190, -66.118, -64.757, -80.190, -70.579, -67.514, -66.668, -70.579, -70, -49, -51, -70)
10-
# , lat = c(26.774, 18.466, 32.321, 26.774, 28.745, 29.570, 27.339, 28.745, 22, 23, 22, 22)
11-
# )
12-
#
13-
# p1 <- as.matrix(df[4:1, c("lon", "lat")])
14-
# p2 <- as.matrix(df[8:5, c("lon", "lat")])
15-
# p3 <- as.matrix(df[9:12, c("lon", "lat")])
16-
#
17-
# sfAttrs <- function(sf, geom) {
18-
# attr(sf, "class") <- c("XY", geom, "sfg")
19-
# sf <- list(sf)
20-
# attr(sf, "class") <- c("sfc_POINT", "sfc")
21-
# attr(sf, "precision") <- 0
22-
# bbox <- c(xmin = 0, ymin = 0, xmax = 0, ymax = 0)
23-
# attr(sf, "bbox") <- bbox
24-
# attr(sf, "precision") <- 0
25-
# attr(sf, "n_empty") <- 0
26-
# return(sf)
27-
# }
28-
#
29-
# constructSf <- function(sf) {
30-
# sf <- data.frame(geometry = sf)
31-
# attr(sf, "class") <- c("sf", "data.frame")
32-
# attr(sf, "sf_column") <- "geometry"
33-
# attr(sf, "agr") <- factor()
34-
# return(sf)
35-
# }
36-
#
37-
# pt <- matrix(c(df[1, "lon"], df[1, "lat"]), nrow = 1)
38-
# mp <- as.matrix(df[1:2, c("lon", "lat")])
39-
# ln <- p3
40-
#
41-
# dfpt <- data.frame(geometry = as.list(pt))
42-
# attr(dfpt, "class") <- c("sf", "data.frame")
43-
#
44-
# data.frame(list(mp))
45-
# data.frame(list(ln))
46-
# data.frame(geometry = list(mp, ln))
47-
#
48-
# pt <- sfAttrs(pt, "POINT")
49-
# pt <- constructSf(pt)
50-
#
51-
# mp <- sfAttrs(mp, "MULTIPOINT")
52-
# #mp <- constructSf(mp)
53-
# ln <- sfAttrs(ln, "LINESTRING")
54-
# #ln <- constructSf(ln)
55-
# ml <- list(p1, p2)
56-
# ml <- sfAttrs(ml, "MULTILINESTRING")
57-
# #ml <- constructSf(ml)
58-
# po <- list(p1, p2)
59-
# po <- sfAttrs(po, "POLYGON")
60-
# #po <- constructSf(po)
61-
# mpl <- list( list(p1, p2), list(p3) )
62-
# mpl <- sfAttrs(mpl, "MULTIPOLYGON")
63-
# #mpl <- constructSf(mpl)
64-
#
65-
# rbind(pt, mp)
66-
#
67-
# #
68-
# sf <- rbind(
69-
# sf::st_sf(geometry = point),
70-
# sf::st_sf(geometry = multipolygon),
71-
# sf::st_sf(geometry = multilinestring),
72-
# sf::st_sf(geometry = linestring),
73-
# sf::st_sf(geometry = point),
74-
# sf::st_sf(geometry = multipoint)
75-
# )
76-
#
77-
# expect_true(inherits(googleway:::normalise_sf(sf), "sfencoded"))
78-
#
79-
# enc <- googlePolylines::encode(sf)
80-
# expect_true(googleway:::findEncodedColumn(enc, NULL) == "geometry")
81-
# expect_true(googleway:::findEncodedColumn(enc, "geometry") == "geometry")
82-
#
83-
# df <- data.frame(polyline = "abc")
84-
# expect_true(googleway:::findEncodedColumn(df, 'polyline') == "polyline")
85-
#
86-
# })
87-
#
88-
# test_that("correct sf rows are returned", {
89-
#
90-
# df <- data.frame(myId = c(1,1,1,1,1,1,1,1,2,2,2,2),
91-
# lineId = c(1,1,1,1,2,2,2,2,1,1,1,2),
92-
# lon = c(-80.190, -66.118, -64.757, -80.190, -70.579, -67.514, -66.668, -70.579, -70, -49, -51, -70),
93-
# lat = c(26.774, 18.466, 32.321, 26.774, 28.745, 29.570, 27.339, 28.745, 22, 23, 22, 22))
94-
#
95-
# p1 <- as.matrix(df[4:1, c("lon", "lat")])
96-
# p2 <- as.matrix(df[8:5, c("lon", "lat")])
97-
# p3 <- as.matrix(df[9:12, c("lon", "lat")])
98-
#
99-
# point <- sf::st_sfc(sf::st_point(x = c(df[1,"lon"], df[1,"lat"])))
100-
# multipoint <- sf::st_sfc(sf::st_multipoint(x = as.matrix(df[1:2, c("lon", "lat")])))
101-
# polygon <- sf::st_sfc(sf::st_polygon(x = list(p1, p2)))
102-
# linestring <- sf::st_sfc(sf::st_linestring(p3))
103-
# multilinestring <- sf::st_sfc(sf::st_multilinestring(list(p1, p2)))
104-
# multipolygon <- sf::st_sfc(sf::st_multipolygon(x = list(list(p1, p2), list(p3))))
105-
#
106-
# sf <- rbind(
107-
# sf::st_sf(geometry = polygon),
108-
# sf::st_sf(geometry = multipolygon),
109-
# sf::st_sf(geometry = multilinestring),
110-
# sf::st_sf(geometry = linestring),
111-
# sf::st_sf(geometry = point),
112-
# sf::st_sf(geometry = multipoint)
113-
# )
114-
#
115-
# expect_true(nrow(googleway:::normaliseSfData(sf, "POLYGON")) == 2)
116-
# expect_true(nrow(googleway:::normaliseSfData(sf, "LINE")) == 2)
117-
# expect_true(nrow(googleway:::normaliseSfData(sf, "POINT")) == 2)
118-
#
119-
# enc <- googlePolylines::encode(sf)
120-
#
121-
# expect_identical(enc, googleway:::normalise_sf(sf))
122-
# expect_identical(enc, googleway:::normalise_sf(enc))
123-
# expect_error(googleway:::normalise_sf(""), "Expecting an sf or sfencoded object to add_sf")
124-
#
125-
# expect_true(nrow(googleway:::normaliseSfData(enc, "POLYGON")) == 2)
126-
# expect_true(nrow(googleway:::normaliseSfData(enc, "LINE")) == 2)
127-
# expect_true(nrow(googleway:::normaliseSfData(enc, "POINT")) == 2)
128-
#
129-
# })
130-
#
1+
context("sf")
2+
3+
4+
test_that("sf objects encoded", {
5+
6+
sf <- structure(list(geometry = structure(list(structure(list(structure(c(-80.19,
7+
-64.757, -66.118, -80.19, 26.774, 32.321, 18.466, 26.774), .Dim = c(4L,
8+
2L), .Dimnames = list(c("4", "3", "2", "1"), c("lon", "lat"))),
9+
structure(c(-70.579, -66.668, -67.514, -70.579, 28.745, 27.339,
10+
29.57, 28.745), .Dim = c(4L, 2L), .Dimnames = list(c("8",
11+
"7", "6", "5"), c("lon", "lat")))), class = c("XY", "POLYGON",
12+
"sfg")), structure(list(list(structure(c(-80.19, -64.757, -66.118,
13+
-80.19, 26.774, 32.321, 18.466, 26.774), .Dim = c(4L, 2L), .Dimnames = list(
14+
c("4", "3", "2", "1"), c("lon", "lat"))), structure(c(-70.579,
15+
-66.668, -67.514, -70.579, 28.745, 27.339, 29.57, 28.745), .Dim = c(4L,
16+
2L), .Dimnames = list(c("8", "7", "6", "5"), c("lon", "lat")))),
17+
list(structure(c(-70, -49, -51, -70, 22, 23, 22, 22), .Dim = c(4L,
18+
2L), .Dimnames = list(c("9", "10", "11", "12"), c("lon",
19+
"lat"))))), class = c("XY", "MULTIPOLYGON", "sfg")), structure(list(
20+
structure(c(-80.19, -64.757, -66.118, -80.19, 26.774, 32.321,
21+
18.466, 26.774), .Dim = c(4L, 2L), .Dimnames = list(c("4",
22+
"3", "2", "1"), c("lon", "lat"))), structure(c(-70.579, -66.668,
23+
-67.514, -70.579, 28.745, 27.339, 29.57, 28.745), .Dim = c(4L,
24+
2L), .Dimnames = list(c("8", "7", "6", "5"), c("lon", "lat"
25+
)))), class = c("XY", "MULTILINESTRING", "sfg")), structure(c(-70,
26+
-49, -51, -70, 22, 23, 22, 22), .Dim = c(4L, 2L), .Dimnames = list(
27+
c("9", "10", "11", "12"), c("lon", "lat")), class = c("XY",
28+
"LINESTRING", "sfg")), structure(c(-80.19, 26.774), class = c("XY",
29+
"POINT", "sfg")), structure(c(-80.19, -66.118, 26.774, 18.466
30+
), .Dim = c(2L, 2L), .Dimnames = list(c("1", "2"), c("lon", "lat"
31+
)), class = c("XY", "MULTIPOINT", "sfg"))), class = c("sfc_GEOMETRY",
32+
"sfc"), precision = 0, bbox = structure(c(xmin = -80.19, ymin = 18.466,
33+
xmax = -49, ymax = 32.321), class = "bbox"), crs = structure(list(
34+
epsg = NA_integer_, proj4string = NA_character_), class = "crs"), n_empty = 0L, classes = c("POLYGON",
35+
"MULTIPOLYGON", "MULTILINESTRING", "LINESTRING", "POINT", "MULTIPOINT"
36+
))), row.names = c(NA, 6L), sf_column = "geometry", agr = structure(integer(0), class = "factor", .Label = c("constant",
37+
"aggregate", "identity"), .Names = character(0)), class = c("sf",
38+
"data.frame"))
39+
40+
expect_true(inherits(googleway:::normalise_sf(sf), "sfencoded"))
41+
42+
enc <- googlePolylines::encode(sf)
43+
expect_true(googleway:::findEncodedColumn(enc, NULL) == "geometry")
44+
expect_true(googleway:::findEncodedColumn(enc, "geometry") == "geometry")
45+
46+
df <- data.frame(polyline = "abc")
47+
expect_true(googleway:::findEncodedColumn(df, 'polyline') == "polyline")
48+
49+
})
50+
51+
test_that("correct sf rows are returned", {
52+
53+
sf <- structure(list(geometry = structure(list(structure(list(structure(c(-80.19,
54+
-64.757, -66.118, -80.19, 26.774, 32.321, 18.466, 26.774), .Dim = c(4L,
55+
2L), .Dimnames = list(c("4", "3", "2", "1"), c("lon", "lat"))),
56+
structure(c(-70.579, -66.668, -67.514, -70.579, 28.745, 27.339,
57+
29.57, 28.745), .Dim = c(4L, 2L), .Dimnames = list(c("8",
58+
"7", "6", "5"), c("lon", "lat")))), class = c("XY", "POLYGON",
59+
"sfg")), structure(list(list(structure(c(-80.19, -64.757, -66.118,
60+
-80.19, 26.774, 32.321, 18.466, 26.774), .Dim = c(4L, 2L), .Dimnames = list(
61+
c("4", "3", "2", "1"), c("lon", "lat"))), structure(c(-70.579,
62+
-66.668, -67.514, -70.579, 28.745, 27.339, 29.57, 28.745), .Dim = c(4L,
63+
2L), .Dimnames = list(c("8", "7", "6", "5"), c("lon", "lat")))),
64+
list(structure(c(-70, -49, -51, -70, 22, 23, 22, 22), .Dim = c(4L,
65+
2L), .Dimnames = list(c("9", "10", "11", "12"), c("lon",
66+
"lat"))))), class = c("XY", "MULTIPOLYGON", "sfg")), structure(list(
67+
structure(c(-80.19, -64.757, -66.118, -80.19, 26.774, 32.321,
68+
18.466, 26.774), .Dim = c(4L, 2L), .Dimnames = list(c("4",
69+
"3", "2", "1"), c("lon", "lat"))), structure(c(-70.579, -66.668,
70+
-67.514, -70.579, 28.745, 27.339, 29.57, 28.745), .Dim = c(4L,
71+
2L), .Dimnames = list(c("8", "7", "6", "5"), c("lon", "lat"
72+
)))), class = c("XY", "MULTILINESTRING", "sfg")), structure(c(-70,
73+
-49, -51, -70, 22, 23, 22, 22), .Dim = c(4L, 2L), .Dimnames = list(
74+
c("9", "10", "11", "12"), c("lon", "lat")), class = c("XY",
75+
"LINESTRING", "sfg")), structure(c(-80.19, 26.774), class = c("XY",
76+
"POINT", "sfg")), structure(c(-80.19, -66.118, 26.774, 18.466
77+
), .Dim = c(2L, 2L), .Dimnames = list(c("1", "2"), c("lon", "lat"
78+
)), class = c("XY", "MULTIPOINT", "sfg"))), class = c("sfc_GEOMETRY",
79+
"sfc"), precision = 0, bbox = structure(c(xmin = -80.19, ymin = 18.466,
80+
xmax = -49, ymax = 32.321), class = "bbox"), crs = structure(list(
81+
epsg = NA_integer_, proj4string = NA_character_), class = "crs"), n_empty = 0L, classes = c("POLYGON",
82+
"MULTIPOLYGON", "MULTILINESTRING", "LINESTRING", "POINT", "MULTIPOINT"
83+
))), row.names = c(NA, 6L), sf_column = "geometry", agr = structure(integer(0), class = "factor", .Label = c("constant",
84+
"aggregate", "identity"), .Names = character(0)), class = c("sf",
85+
"data.frame"))
86+
87+
expect_true(nrow(googleway:::normaliseSfData(sf, "POLYGON")) == 2)
88+
expect_true(nrow(googleway:::normaliseSfData(sf, "LINE")) == 2)
89+
expect_true(nrow(googleway:::normaliseSfData(sf, "POINT")) == 2)
90+
91+
enc <- googlePolylines::encode(sf)
92+
93+
expect_identical(enc, googleway:::normalise_sf(sf))
94+
expect_identical(enc, googleway:::normalise_sf(enc))
95+
expect_error(googleway:::normalise_sf(""), "Expecting an sf or sfencoded object to add_sf")
96+
97+
expect_true(nrow(googleway:::normaliseSfData(enc, "POLYGON")) == 2)
98+
expect_true(nrow(googleway:::normaliseSfData(enc, "LINE")) == 2)
99+
expect_true(nrow(googleway:::normaliseSfData(enc, "POINT")) == 2)
100+
101+
})
102+

0 commit comments

Comments
 (0)