Git Product home page Git Product logo

ropensci / opentripplanner Goto Github PK

View Code? Open in Web Editor NEW
78.0 9.0 20.0 3.56 MB

An R package to set up and use OpenTripPlanner (OTP) as a local or remote multimodal trip planner.

Home Page: https://docs.ropensci.org/opentripplanner

License: GNU General Public License v3.0

R 99.12% TeX 0.75% Dockerfile 0.14%
r transport data routing opentripplanner public-transport transportation-planning otp java isochrones

opentripplanner's Introduction

OpenTripPlanner for R

R build status codecov Project Status: Active – The project has reached a stable, usable state and is being actively developed. DOI status CRAN_Status_Badge

opentripplanner is an R package that provides a simple yet flexible interface to OpenTripPlanner (OTP). OTP is a multimodal trip planning service written in Java. For more information on what OTP is, see the prerequisites vignette.

opentripplanner can be used to interface with a remote instance of OTP (e.g. a website) or help you set up and manage a local version of OTP for private use. Basic setup and routing functions are outlined in the getting started vignette, while advanced functionality such as batch routing, isochrones, and customised setup is described in the advanced features vignette.

What’s New

The newest version of the package 0.5.0 (Jan 2023) focuses on increased routing speeds (3-4x faster) and expanding support for OTP v2.2. The new version also drops legacy support for R 3.6, and so now requires R 4.0 or later. See news for more details.

Installation

OpenTripPlanner

To use OpenTripPlanner on your local computer you will need to install Java 8 and download the latest version of OTP. Instructions on installing Java and setting up OTP can be found in the prerequisites vignette.

R Package

To install the stable CRAN version:

install.packages("opentripplanner") # Install Package
library(opentripplanner)            # Load Package

Install the development version using remotes:

# If you do not already have the remotes package
install.packages("remotes")
# Install the package from GitHub
remotes::install_github("ropensci/opentripplanner")
# Load the package
library(opentripplanner)

Usage

The package contains three groups of functions:

Functions for setting up a local instance of OTP:

  1. otp_dl_jar() To download the OTP Jar file;
  2. otp_dl_demo() To download the demo data for the Isle of Wight;
  3. otp_check_java() To check you have the correct version of Java;
  4. otp_build_graph() To make a OTP graph from raw data;
  5. otp_setup() To start up a local instance of OTP;
  6. otp_make_config() To make a config object;
  7. otp_validate_config() To validate a config object;
  8. otp_write_config() To save a config object as a json file.

Functions for connecting to a local or remote instance of OTP:

  1. otp_connect() To connect to OTP.

Functions for retrieving data from OTP:

  1. otp_plan() To get routes from A to B;
  2. otp_geocode() To get the locations of named places e.g. road names (OTP 1.x only);
  3. otp_isochrone() To get isochrone maps (OTP 1.x only);
  4. otp_make_surface() To make an analyst surface (OTP 1.x only);
  5. otp_surface() To evaluate a analyst surface (OTP 1.x only);
  6. otp_traveltime() To make a travel time matrix (OTP 1.x only);
  7. otp_surface_isochrone() To make a raster isochrone map (OTP 1.x only);

Results are returned as sf objects.

Acknowledgement

This package was built off the tutorial by Marcus Young.

Contribution

Please note that the opentripplanner project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms. Bug reports and comments are welcome as Github Issues and code submissions as Pull Requests.

Citation

Please cite the JOSS paper in publications:

Morgan et al., (2019). OpenTripPlanner for R. Journal of Open Source Software, 4(44), 1926, https://doi.org/10.21105/joss.01926

ropensci_footer

opentripplanner's People

Contributors

aakarner avatar danielskatz avatar dhersz avatar e-kotov avatar layik avatar marcusyoung avatar mem48 avatar robinlovelace avatar temporalista avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opentripplanner's Issues

Issue in opentripplanner vignette

Everything worked, except this line:

route <- otp_plan(otpcon, fromPlace = c(-1.17502, 50.64590), toPlace = c(-1.15339, 50.72266))
   |                                                  | 0 % ~calculating  Error in geodist::geodist(line[seq(1, nrow(line) - 1), ], line[seq(2,  : 
  unused argument (paired = TRUE)

Can you reproduce this @mem48 ?

json files compatibility with OTP 1.4

OTP 1.4 Does not like

"stopClusterMode": ["proximity"],

but does like

"stopClusterMode": "proximity",

Need to fix the otp_config code and check with OTP 1.3 for back compatability

sf expects json not gpkg files from urls

See

lsoa <- sf::read_sf("https://github.com/ITSLeeds/opentripplanner/releases/download/0.1/centroids.gpkg")
#> Warning in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, :
#> GDAL Error 1: JSON parsing error: unexpected character (at offset 0)

Created on 2019-05-09 by the reprex package (v0.2.1)

  • heads-up @mem48 this causes tests to crash

Error when calculating walking route (without fare)

Reproducible example:

# Aim: set-up and use local routing service

devtools::install_github("ropensci/opentripplanner", build_vignettes = TRUE)
devtools::install_github("itsleeds/geofabrik")

library(geofabrik)
library(opentripplanner)

otp_data = geofabrik::gf_filename("West Yorkshire")
# vignette("opentripplanner")

path_data <- "/home/robin/hd/data/otp"
dir.create(path_data) 

dir.create(file.path(path_data, "graphs"))
dir.create(file.path(path_data, "graphs", "default"))

file.copy(otp_data, file.path(path_data, "graphs", "default"))
path_otp <- otp_dl_jar(path_data)

log1 <- otp_build_graph(otp = path_otp, dir = path_data)

# 2020-01-29 11:14:54 Basic checks completed, building graph, this may take a few minutes
# The graph will be saved to /home/robin/hd/data/otp
# 2020-01-29 11:15:19 Graph built

log2 <- otp_setup(otp = path_otp, dir = path_data)
log2 <- otp_setup(otp = path_otp, dir = path_data, port = 8801, securePort = 8802)
otpcon <- otp_connect()
route <- otp_plan(otpcon, fromPlace = c(-1.54804, 53.79335),  
  toPlace = c(-1.52264, 53.82964), mode = "WALK")

| | 0 % ~calculating Error in $<-.data.frame(*tmp*, "fare", value = numeric(0)) :
replacement has 0 rows, data has 1

non-deterministic batch routing?

Hi,
thanks for the work on the package - makes especially batch routing with OTP super easy.
I just ran into one problem:
I'm using otp_plan for batch routing (~4000 routings). It seems, that even though all parameters are set identical for two runs, the batch routing does not always return the same results.
E.g. for one route there are once 2 options and once 3 options (therefore also leading to different "shortest travel time" results). It also does not make a difference, wether I set the parameter numItineraries = 3 or not.
When running the routing only for that one specific route (so no batch routing), the same routes are always returned.
Not sure if I am doing sth wrong, or if this is a possible behaviour of the OTP router, when too many requests are fired at once?

remote install throw an error

When following your readme file bring to remote install the package I received an error message below

Error in curl::curl_fetch_memory(url, handle = h) :
Timeout was reached: Operation timed out after 10004 milliseconds with 0 out of 0 bytes received

upper value must be greater than lower value

places <- read.csv("E:/OneDrive - University of Leeds/Data/opentripplanner/graphs/brandenburg/stops_example.csv")
places <- sf::st_as_sf(places, coords = c("stop_lon", "stop_lat" ))

fromPlace <- places[rep(seq(1, nrow(places)), times = nrow(places)),]
toPlace <- places[rep(seq(1, nrow(places)), each = nrow(places)),]

r1 <- otp_plan(otpcon, fromPlace[1073,], toPlace[1073,], mode = c("WALK","TRANSIT"),
               date_time = as.POSIXct(strptime("2020-07-28 13:30", "%Y-%m-%d %H:%M")),
               ncores = 1)

Ideas for next version

Holding place for ideas of what could be added to the package.

  • Support for OTP 2.0

  • Check Java version function

  • Perfect elevation transcription (currently just mostly good)

  • More helper functions e.g. travel time matrix

  • Support wider set of API features, e.g. GTFS details

  • Cache JAR files in package

maxTransfers is logical in otp_validate_routing_options when it should be integer

Hi,

Great package I am enjoying it a lot! Thanks for the contribution.

I tried to edit otp_routing_options to limit the number of transfers in a request. However, when using otp_validate_routing_options it fails since it expecting a logical value when it should be an integer.

 routingOptions <- otp_routing_options()
 routingOptions$maxTransfers <- 3
 routingOptions <- otp_validate_routing_options(routingOptions)

Returns:

Error in otp_validate_routing_options(routingOptions) : 
  Assertion on 'opts$maxTransfers' failed: Must be of type 'logical' (or 'NULL'), not 'double'.

Best,
Rafa

Add bannedAgencies parameter

Hi, first off thank you for the brilliant package! I am new to R and this made my life very easy.

I wanted to suggest adding the bannedAgencies parameter to the otp_plan() and otp_isochrone() functions. This exists in OpenTripPlanner . One use case I can think of is informal transit; you have formal buses and informal buses which both go under mode “BUS”, but are normally under different agencies. This is specific to cities in developing countries (I was working on Cairo, Egypt)

It would be something like this:

otp_isochrone(
      otpcon = otpcon, 
      fromPlace = c(-0.1346, 51.5292),
      mode = "TRANSIT",
      date_time = Sys.time(),
      maxWalkDistance = 800,
      cutoffSec = 3600
      bannedAgencies = c("Microbus", "Suzuki") 
)

In this case, Microbus and Suzuki are informal modes of transport that fall under the mode "BUS", so they cannot be filtered out by the mode parameter.

For my work, I ended up using the onebusaway-gtfs-transformer-cli to subset the GTFS by agency, but this required building a new otp graph with the subsetted GTFS. The bannedAgencies parameter would allow the analysis to be done on the same graph.

Overlong load time in otp_setup

Hello again, and sorry for opening another issue. Problem this time is that OTP is taking an extremely long time to set up. The message received is:

2020-06-15 14:29:16 OTP is loading and may take a while to be useable
2020-06-15 14:47:57 OTP is taking an unusually long time to load, releasing R to your control, OTP will continue in the background

My code is:

path_data <- file.path("[]/Documents/[]", "OTP")
path_otp <- file.path("[]/Documents/[]/OTP/otp.jar")
log1 <- otp_build_graph(otp = path_otp, dir = path_data, router = "NYC", memory = 54000)
log2 <- otp_setup(otp = path_otp, dir = path_data, router = "NYC")

And my file structure looks like:

[img]https://i.imgur.com/axXkMZs.png[/img]

Thanks so much.

otp_plan returning NA when mode is set to "TRANSIT"

I was testing the otp_plan function and when I set the mode argument to transit I got NA as the result. It runs alright for car, walk and bicycle, but none of the transit options work.

I guess it's hard to send a reproducible code, but here is a example:

otp_setup(otp = "./otp/otp.jar", dir = "./otp", router = "router")

otpcon <- otp_connect(hostname =  "localhost", router = "router")

origin <- matrix(c(-43.2239138328723, -43.5985533845742, -43.6365446776388, 
                   -43.2970458336628, -43.699771395377, -22.7910165669908, -22.9071947734321, 
                   -22.9526980792538, -22.8932385556204, -22.899807308795), ncol = 2)
dest <- c(-43.179156, -22.906453)

routes_car <- otp_plan(otpcon = otpcon, fromPlace = origin, toPlace = dest, mode = "CAR")

print(routes_car)
#> Simple feature collection with 5 features and 32 fields
#> geometry type:  LINESTRING
#> dimension:      XYZ
#> bbox:           xmin: -43.69972 ymin: -23.02123 xmax: -43.17916 ymax: -22.78991
#> z_range:        zmin: 0 zmax: 0
#> geographic CRS: WGS 84
#>   duration           startTime             endTime walkTime transitTime waitingTime walkDistance
#> 1     2379 2020-05-22 06:03:00 2020-05-22 06:42:39     2379           0           0            0
#> 2     3359 2020-05-22 06:03:00 2020-05-22 06:58:59     3359           0           0            0
#> 3     4410 2020-05-22 06:03:00 2020-05-22 07:16:30     4410           0           0            0
#> 4     1215 2020-05-22 06:03:00 2020-05-22 06:23:15     1215           0           0            0
#> 5     3129 2020-05-22 06:03:00 2020-05-22 06:55:09     3129           0           0            0
#>   walkLimitExceeded elevationLost elevationGained transfers tooSloped fare fare_currency
#> 1             FALSE             0               0         0     FALSE   NA            NA
#> 2             FALSE             0               0         0     FALSE   NA            NA
#> 3             FALSE             0               0         0     FALSE   NA            NA
#> 4             FALSE             0               0         0     FALSE   NA            NA
#> 5             FALSE             0               0         0     FALSE   NA            NA
#>            startTime1            endTime1 departureDelay arrivalDelay realTime distance pathway mode route
#> 1 2020-05-22 06:03:00 2020-05-22 06:42:39              0            0    FALSE 24224.63   FALSE  CAR      
#> 2 2020-05-22 06:03:00 2020-05-22 06:58:59              0            0    FALSE 57710.76   FALSE  CAR      
#> 3 2020-05-22 06:03:00 2020-05-22 07:16:30              0            0    FALSE 65989.54   FALSE  CAR      
#> 4 2020-05-22 06:03:00 2020-05-22 06:23:15              0            0    FALSE 16240.96   FALSE  CAR      
#> 5 2020-05-22 06:03:00 2020-05-22 06:55:09              0            0    FALSE 62994.27   FALSE  CAR      
#>   agencyTimeZoneOffset interlineWithPreviousLeg rentedBike flexDrtAdvanceBookMin duration1 transitLeg
#> 1            -10800000                    FALSE      FALSE                     0      2379      FALSE
#> 2            -10800000                    FALSE      FALSE                     0      3359      FALSE
#> 3            -10800000                    FALSE      FALSE                     0      4410      FALSE
#> 4            -10800000                    FALSE      FALSE                     0      1215      FALSE
#> 5            -10800000                    FALSE      FALSE                     0      3129      FALSE
#>   route_option               fromPlace               toPlace                       geometry
#> 1            1 -22.7910166,-43.2239138 -22.906453,-43.179156 LINESTRING Z (-43.22328 -22...
#> 2            1 -22.9071948,-43.5985534 -22.906453,-43.179156 LINESTRING Z (-43.59858 -22...
#> 3            1 -22.9526981,-43.6365447 -22.906453,-43.179156 LINESTRING Z (-43.63701 -22...
#> 4            1 -22.8932386,-43.2970458 -22.906453,-43.179156 LINESTRING Z (-43.29683 -22...
#> 5            1 -22.8998073,-43.6997714 -22.906453,-43.179156 LINESTRING Z (-43.69972 -22...

routes_transit <- otp_plan(otpcon = otpcon, fromPlace = origin, toPlace = dest, mode = "TRANSIT")

print(routes_transit)
#> [1] NA

I didn't create the graph object with the otp_build_graph, since I have just recently found out about this package, but I don't think that should matter. In fact, I'm able to make requests with the mode paramater set to "TRANSIT" with another function I wrote, so it's probably not related to the graph? Not sure.

Edit: I should mention that my otp directory is arranged as so:

/otp
    otp.jar
    /graphs
        /router
            google_transit_fetranspor.zip
            gtfs20191128_supervia.zip
            Graph.obj
            rio_de_janeiro.osm.pbf

0.3 release

  • route option missing from results

  • benchmark results

  • check otp_plan for all modes

  • check otp_isochrone

  • run full tests

  • increase code coverage

  • run onboarding tests

  • spell check documentation

Failing on AppVeyor

It seems to be a problem with geodist

Installing 1 packages: geodist
Installing package into 'c:/RLibrary'
(as 'lib' is unspecified)
  There is a binary version available but the source version is later:
        binary source needs_compilation
geodist  0.0.2  0.0.3              TRUE
installing the source package 'geodist'
trying URL 'https://cran.rstudio.com/src/contrib/geodist_0.0.3.tar.gz'
Content type 'application/x-gzip' length 536443 bytes (523 KB)
==================================================
downloaded 523 KB
* installing *source* package 'geodist' ...
** package 'geodist' successfully unpacked and MD5 sums checked
** libs
*** arch - i386
c:/Rtools/mingw_32/bin/gcc  -I"c:/R/include" -DNDEBUG          -O3 -Wall  -std=gnu99 -mtune=generic -c common.c -o common.o
/bin/sh: c:/Rtools/mingw_32/bin/gcc: No such file or directory
make: *** [common.o] Error 127
ERROR: compilation failed for package 'geodist'
* removing 'c:/RLibrary/geodist'
* restoring previous 'c:/RLibrary/geodist'
In R CMD INSTALL
Error in i.p(...) : 
  (converted from warning) installation of package 'geodist' had non-zero exit status
Calls: <Anonymous> ... with_rprofile_user -> with_envvar -> force -> force -> i.p
Execution halted
Command exited with code 1

tests failing on Linux

==> devtools::check()

Updating opentripplanner documentation
Writing NAMESPACE
Loading opentripplanner
Writing NAMESPACE
── Building ─────── opentripplanner ──
Setting env vars:
● CFLAGS    : -Wall -pedantic -fdiagnostics-color=always
● CXXFLAGS  : -Wall -pedantic -fdiagnostics-color=always
● CXX11FLAGS: -Wall -pedantic -fdiagnostics-color=always
──────────────────────────────────────
✔  checking for file ‘/mnt/27bfad9a-3474-4e61-9a43-0156ebc67d67/home/robin/ITSLeeds/opentripplanner/DESCRIPTION’ ...
─  preparing ‘opentripplanner’:
✔  checking DESCRIPTION meta-information ...
─  installing the package to build vignettes
✔  creating vignettes (2.2s)
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
   Removed empty directory ‘opentripplanner/git’
─  building ‘opentripplanner_0.1.0.0000.tar.gz’
   
── Checking ─────── opentripplanner ──
Setting env vars:
● _R_CHECK_CRAN_INCOMING_USE_ASPELL_: TRUE
● _R_CHECK_CRAN_INCOMING_REMOTE_    : FALSE
● _R_CHECK_CRAN_INCOMING_           : FALSE
● _R_CHECK_FORCE_SUGGESTS_          : FALSE
── R CMD check ─────────────────────────────────────────────────────────────────
─  using log directory ‘/mnt/27bfad9a-3474-4e61-9a43-0156ebc67d67/home/robin/ITSLeeds/opentripplanner.Rcheck’
─  using R version 3.6.0 (2019-04-26)
─  using platform: x86_64-pc-linux-gnu (64-bit)
─  using session charset: UTF-8
─  using options ‘--no-manual --as-cran’ (601ms)
✔  checking for file ‘opentripplanner/DESCRIPTION’
─  this is package ‘opentripplanner’ version ‘0.1.0.0000’
─  package encoding: UTF-8
✔  checking package namespace information ...
✔  checking package dependencies (2.4s)
N  checking if this is a source package
   Found the following apparent object files/libraries:
     graphs/default/Graph.obj
   Object files/libraries should not be included in a source package.
✔  checking if there is a namespace
✔  checking for executable files ...
✔  checking for hidden files and directories
✔  checking for portable file names ...
✔  checking for sufficient/correct file permissions ...
✔  checking serialization versions
✔  checking whether package ‘opentripplanner’ can be installed (1.3s)
✔  checking installed package size ...
✔  checking package directory ...
✔  checking for future file timestamps ...
✔  checking ‘build’ directory
✔  checking DESCRIPTION meta-information ...
N  checking top-level files
   Non-standard files/directories found at top level:
     ‘graphs’ ‘paper.bib’
✔  checking for left-over files
✔  checking index information ...
✔  checking package subdirectories ...
✔  checking R files for non-ASCII characters ...
✔  checking R files for syntax errors ...
✔  checking whether the package can be loaded ...
✔  checking whether the package can be loaded with stated dependencies ...
✔  checking whether the package can be unloaded cleanly ...
✔  checking whether the namespace can be loaded with stated dependencies ...
✔  checking whether the namespace can be unloaded cleanly ...
✔  checking loading without being on the library search path ...
✔  checking dependencies in R code (584ms)
✔  checking S3 generic/method consistency (431ms)
✔  checking replacement functions ...
✔  checking foreign function calls ...
N  checking R code for possible problems (2.4s)
   Warning: <anonymous>: ... may be used in an incorrect context
   
   otp_get_results: ... may be used in an incorrect context
✔  checking Rd files ...
✔  checking Rd metadata ...
✔  checking Rd line widths ...
✔  checking Rd cross-references ...
✔  checking for missing documentation entries ...
✔  checking for code/documentation mismatches (353ms)
✔  checking Rd \usage sections (530ms)
✔  checking Rd contents ...
✔  checking for unstated dependencies in examples ...
✔  checking installed files from ‘inst/doc’ ...
✔  checking files in ‘vignettes’ ...
✔  checking examples (689ms)
✔  checking for unstated dependencies in ‘tests’ ...
─  checking tests ...
E  Running ‘testthat.R’ [50s/82s]
   Running the tests in ‘tests/testthat.R’ failed.
   Last 13 lines of output:
     19:36:20.776 INFO (LuceneIndex.java:143) Starting background Lucene indexing.
     19:36:23.431 INFO (LuceneIndex.java:91) Built Lucene index in 2655 msec
     13481 ?        00:00:32 java
     ══ testthat results  ═════════════════
     OK: 84 SKIPPED: 0 WARNINGS: 100 FAILED: 2
     1. Failure: can get lsoa points (@test_03_with_OTP.R#43) 
     2. Error: batch routing (@test_03_with_OTP.R#138) 
     
     Error: testthat unit tests failed
     In addition: Warning messages:
     1: In for (i in nsInfo$imports) { :
       closing unused connection 5 (<-localhost:11706)
     2: In for (i in nsInfo$imports) { :
       closing unused connection 4 (<-localhost:11706)
     Execution halted
✔  checking for unstated dependencies in vignettes ...
✔  checking package vignettes in ‘inst/doc’ ...
✔  checking re-building of vignette outputs (1.7s)
   
   See
     ‘/mnt/27bfad9a-3474-4e61-9a43-0156ebc67d67/home/robin/ITSLeeds/opentripplanner.Rcheck/00check.log’
   for details.
   
── R CMD check results ───────────────────────── opentripplanner 0.1.0.0000 ────
Duration: 1m 38s

❯ checking tests ...
  See below...

❯ checking if this is a source package ... NOTE
  Found the following apparent object files/libraries:
    graphs/default/Graph.obj
  Object files/libraries should not be included in a source package.

❯ checking top-level files ... NOTE
  Non-standard files/directories found at top level:
    ‘graphs’ ‘paper.bib’

❯ checking R code for possible problems ... NOTE
  Warning: <anonymous>: ... may be used in an incorrect context
  
  otp_get_results: ... may be used in an incorrect context

── Test failures ───────────────────────────────────────────────── testthat ────

> library(testthat)
> library(opentripplanner)
> 
> test_check("opentripplanner")
── 1. Failure: can get lsoa points (@t
nrow(lsoa) == 89 isn't true.

19:35:49.467 INFO (OTPServer.java:39) Wiring up and configuring server.
19:35:49.471 INFO (GraphScanner.java:81) Attempting to automatically register routerIds [default]
19:35:49.471 INFO (GraphScanner.java:82) Graph files will be sought in paths relative to /tmp/Rtmpk7sdDf/otp/graphs
19:35:49.474 INFO (GraphService.java:189) Registering new router 'default'
19:35:49.474 INFO (InputStreamGraphSource.java:207) Loading graph...
19:35:55.235 INFO (Graph.java:789) Graph version: MavenVersion(1, 3, 0, , 23d319183a7d6fa9b3caef5412fc3ad8fcc54290)
19:35:55.236 INFO (Graph.java:790) OTP version:   MavenVersion(1, 3, 0, , 23d319183a7d6fa9b3caef5412fc3ad8fcc54290)
19:35:55.236 INFO (Graph.java:807) This graph was built with the currently running version and commit of OTP.
19:35:57.560 INFO (Graph.java:759) Main graph read. |V|=37820 |E|=88993
19:35:58.120 INFO (GraphIndex.java:124) Indexing graph...
19:35:58.206 INFO (GraphIndex.java:583) Clustering stops by geographic proximity and name...
19:35:58.269 INFO (GraphIndex.java:198) Creating a spatial index for stop clusters.
19:35:58.310 INFO (GraphIndex.java:187) Done indexing graph.
19:35:58.430 INFO (Router.java:96) Loading default routing parameters from JSON:
19:35:58.440 INFO (ReflectiveInitializer.java:121) Initialized 'driveOnRight' with value false.
19:35:58.440 INFO (Router.java:127) Timeouts for router 'default': [5.0, 4.0, 3.0, 1.0]
19:35:58.440 INFO (Router.java:134) Incoming requests will not be logged.
19:35:58.441 INFO (GraphUpdaterConfigurator.java:55) Using configurations: [main] 
19:35:58.569 INFO (Router.java:166) Computed ellipsoid/geoid offset at (50.68034655, -1.36223675) as 48.546999439148024
19:35:58.572 INFO (GrizzlyServer.java:72) Starting OTP Grizzly server on ports 8080 (HTTP) and 8081 (HTTPS) of interface 0.0.0.0
19:35:58.572 INFO (GrizzlyServer.java:74) OTP server base path is /var/otp
19:35:59.007 INFO (GrizzlyServer.java:51) Java reports that this machine has 4 available processors.
19:35:59.007 INFO (GrizzlyServer.java:62) Maximum HTTP handler thread pool size will be 5 threads.
19:35:59.795 WARN (PropertiesHelper.java:330) There is no way how to transform value "true" [java.lang.Boolean] to type [java.lang.String].
19:35:59.857 INFO (NetworkListener.java:750) Started listener bound to [0.0.0.0:8080]
19:35:59.874 INFO (NetworkListener.java:750) Started listener bound to [0.0.0.0:8081]
19:35:59.883 INFO (HttpServer.java:300) [HttpServer] Started.
19:35:59.883 INFO (GrizzlyServer.java:153) Grizzly server running.
19:36:19.459 ERROR (GraphService.java:124) no graph registered with the routerId 'test'
── 2. Error: batch routing (@test_03_w
fromPlace contains non-POINT geometry
1: otp_plan(otpcon = otpcon, fromPlace = lsoa[1:10, 
       ], toPlace = lsoa[11:20, ]) at testthat/test_03_with_OTP.R:138
2: otp_clean_input(fromPlace, "fromPlace")
3: stop(paste0(imp_name, " contains non-POINT geometry"))

19:36:20.654 INFO (SPTWalker.java:169) SPTWalker: Generated 59900 points (0 dup edges, 0 no geometry) from 11840 vertices / 27015 states.
19:36:20.657 INFO (AccumulativeGridSampler.java:152) Added 269 closing samples to get a total of 986.
19:36:20.657 INFO (SampleGridRenderer.java:102) Computed SPT in 127msec, 124msec for sampling (251 msec total)
19:36:20.705 INFO (IsoChroneSPTRendererAccSampling.java:114) Computed 6 isochrones in 48msec
19:36:20.776 INFO (LuceneIndex.java:143) Starting background Lucene indexing.
19:36:23.431 INFO (LuceneIndex.java:91) Built Lucene index in 2655 msec
13481 ?        00:00:32 java
══ testthat results  ═════════════════
OK: 84 SKIPPED: 0 WARNINGS: 100 FAILED: 2
1. Failure: can get lsoa points (@test_03_with_OTP.R#43) 
2. Error: batch routing (@test_03_with_OTP.R#138) 

Error: testthat unit tests failed
In addition: Warning messages:
1: In for (i in nsInfo$imports) { :
  closing unused connection 5 (<-localhost:11706)
2: In for (i in nsInfo$imports) { :
  closing unused connection 4 (<-localhost:11706)
Execution halted

1 error ✖ | 0 warnings ✔ | 3 notes ✖
Error: R CMD check found ERRORs
Execution halted

Exited with status 1.

Files
Plots
Packages
Help
Viewer

			

			
	
	
Zoom
	
	
Export

	
			
	
			
	
			

			

			
	
			

	
.travis.yml

	
DESCRIPTION

	
opentripplanner.Rmd

	
prerequisites.Rmd

	
otp-setup.R

	
Untitled1
*	
	
.Renviron

	
test_03_with_OTP.R


			

			
	
			
	
			
		
			

			
	
			

	
Run Tests
	
			
41:1
(Top Level)
R Script

windo
 
Next

Prev

All

Replace
 
Replace

All
	
In selection
	
Match case
	
Whole word
	
Regex
	
Wrap



��
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
path_otp <- file.path(path_data, "otp.jar")
test_that("download otp", {
  url_otp <- "https://repo1.maven.org/maven2/org/opentripplanner/otp/1.3.0/otp-1.3.0-shaded.jar"
  download.file(url = url_otp, destfile = file.path(path_data, "otp.jar"), mode = "wb", quiet = TRUE)
  expect_true(file.exists(file.path(path_otp)))
})
lsoa <- sf::read_sf("https://github.com/ITSLeeds/opentripplanner/releases/download/0.1/centroids.gpkg")
test_that("can get lsoa points", {
  expect_is(lsoa, "sf")
  expect_true(nrow(lsoa) == 89)
})
context("Test the otp_build_graph function")
test_that("We can build an otp graph", {
  skip_no_otp()

Console/mnt/27bfad9a-3474-4e61-9a43-0156ebc67d67/home/robin/ITSLeeds/opentripplanner/
Console
Terminal

Find in Files

Jobs

/mnt/27bfad9a-3474-4e61-9a43-0156ebc67d67/home/robin/ITSLeeds/opentripplanner/	
			

			

otp_plan function error

Hi Dr.Morgan and other developers,

Thanks for developing such a wonderful R package.

When I run "otp_plan" function, an error message keeps coming up. I wonder if you can help me figure out.

I follow your tutorial(https://docs.ropensci.org/opentripplanner/articles/advanced_features.html) but use the data of the Washington metropolitan area. The local OTP server is successfully set on my computer. When I run otp_plan function, I do 'Batch Routing', set 3 cores, and set get_geometry false. But I get the error message, which says "Error in otp_plan(otpcon = otpcon, fromPlace = fromPlace, toPlace = toPlace, : unused arguments (get_geometry = FALSE, ncores = 3)".

Batch routing example

library(opentripplanner)

Path to a folder containing the OTP.jar file, change to where you saved the file.

path_data <- file.path("C:\Project_R_Tool\OpenStripPlanner\Based_on_R","OTP")
path_otp <- file.path(path_data,"otp.jar")
##Build Graph and start OTP
log1 <- otp_build_graph(otp = path_otp, dir = path_data)
log2 <- otp_setup(otp = path_otp, dir = path_data)
otpcon <- otp_connect()

Load points

DC_centroids<-sf::st_read("C:\...blockxy.csv",colClasses=c(ID="character"))
DC_centroids<-DC_centroids[1:5000,]
DC_centroids<-DC_centroids[c('lon','lat')]

toPlace = DC_centroids[rep(seq(1, nrow(DC_centroids)), times = nrow(DC_centroids)),]
fromPlace = DC_centroids[rep(seq(1, nrow(DC_centroids)), each = nrow(DC_centroids)),]

Run otp_plan function

routes <- otp_plan(otpcon = otpcon,
fromPlace = fromPlace,
toPlace = toPlace,
get_geometry = FALSE,
ncores=3)

Error message

Error in otp_plan(otpcon = otpcon, fromPlace = fromPlace, toPlace = toPlace, : unused arguments (get_geometry = FALSE, ncores = 3)

Point example

Actually, when I run the 'otp_plan' function with the following codes to compute one point to another point, it reports an error as well.

dd<-opentripplanner::otp_plan(otpcon, fromPlace=c(-77.06463, 38.96368),toPlace= c(-77.02961, 38.89477),mode = "CAR",maxWalkDistance = 100000000)
Warning message:
In opentripplanner::otp_plan(otpcon, fromPlace = c(-77.06463, 38.96368), :
A routing error has occurred, returning error message

OTP / Java set up issue on Windows

Hi there opentripplanner team

I am going through the installation and set up for the package review. I have updated Java to version 8 and installed and attached the R package opentripplanner, as per the vignettes. I am raising this is as an issue as I am unable to progress on the review at this point.

I initially suspected there an issue with the OTP connection as the check for OTP did not return TRUE. (I did not change the .Renviron file at that point, as suggested in the vignette, see next).
Sys.getenv("I_have_OTP")

[1] ""

The build of a graph object also returned an error message:

log <- otp_build_graph(otp = path_otp, dir = path_data)

Basic checks completed, building graph, this may take a few minutes
Failed to build graph with message:
Error occurred during initialization of VMCould not reserve enough space for 2097152KB object heap
Warning message:
In system(text, intern = TRUE) :
running command 'java -Xmx2G -jar > >"C:\Users\Home\AppData\Local\Temp\RtmpoNFxd9/OTP/otp.jar" --build >"C:\Users\Home\AppData\Local\Temp\RtmpoNFxd9/OTP/graphs/default"' had status 1

I did some Googling and tried this fix on the environment variables in the control panel:
System Variables->New:
Variable name: _JAVA_OPTIONS
Variable value: -Xmx2G

Edit Environment Variable path:
Variable name: Path
Variable value: ;C:\Program Files\Java\jre6\bin;F:\JDK\bin;

I now see a successful OTP connection,

Sys.getenv("I_have_OTP")

[1] "TRUE"

I then retried the graph object and perhaps the new variables are good as it looks like it has gone past the initialisation, but there appears to be a Java version issue now. ? I am not familiar with Java so I was wondering if you could advise on what to try next?

Run the OTP and Build a graph object

log <- otp_build_graph(otp = path_otp, dir = path_data)

Error in otp_checks(otp = otp, dir = dir, router = router, graph = FALSE) :

In addition: Warning messages:
1: In system2("java", "-version", stdout = TRUE, stderr = TRUE) :
running command '"java" -version' had status 1
2: In otp_checks(otp = otp, dir = dir, router = router, graph = FALSE) :
NAs introduced by coercion
3: In otp_checks(otp = otp, dir = dir, router = router, graph = FALSE) :

Also see below the session information:

sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252
[3] LC_MONETARY=English_New Zealand.1252 LC_NUMERIC=C
[5] LC_TIME=English_New Zealand.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] opentripplanner_0.1.0.0000

loaded via a namespace (and not attached):
[1] compiler_3.5.1 backports_1.1.4 clisymbols_1.2.0 tools_3.5.1 fs_1.2.6
[6] glue_1.3.1 rstudioapi_0.9.0 yaml_2.2.0 crayon_1.3.4 Rcpp_1.0.1
[11] usethis_1.5.0 checkmate_1.9.3 rlang_0.3.4

Set up an OTP instance taking too long

I have successfully created a graph object but it seems like there is a potential issue with setting up the OTP instance. See below error message.

log <- otp_build_graph(otp = path_otp, dir = path_data, memory = 1)

Basic checks completed, building graph, this may take a few minutes
Graph built

otp_setup(otp = path_otp, dir = path_data)

2019-05-30 11:05:41 OTP is loading and may take a while to be useable
2019-05-30 11:11:05 OTP is taking an unusually long time to load, releasing R to your control

Trying the other alternative ports example

otp_setup(otp = path_otp, dir = path_data, port = 8801, securePort = 8802)

2019-05-30 11:11:06 OTP is loading and may take a while to be useable
2019-05-30 11:16:29 OTP is taking an unusually long time to load, releasing R to your control

add id variable

Add option for a from place and to place id to be included in the results.

Support API Keys

For remote servers it would be good to support API keys and login requirments, need an example to build around so waiting for someone in need.

N x N matrix

Hello

I'm trying to get the trip data from a matrix of N x N origins. I have my area of service divided into a set of polygons, each with a centroid. What I want to generate is the grade of accessibility which measures the time of each centroid to the rest of the centroids (including itself which is = 0) and the Deuter index which is related to distances.

I have been reading the advanced documentation but I get still an error. The ways I have been trying to do are:

routes <- otp_plan(otpcon = otpcon, fromPlace = centroides, toPlace = centroides, mode = ("CAR"),ncores = 5)

centroids is a SF object with the coordinates in its geometry so is a valid data frame. The error that I get is the following (error 1):
error 1

All the points are within a valid area, I have measured the time from a single point to the all set of centroids and it runs well.

The other way I want to do it is following more closer the sintaxis of the tutorial which is :

toPlace = centroides[rep(1, nrow(centroides), times = nrow(centroides)),] fromPlace = centroides[rep(1, nrow(centroides), each = nrow(centroides)),]

This generated 2 variables (from places which will have rows of N^N and to Place which is going to have N rows) and I use them in the function otp_plan like I do it in a one to one origin and destination:

OD_Matrix <- otp_plan(otpcon = otpcon, fromPlace = fromPlace, toPlace = toPlace, mode=("CAR"), get_geometry = FALSE, ncores = 5)

This gives me the following error:

error 2

In this case, I don't understand why is a problem that the number of rows in origins and the number of rows in the destination is a problem if previously I have used from a single origin to many destinations without a problem.

I hope someone can help me.

Best regards,
Orlando

Meet ropensci standards

https://ropensci.github.io/dev_guide/building.html#building

  • 1.1.1 Naming your package

  • 1.1.2 Creating metadata for your package

  • 1.2 Platforms

  • 1.4 Function and argument naming

  • 1.4.1 Console messages

  • 1.5 Code Style

  • 1.6 README

  • 1.7 Documentation

  • 1.8 Documentation website

  • 1.8.1 Grouping functions in the reference

  • 1.8.2 Automatic deployment of the documentation website

  • 1.8.3 Branding of authors

  • 1.9 Authorship

  • 1.10 Testing

  • 1.11 Examples

  • 1.12 Package dependencies

  • 1.13 Recommended scaffolding

  • 1.14 Miscellaneous CRAN gotchas

  • 1.15 Further guidance

  • 2.3.1 Travis CI (Linux and Mac OSX)

  • 2.3.2 AppVeyor CI (Windows)

  • 2.4 Test coverage

  • 3.1 Misc

  • JOSS Paper

  • 7.1.1 General guidelines

End of (Unix) Time

The package is hardcoded for 32 bit Unix time, to support OTP. So the whole thing may break after 19th January 2038.

small typo in vignette

While teaching myself using the vignettes, I came across a smaller error in the advanced vignette. (https://cran.r-project.org/web/packages/opentripplanner/vignettes/advanced_features.html)

In the pivot_wider function, the document uses the older terminology from the spread and gather functions (key and value) instead of names_to and values_to. It throws an error when executing the code.

routes <- otp_plan(otpcon = otpcon,
fromPlace = fromPlace,
toPlace = toPlace,
fromID = fromPlace$geo_code,
toID = toPlace$geo_code,
get_geometry = FALSE)
routes <- routes[,c("fromPlace","toPlace","duration")]

Use the tidyr package to go from long to wide format

routes_matrix <- tidyr::pivot_wider(routes,
key = "toPlace",
value = "duration")

Speed up otp_plan function

Hello.

I run otp_plan function with batch routing and multiple cores. But the takes me more than 100 hours to run the function since I try to calculate a travel time matrix of 110,000 columns and 110,000 rows. Is there any way I can speed up the otp_plan function? For example, trying to run otp_plan in C++ language?

Thanks.
Best,
John

Check OS compatability

@layik and @Robinlovelace

Please confirm that for Linux and Mac the following code will run.


devtools::install_github("ITSLeeds/opentripplanner")
library(opentripplanner)
path_otp <- "~/programs/otp.jar"
url_otp <- "https://repo1.maven.org/maven2/org/opentripplanner/otp/1.3.0/otp-1.3.0-shaded.jar"
download.file(url = url_otp, destfile = path_otp, mode="wb")
path_data <- getwd()
dir.create("graphs")
dir.create("graphs/default")
download.file("https://github.com/ITSLeeds/opentripplanner/releases/download/0.1/isle-of-wight-demo.zip", 
              destfile = "isle-of-wight-demo.zip", mode="wb")
unzip("isle-of-wight-demo.zip", exdir = "graphs/default")
unlink("isle-of-wight-demo.zip")
log <- otp_build_graph(otp = path_otp, dir = path_data) 
otp_setup(otp = path_otp, dir = path_data)
otp_stop()

R OTP initialization not working

Hello!

I'm attempting to use OTP in R. I downloaded Java 8u251, and have been following the setup steps outlined in the getting started vignette. My commands entered thusfar are:

path_data <- file.path(tempdir(), "OTP")
dir.create(path_data) 
path_otp <- otp_dl_jar(path_data)
otp_dl_demo(path_data)
log1 <- otp_build_graph(otp = path_otp, dir = path_data) 

However, upon entering the log1 command, I receive the following error message:

2020-06-12 18:57:33 Basic checks completed, building graph, this may take a few minutes
The graph will be saved to []AppData\Local\Temp\RtmpasiS8P/OTP
2020-06-12 18:57:34 Failed to build graph with message:
Error occurred during initialization of VMCould not reserve enough space for 2097152KB object heap
Warning message:
In system(text, intern = TRUE) :
  running command 'java -Xmx2048M -jar "[]AppData\Local\Temp\RtmpasiS8P/OTP/otp.jar" --build "[]AppData\Local\Temp\RtmpasiS8P/OTP/graphs/default"' had status 1

I attempted setting memory to 5000 and 2500 -- did not solve the issue. How should I proceed?

Thanks much.

Allow package to work if otp is installed on system

As per the docs, this would involve supporting otp built from source: http://docs.opentripplanner.org/en/latest/Getting-OTP/#building-from-source

E.g. as demonstrated below:

system2("otp", stdout = T)
#> Warning in system2("otp", stdout = T): running command ''otp'' had status
#> 255
#> [1] "02:07:25.478 INFO (OTPMain.java:68) Nothing to do. Use --help to see available tasks."
#> attr(,"status")
#> [1] 255

Created on 2019-04-02 by the reprex package (v0.2.1)

Question about test failure

heyo! I'm new to this package and general R testing, so please excuse that off the bat. I'm running tests for your package, and I'm hitting this error:

* checking tests ... ERROR
  Running ‘testthat.R’
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
  
  ── 1. Error: (unknown) (@test_04_with_public_API.R#4)  ─────────────────────────
  Router https://api.digitransit.fi:443/routing/v1/routers/hsl does not exist. Error code 404
  Backtrace:
   1. opentripplanner::otp_connect(url = "https://api.digitransit.fi:443/routing/v1/routers/hsl")
  
  ══ testthat results  ═══════════════════════════════════════════════════════════
  [ OK: 66 | SKIPPED: 19 | WARNINGS: 5 | FAILED: 1 ]
  1. Error: (unknown) (@test_04_with_public_API.R#4) 
  
  Error: testthat unit tests failed
  In addition: Warning messages:
  1: closing unused connection 5 (<-localhost:11339) 
  2: closing unused connection 4 (<-localhost:11339) 
  Execution halted
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes in ‘inst/doc’ ... OK
* checking running R code from vignettes ... NONE
  ‘advanced_features.Rmd’using ‘UTF-8’... OK
  ‘known_issues.Rmd’using ‘UTF-8’... OK
  ‘opentripplanner.Rmd’using ‘UTF-8’... OK
  ‘prerequisites.Rmd’using ‘UTF-8’... OK
* checking re-building of vignette outputs ... OK
* DONE
Status: 1 ERROR, 1 NOTE

It looks like an issue with a router / endpoint not working - have you seen this before? I'm trying to run the tests from GitHub Actions, if that helps. Thank you!

Any way to recover routes after R crashes?

I was trying to calculate a transit travel-time matrix for use in an accessibility analysis. I have 970 centroids, so I'm generating ~944K routes. Just as I reached 100%--2 days and 7 hours of processing--R encountered an error. OTPmain is still showing up in the activity monitor, with about 14.11 GB of memory. I'm wondering if there is any way to recover those routes before I stop the instance and try to start again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.