-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfacade.R
27 lines (23 loc) · 976 Bytes
/
facade.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Rscript --vanilla facade.R 'otp.host="192.168.0.2", otp.port=8080, fun=pointToPoint,src_file="origin.csv", dst_file="destination.csv", output.dir="/tmp/a2s", startDateAndTime="2019-08-02 12:00:00", mapOutput=T'
suppressMessages(library(propeR))
connect <- (function() {
otp <- NULL
function() {
if(is.null(otp)) {
otp <<- otpConnect()
}
otp
}
})()
generate <- function(otp.host="localhost", otp.port=8080, otp.router="default", otp.ssl=FALSE, fun, src_file, dst_file, ...) {
otp <- otpConnect(hostname=otp.host, port=otp.port, router=otp.router, ssl=otp.ssl)
src.points <- importLocationData(src_file)
dst.points <- importLocationData(dst_file)
do.call(fun, list(otpcon=otp, originPoints=src.points, destinationPoints=dst.points, ...))
}
if(!interactive()) {
args.str <- commandArgs(trailingOnly=T)
args.lst <- eval(parse(text=paste0("list(", args.str, ")")))
stopifnot("fun" %in% names(args.lst))
do.call(generate, args.lst)
}