Skip to content

Commit

Permalink
more fiddling
Browse files Browse the repository at this point in the history
  • Loading branch information
josie-hughes committed Mar 15, 2024
1 parent 4982785 commit 288dc8b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions R/getGraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ getGraph<- function(sim, neighbourhood,method="old",weightFunction = function(x1
#sim = list(costSurface=costRaster);neighbourhood="octagon"
#gdistance method takes more time and less memory. See testAltGraphFns in RoadPaper repo for details.
resolution=res(sim$costSurface)[1]
e = new.env()
if(method=="gdistance"){
if(!is.element(neighbourhood, c("rook", "octagon","queen"))) {
stop("neighbourhood type not recognized")
Expand Down
2 changes: 1 addition & 1 deletion R/weightFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' @param limitCost Value assigned to edges that exceed the grade limit. Set to a high (not NA) value if
#' @export
slopePenaltyFn<-function(x1,x2,baseCost = 16178,limit=20,penalty=504,limitCost=NA){
if(!exists("resolution")){resolution=1} # Will use value from calling environment if it exists there.
if(!exists("e$resolution")){resolution=1}else{resolution=e$resolution} # Will use value from calling environment if it exists there.
#If one of the nodes is a road or barrier ignore grade penalty
cond = pmin(x1,x2)>0
cond[is.na(cond)]=F
Expand Down

0 comments on commit 288dc8b

Please sign in to comment.