ropensci / opentripplanner

An R package to set up and use OpenTripPlanner (OTP) as a local or remote multimodal trip planner.
https://docs.ropensci.org/opentripplanner
GNU General Public License v3.0
78 stars 20 forks source link

[Need Help]: Unidentified error. Possibly related to json? #90

Closed RdgoVillegas closed 3 years ago

RdgoVillegas commented 3 years ago

Pre Issue Check List

Before opening a new issue please confirm you have done the following:

Problem Type

Tell us where you are having problems: Please tick all that apply:

Demo Data vs Own Data

Are you having a problem using the demo data or your own data?

Session Info

Please run sessionInfo() and paste the results here:

R version 4.0.5 (2021-03-31) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale: [1] LC_COLLATE=Spanish_Chile.1252 LC_CTYPE=Spanish_Chile.1252 LC_MONETARY=Spanish_Chile.1252 LC_NUMERIC=C [5] LC_TIME=Spanish_Chile.1252

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

other attached packages: [1] opentripplanner_0.3.1

loaded via a namespace (and not attached): [1] compiler_4.0.5 backports_1.2.1 tools_4.0.5 curl_4.3.1 checkmate_2.0.0

Your Issue

Hi ! I really appreciate your work. I've been trying to run code I wrote on november last year, where I run OTP without any issues. Unfortunately, I've been unable to run routing functions such as isochrone or plan, and I'm puzzled as to why. Even more, I haven't been able to reproduce the tutorials with the demo data.

Heres the code I've been using to run the demo:

library(opentripplanner) path_data <- file.path(tempdir(), "OTP") dir.create(path_data) path_otp <- otp_dl_jar(path_data, cache = FALSE) otp_dl_demo(path_data) log1 <- otp_build_graph(otp = path_otp, dir = path_data) log2 <- otp_setup(otp = path_otp, dir = path_data) otpcon <- otp_connect(timezone = "Europe/London") route <- otp_plan(otpcon, fromPlace = c(-1.17502, 50.64590), toPlace = c(-1.15339, 50.72266))

And the error I get is:

| | 0 % ~calculating Error in .deserialize_json(json = json, query = query, empty_array = empty_array, : Empty: no JSON found

Also, when I try otp_isochrone I get the following:

|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s Warning message: In otp_isochrone(otpcon, fromPlace = c(-1.17502, 50.6459)) : Failed to get isochrone with error:

Also, I've run this exact code in another computer without any issues, so I'm certain the issue is with my own computer.

Things I've tried to address the issue:

Any advice on the matter would be highly appreciated.

Thank you and may you have a good day!

mem48 commented 3 years ago

Sounds like a JSON parsing problem, try removing and reinstalling RcppSimdJson.

Also, can you confirm that you can get this route using the OTP web interface?

You could also try ververting to version 0.2.3 remotes::install_version("opentripplanner", "0.2.3") as this version used a different JSON parsing method.

You could also try pasting this into a web browser

http://localhost:8080/otp/routers/default/plan?fromPlace=50.64590,-1.17502&toPlace=50.72266,-1.15339&mode=CAR&maxWalkDistance=1000&arriveBy=false

Also, I notice that your time zone is in Chile, there was a previous issue where a Brazilian timezone cause problems with OTP. https://github.com/ropensci/opentripplanner/issues/85 so check if you are having similar problems

This is roughtly the command that R sends to OTP, so you woudl get a look at any unusual errors retuned by OTP.

RdgoVillegas commented 3 years ago

Thanks for your answer.

I removed and reinstalled RcppSimdJson but it made no difference. The route using OTP web interface was successful I tried remotes::install_version("opentripplanner", "0.2.3") and it worked fine. The url used in the web browser gave the expected result. Regarding the timezone, I reproduced the issue described in #85 and got the expected output

I also updated rtools, since I was having trouble updating other packages like dplyr.

Although reverting to the old version worked, I would like to identify the issue and fix it. Any suggestions?

mem48 commented 3 years ago

It could be a problem with curl try removing and reinstalling the package.

RdgoVillegas commented 3 years ago

It didn't work. I also tried to reinstall all other dependencies to no avail. The dependencies I reinstalled are: "checkmate", "data.table", "geodist", "googlePolylines", "curl", "rjson", "pbapply", "lubridate", "sf", "sfheaders", "tibble", "opentripplanner", "RcppSimdJson".

I think it would be useful to see the query created by the function, but I'm not sure how to access it. What do you think?

mem48 commented 3 years ago

This is the step where the json is parsed

https://github.com/ropensci/opentripplanner/blob/2af4df35f792772e5e4d4b82ac16220d4d7dd45f/R/otp-plan.R#L526

You could try manual creating a url and see what happens.

mem48 commented 3 years ago

Check the url is valid by testing in browser