jmsigner / amt

37 stars 13 forks source link

fix make_track marked as deprecated #65

Closed robitalec closed 2 years ago

robitalec commented 2 years ago

make_track is marked as deprecated because of the .Deprecated function without sufficient arguments.

Here's the chunk: https://github.com/jmsigner/amt/blob/master/R/track.R#L103-L104=

Running this locally, we see that .Deprecated picks up a default "old" function name from the parent calling environment

old = as.character(sys.call(sys.parent()))[1L]

.Deprecated("It looks like you used `CRS()` to create the crs,
                  please use the ESPG directly.")
#> Warning: '.Deprecated' is deprecated.
#> Use 'It looks like you used `CRS()` to create the crs,
#>                   please use the ESPG directly.' instead.
#> See help("Deprecated")

So in the case of within make_track, without the old argument set, it marks make_track as deprecated.

make_track <- function() {
    .Deprecated("It looks like you used `CRS()` to create the crs,
                  please use the ESPG directly.")
}

make_track()
#> Warning: 'make_track' is deprecated.
#> Use 'It looks like you used `CRS()` to create the crs,
#>                   please use the ESPG directly.' instead.
#> See help("Deprecated")

Some alternatives, probably I would think the simple warning is most straightforward:


.Deprecated(
    "It looks like you used `CRS()` to create the crs, please use the ESPG directly.",
    old = 'CRS',
    new = 'EPSG code'
)
#> Warning: 'CRS' is deprecated.
#> Use 'EPSG code' instead.
#> See help("Deprecated") and help("It looks like you used `CRS()` to create the crs, please use the ESPG directly.-deprecated").

warning("It looks like you used `CRS()` to create the crs, please use the ESPG directly.")
#> Warning: It looks like you used `CRS()` to create the crs, please use the ESPG
#> directly.

Maybe with some link in the function's docs to the r spatial posts on the deprecation of CRS.

Thanks!

jmsigner commented 2 years ago

Great catch, thanks for putting this in a pull request. I will add you as a contributor.

robitalec commented 2 years ago

No problem, thanks!