Skip to content

Commit

Permalink
Merge pull request #58 from richardellison/master
Browse files Browse the repository at this point in the history
Fix to errors with viaroute JSON
  • Loading branch information
Robinlovelace committed Jan 17, 2016
2 parents b06c48c + 8dd3b16 commit 5063e02
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions R/osrmfunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,18 @@ viaroute <- function(startlat = NULL, startlng = NULL, endlat = NULL,
i <- 1
while (i <= length(viapoints)) {
if(ncol(viapoints[[i]]) == 3) {
returnval[i] <- gsub('\\\\','\\\\\\\\',RCurl::getURL(paste0(qryurl,"loc=",paste0(viapoints[[i]][,1],',',viapoints[[i]][,2],'&u=',viapoints[[i]][,3],collapse='&loc='),'&',
returnval[i] <- gsub('\\\\\\\\\"','\\\\\\"',gsub('\\\\','\\\\\\\\',RCurl::getURL(paste0(qryurl,"loc=",paste0(viapoints[[i]][,1],',',viapoints[[i]][,2],'&u=',viapoints[[i]][,3],collapse='&loc='),'&',
paste0(paste0(
c("z","instructions","alt","geometry","uturns"),'=',
c(zoom,instructions,alt,geometry,uturns)),collapse='&')
)))
))))
}
else {
returnval[i] <- gsub('\\\\','\\\\\\\\',RCurl::getURL(paste0(qryurl,"loc=",paste0(paste0(viapoints[[i]][,1],',',viapoints[[i]][,2]),collapse='&loc='),'&',
returnval[i] <- gsub('\\\\\\\\\"','\\\\\\"',gsub('\\\\','\\\\\\\\',RCurl::getURL(paste0(qryurl,"loc=",paste0(paste0(viapoints[[i]][,1],',',viapoints[[i]][,2]),collapse='&loc='),'&',
paste0(paste0(
c("z","instructions","alt","geometry","uturns"),'=',
c(zoom,instructions,alt,geometry,uturns)),collapse='&')
)))
))))
}
i <- i + 1
}
Expand All @@ -134,18 +134,18 @@ viaroute <- function(startlat = NULL, startlng = NULL, endlat = NULL,
}

if (length(startlat) == 1) {
returnval <- gsub('\\\\','\\\\\\\\',RCurl::getURL(paste0(qryurl,"loc=",startlat,",",startlng,"&loc=",endlat,",",endlng,"&",
returnval <- gsub('\\\\\\\\\"','\\\\\\"',gsub('\\\\','\\\\\\\\',RCurl::getURL(paste0(qryurl,"loc=",startlat,",",startlng,"&loc=",endlat,",",endlng,"&",
paste0(paste0(c("z","instructions","alt","geometry","uturns"),'=',
c(zoom,instructions,alt,geometry,uturns)),collapse='&')
)))
))))
}
else {
i <- 1
while (i <= length(startlat)) {
returnval[i] <- gsub('\\\\','\\\\\\\\',RCurl::getURL(paste0(qryurl,"loc=",startlat[i],",",startlng[i],"&loc=",endlat[i],",",endlng[i],"&",
returnval[i] <- gsub('\\\\\\\\\"','\\\\\\"',gsub('\\\\','\\\\\\\\',RCurl::getURL(paste0(qryurl,"loc=",startlat[i],",",startlng[i],"&loc=",endlat[i],",",endlng[i],"&",
paste(paste0(c("z","instructions","alt","geometry","uturns"),'=',
c(zoom,instructions,alt,geometry,uturns)),collapse='&')
)))
))))
i <- i + 1
}
}
Expand Down

0 comments on commit 5063e02

Please sign in to comment.