-
Notifications
You must be signed in to change notification settings - Fork 3
Phase 1: Quick Fixes and Improvements #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # https://epsg.io/4326 | ||
| wgs = function() sp::CRS('+proj=longlat +datum=WGS84', doCheckCRSArgs = FALSE) | ||
| wgs = function() sp::CRS('EPSG:4326') | ||
|
|
||
| # nocov start | ||
| check_suggested = function(pkg) { | ||
|
|
@@ -12,10 +12,10 @@ check_suggested = function(pkg) { | |
| gh_to_sp = function(geohashes) { | ||
| check_suggested('sp') | ||
| gh = tolower(geohashes) | ||
| if (anyDuplicated(gh) > 0L) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i actually would revert this -- it's optimizing the right way IMO
ditto elsewhere. Maybe this should be a helper |
||
| idx = which(duplicated(gh)) | ||
| warning('Detected ', length(idx), ' duplicate input geohashes; removing') | ||
| gh = gh[-idx] | ||
| dup_idx = duplicated(gh) | ||
| if (any(dup_idx)) { | ||
| warning('Detected ', sum(dup_idx), ' duplicate input geohashes; removing') | ||
| gh = gh[!dup_idx] | ||
| } | ||
| gh_xy = gh_decode(gh, include_delta = TRUE) | ||
| sp::SpatialPolygons(lapply(seq_along(gh), function(ii) { | ||
|
|
@@ -34,10 +34,10 @@ gh_to_spdf = function(...) { | |
| } | ||
|
|
||
| gh_to_spdf.default = function(geohashes, ...) { | ||
| if (anyDuplicated(geohashes) > 0L) { | ||
| idx = which(duplicated(geohashes)) | ||
| warning('Detected ', length(idx), ' duplicate input geohashes; removing') | ||
| geohashes = geohashes[-idx] | ||
| dup_idx = duplicated(geohashes) | ||
| if (any(dup_idx)) { | ||
| warning('Detected ', sum(dup_idx), ' duplicate input geohashes; removing') | ||
| geohashes = geohashes[!dup_idx] | ||
| } | ||
| sp::SpatialPolygonsDataFrame( | ||
| gh_to_sp(geohashes), | ||
|
|
@@ -49,11 +49,11 @@ gh_to_spdf.data.frame = function(gh_df, gh_col = 'gh', ...) { | |
| if (is.na(idx <- match(gh_col, names(gh_df)))) | ||
| stop('Searched for geohashes at a column named "', gh_col, '", but found nothing.') | ||
| gh = gh_df[[idx]] | ||
| if (anyDuplicated(gh) > 0L) { | ||
| idx = which(duplicated(gh)) | ||
| warning('Detected ', length(idx), ' duplicate input geohashes; removing') | ||
| gh = gh[-idx] | ||
| gh_df = gh_df[-idx, , drop = FALSE] | ||
| dup_idx = duplicated(gh) | ||
| if (any(dup_idx)) { | ||
| warning('Detected ', sum(dup_idx), ' duplicate input geohashes; removing') | ||
| gh = gh[!dup_idx] | ||
| gh_df = gh_df[!dup_idx, , drop = FALSE] | ||
| } | ||
| sp::SpatialPolygonsDataFrame( | ||
| gh_to_sp(gh), data = gh_df, match.ID = FALSE | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,8 @@ | |
|
|
||
| gh_delta = function(precision) { | ||
| if (length(precision) > 1L) stop('One precision at a time, please.') | ||
| if (!is.numeric(precision) || precision < 0L || precision > 25L) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess there's no real reason to enforce the |
||
| stop('precision must be a single integer between 0 and 25, inclusive.') | ||
| } | ||
| 45.0/2.0^((5.0*precision + c(-1.0, 1.0) * (precision %% 2.0))/2.0 - 1:2) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't there some problem with this CRS? Maybe we should just drop 'sp' support altogether, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah.
spis pretty deprecated.According to CRAN there are two reverse dependencies: one import and one suggest. Neither use
sp.Reverse imports: MazamaCoreUtils
Reverse suggests: spatialrisk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome... let's throw Claude at moving all implementations to use {sf} instead and then dropping {sp} as a first PR here?