@@ -32,28 +32,37 @@ doResolveFormula <- function(data, f) {
32
32
UseMethod(" doResolveFormula" )
33
33
}
34
34
35
+ # ' @export
35
36
doResolveFormula.data.frame <- function (data , f ) {
36
37
eval(f [[2 ]], data , environment(f ))
37
38
}
38
39
40
+ # ' @export
39
41
doResolveFormula.SharedData <- function (data , f ) {
40
42
doResolveFormula(data $ data(withSelection = TRUE , withFilter = FALSE , withKey = TRUE ), f )
41
43
}
42
44
45
+ # ' @export
43
46
doResolveFormula.map <- function (data , f ) {
44
47
eval(f [[2 ]], data , environment(f ))
45
48
}
46
49
50
+ # ' @export
47
51
doResolveFormula.list <- function (data , f ) {
48
52
eval(f [[2 ]], data , environment(f ))
49
53
}
50
54
51
- doResolveFormula.SpatialLinesDataFrame <-
52
- doResolveFormula.SpatialPolygonsDataFrame <-
55
+ # ' @export
53
56
doResolveFormula.SpatialPointsDataFrame <- function (data , f ) {
54
57
doResolveFormula(data @ data , f )
55
58
}
56
59
60
+ # ' @export
61
+ doResolveFormula.SpatialLinesDataFrame <- doResolveFormula.SpatialPointsDataFrame
62
+
63
+ # ' @export
64
+ doResolveFormula.SpatialPolygonsDataFrame <- doResolveFormula.SpatialPointsDataFrame
65
+
57
66
# ' Given a data object and lng/lat arguments (which may be NULL [meaning infer
58
67
# ' from data], formula [which should be evaluated with respect to the data], or
59
68
# ' vector data [which should be used as-is]) return a lng/lat data frame.
@@ -172,30 +181,36 @@ polygonData <- function(obj) {
172
181
UseMethod(" polygonData" )
173
182
}
174
183
184
+ # ' @export
175
185
polygonData.default <- function (obj ) {
176
186
stop(" Don't know how to get path data from object of class " , class(obj )[[1 ]])
177
187
}
188
+ # ' @export
178
189
polygonData.matrix <- function (obj ) {
179
190
makePolyList(pointData.matrix(obj ))
180
191
}
192
+ # ' @export
181
193
polygonData.Polygon <- function (obj ) {
182
194
coords = polygon2coords(obj )
183
195
structure(
184
196
list (list (coords )),
185
197
bbox = attr(coords , " bbox" , exact = TRUE )
186
198
)
187
199
}
200
+ # ' @export
188
201
polygonData.Polygons <- function (obj ) {
189
202
coords = polygons2coords(obj )
190
203
structure(
191
204
list (structure(coords , bbox = NULL )),
192
205
bbox = attr(coords , " bbox" , exact = TRUE )
193
206
)
194
207
}
208
+ # ' @export
195
209
polygonData.SpatialPolygons <- function (obj ) {
196
210
lapply(obj @ polygons , polygons2coords , bbox = FALSE ) %> %
197
211
structure(bbox = obj @ bbox )
198
212
}
213
+ # ' @export
199
214
polygonData.SpatialPolygonsDataFrame <- function (obj ) {
200
215
# polygonData(sp::polygons(obj))
201
216
if (length(obj @ polygons )> 0 ) {
@@ -205,28 +220,33 @@ polygonData.SpatialPolygonsDataFrame <- function(obj) {
205
220
structure(list (), bbox = obj @ bbox )
206
221
}
207
222
}
223
+ # ' @export
208
224
polygonData.map <- function (obj ) {
209
225
polygonData(cbind(obj $ x , obj $ y ))
210
226
}
211
227
228
+ # ' @export
212
229
polygonData.Line <- function (obj ) {
213
230
coords = line2coords(obj )
214
231
structure(
215
232
list (list (coords )),
216
233
bbox = attr(coords , " bbox" , exact = TRUE )
217
234
)
218
235
}
236
+ # ' @export
219
237
polygonData.Lines <- function (obj ) {
220
238
coords = lines2coords(obj )
221
239
structure(
222
240
list (structure(coords , bbox = NULL )),
223
241
bbox = attr(coords , " bbox" , exact = TRUE )
224
242
)
225
243
}
244
+ # ' @export
226
245
polygonData.SpatialLines <- function (obj ) {
227
246
lapply(obj @ lines , lines2coords , bbox = FALSE ) %> %
228
247
structure(bbox = obj @ bbox )
229
248
}
249
+ # ' @export
230
250
polygonData.SpatialLinesDataFrame <- function (obj ) {
231
251
if (length(obj @ lines )> 0 ) {
232
252
polygonData(sp :: SpatialLines(obj @ lines ))
0 commit comments