Skip to content

Commit

Permalink
Prevent long distances, close #125
Browse files Browse the repository at this point in the history
Heads-up @mem48 on this
  • Loading branch information
Robinlovelace committed May 19, 2023
1 parent 73ebfda commit 3921fc1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Fix for CRAN check errors (#124)
- Update README with test instructions
- Ignore large .geojson files in .Rbuildignore
- Prevent high uptake numbers for long distances (#125)

# pct 0.9.8 (February 2023)

Expand Down
8 changes: 8 additions & 0 deletions R/uptake.R
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,14 @@ check_distance_gradient = function(distance, gradient, verbose = TRUE) {
}
distance = distance / 1000
}
# If distance is more than 30 km set to 30:
which_distance_too_long = distance > 30
if (any(which_distance_too_long)) {
if (verbose) {
message("Distances greater than 30 km set to 30 km")
}
distance[which_distance_too_long] = 30
}
# is it in %? If mean of gradient is more than 0.1 (10% as ratio), probably
is_gradient_percent = mean(gradient) > 0.1
if(!is_gradient_percent) {
Expand Down

0 comments on commit 3921fc1

Please sign in to comment.