Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), : java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "<parameter1>" is null #379

Closed
olyakhr opened this issue Mar 21, 2024 · 39 comments

Comments

@olyakhr
Copy link

olyakhr commented Mar 21, 2024

Hi.
I have a problem with r5r - it returned this error : Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), : java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "" is null

The example:
#after setting my data path

r5r_core <- setup_r5(data_path)

points <- data.frame(
id = c(3734, 4022, 4023, 4020, 4021, 4028, 4029, 3999, 3998, 3997, 3996, 3994, 3993,
3992, 3991, 3990, 5748, 5854, 5855, 5856, 5857, 5852, 5853, 5858, 5859, 3773, 3772, 3771, 3777, 4287),
lon = c(-106.63285, -106.587697, -106.697736, -106.622418, -106.696677, -106.630835, -106.630821, -106.655869, -106.626625, -106.625929,
-106.623491, -106.721627, -106.619764, -106.617238, -106.631328, -106.631841, -106.57495, -106.623922, -106.62319, -106.633762,
-106.637495, -106.626792, -106.619894, -106.632252, -106.665375, -106.650022, -106.646864, -106.646677, -106.647942, -106.667418),
lat = c(52.172675, 52.104141, 52.152466, 52.08689, 52.150729, 52.200773, 52.198936, 52.187524, 52.163646, 52.163813, 52.163837, 52.122962,
52.14869, 52.148997, 52.138316, 52.138285, 52.1228, 52.180132, 52.10033, 52.100315, 52.10032, 52.168615, 52.180139, 52.100154, 52.100283,
52.145904, 52.145909, 52.145789, 52.145779, 52.125854)
)

head(points)

central_bus_station <- points[30,]

time_intervals <- seq(0, 100, 10)

mode <- c("BUS", "WALK")
max_walk_time <- 20 # in minutes
max_trip_duration <- 100 # in minutes
time_window <- 120 # in minutes
departure_datetime <- as.POSIXct("29-01-2023 14:40:00",
format = "%d-%m-%Y %H:%M:%S")

iso_sask <- r5r::isochrone(r5r_core,
origins = central_bus_station,
mode = mode,
cutoffs = time_intervals,
sample_size = 1,
departure_datetime = departure_datetime,
max_walk_time = max_walk_time,
max_trip_duration = max_trip_duration,
time_window = time_window,
progress = FALSE)

#here it gives me an Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), : java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "" is null

print(is.null(r5r_core))
print(is.null(mode))
print(is.null(cutoffs))
print(is.null(sample_size))
print(is.null(departure_datetime))
print(is.null(max_walk_time))
print(is.null(max_trip_duration))
print(is.null(time_window))
print(is.null(origins))

#shows no error (null values) with these parameters

Situation report

r5r::r5r_sitrep()
$r5r_package_version
[1] ‘1.1.0’

$r5_jar_version
[1] "7.0"

$java_version
[1] "21.0.2"

$set_memory
[1] "-Xmx4G"

$session_info
R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.0

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Regina
tzcode source: internal

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

other attached packages:
[1] interp_1.1-6 ggplot2_3.5.0 sf_1.0-15 r5r_1.1.0

loaded via a namespace (and not attached):
[1] gtable_0.3.4 htmlwidgets_1.6.4 devtools_2.4.5 remotes_2.4.2.1 processx_3.8.3 rJava_1.0-11 callr_3.7.5 vctrs_0.6.5 tools_4.3.2 ps_1.7.6 generics_0.1.3 curl_5.2.0 tibble_3.2.1
[14] proxy_0.4-27 fansi_1.0.6 pkgconfig_2.0.3 KernSmooth_2.23-22 checkmate_2.3.1 data.table_1.15.99 desc_1.4.3 lifecycle_1.0.4 compiler_4.3.2 stringr_1.5.1 deldir_2.0-2 munsell_0.5.0 httpuv_1.6.14
[27] htmltools_0.5.7 usethis_2.2.3 class_7.3-22 later_1.3.2 pillar_1.9.0 urlchecker_1.0.1 ellipsis_0.3.2 classInt_0.4-10 cachem_1.0.8 sessioninfo_1.2.2 mime_0.12 tidyselect_1.2.0 digest_0.6.34
[40] stringi_1.8.3 dplyr_1.1.4 purrr_1.0.2 fastmap_1.1.1 grid_4.3.2 colorspace_2.1-0 cli_3.6.2 magrittr_2.0.3 pkgbuild_1.4.3 utf8_1.2.4 e1071_1.7-14 withr_3.0.0 backports_1.4.1
[53] scales_1.3.0 promises_1.2.1 memoise_2.0.1 shiny_1.8.0 miniUI_0.1.1.1 profvis_0.3.8 rlang_1.1.3 Rcpp_1.0.12 xtable_1.8-4 glue_1.7.0 DBI_1.2.2 pkgload_1.3.4 R6_2.5.1
[66] fs_1.6.3 units_0.8-5

@rafapereirabr
Copy link
Member

This is because the stable version of r5r on CRAN v1.1.0 used JDK v11, and you have JDK v21 installed in your machine. I realize there is some inconsistency in github documentation about this.

Please install the dev version of r5r and it should work.

utils::remove.packages('r5r')
devtools::install_github("ipeaGIT/r5r", subdir = "r-package")

@olyakhr
Copy link
Author

olyakhr commented Mar 21, 2024

Yup, I installed JDK 21, because with JDK 11 it returns Error in setup_r5(data_path) : could not find function "setup_r5"

@rafapereirabr
Copy link
Member

does it work now with the dev version of r5r ?

@mrosmann
Copy link

mrosmann commented Apr 2, 2024

Hi,

I am having a similar error when creating a travel time matrix. The r5r core sets up correctly but when I run the travel_time_matrix() function it gives:

Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), :
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "" is null

Do you know why this may be happening? I have installed the dev version of r5r with JDK 21.

@rafapereirabr
Copy link
Member

Please install the dev version of r5r and it should work.

If you have JDK v21 installed, please make sure you are using the dev version of r5r.

utils::remove.packages('r5r')
devtools::install_github("ipeaGIT/r5r", subdir = "r-package")

@mrosmann
Copy link

mrosmann commented Apr 3, 2024

Hi, I am using the dev version, still getting the same error.

@rafapereirabr
Copy link
Member

@mrosmann , could please run r5r::r5r_sitrep() and share the output in a comment below ?

@mrosmann
Copy link

mrosmann commented Apr 5, 2024

Sure, here it is:

$r5r_package_version
[1] ‘1.1.0.9000’

$r5_jar_version
[1] "7.0"

$java_version
[1] "21.0.2"

$set_memory
[1] "-Xmx4G"

$session_info
R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.0

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

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

other attached packages:
[1] r5r_1.1.0.9000 data.table_1.15.4 readxl_1.4.3

loaded via a namespace (and not attached):
[1] backports_1.4.1 utf8_1.2.4 cellranger_1.1.0 magrittr_2.0.3 glue_1.7.0 tibble_3.2.1
[7] pkgconfig_2.0.3 rJava_1.0-11 lifecycle_1.0.4 cli_3.6.2 fansi_1.0.6 vctrs_0.6.5
[13] compiler_4.3.3 rstudioapi_0.15.0 tools_4.3.3 checkmate_2.3.1 pillar_1.9.0 rlang_1.1.3

Thank you!

@rafapereirabr
Copy link
Member

We've made a couple important edits to the package in the last couple of days. Could you please install latest dev version and run the code below?

# install latest dev version
utils::remove.packages('r5r')
devtools::install_github("ipeaGIT/r5r", subdir = "r-package")


library(r5r)

# build transport network
data_path <- system.file("extdata/poa", package = "r5r")
r5r_core <- setup_r5(data_path)

# load origin/destination points
points <- read.csv(file.path(data_path, "poa_points_of_interest.csv"))

departure_datetime <- as.POSIXct(
  "13-05-2019 14:00:00",
  format = "%d-%m-%Y %H:%M:%S"
)

ttm <- travel_time_matrix(
  r5r_core,
  origins = points,
  destinations = points,
  mode = c("WALK", "TRANSIT"),
  departure_datetime = departure_datetime,
  max_trip_duration = 60
)
head(ttm)

@mrosmann
Copy link

mrosmann commented Apr 8, 2024

Hi, I installed the newest dev version of r5r, and when I ran the code you provided, the network set up correctly and generated the matrix. However, running my own code still gives the error:

Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), :
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "" is null

Do you think this could be an issue with the .pbf file I am using?

@rafapereirabr
Copy link
Member

Ok, so the problem is not with r5r code or the installation of the package, it is likely related to some issue in your code or data. Can you share a minimal reproducible example of your data?

@mrosmann
Copy link

mrosmann commented Apr 8, 2024

Hi,

Thanks for getting back to me so quickly. We are trying to create a simple OD matrix for census block centroids to grocery store retailers. I've attached my code and the various CSV files being used. In the file OSM_DIR, I have included the entire state of Massachusetts .pbf file, downloaded today:

BOSTON_census_block_groups.csv
BOSTON_SNAP_retailer_data.csv

install.packages("rJava")
rJava::.jinit()
options(java.parameters = '-Xmx8G')

library(readxl)
library(data.table)

data1 <- read.csv("/Boston/BOSTON_census_block_groups.csv", colClasses = "character")

blocks_origin <- subset(data1, select = c(id,long,lat))

origin_data <- as.data.frame(blocks_origin)
origin_data$lon <- as.numeric(origin_data$long)
origin_data$lat <- as.numeric(origin_data$lat)

data2 <- read.csv("/Boston/BOSTON_SNAP_retailer_data.csv", colClasses = "character")
blocks_destination <- subset(data2, select = c(id,long,lat))

destination_data <- as.data.frame(blocks_destination)
destination_data$lon <- as.numeric(destination_data$long)
destination_data$lat <- as.numeric(destination_data$lat)

library(r5r)
path <- "/Boston/OSM_DIR"
r5r_core_boston <- setup_r5(data_path = path, verbose = TRUE)

mat <- travel_time_matrix(
r5r_core_boston,
origins = origin_data,
destinations = destination_data,
mode = c("WALK"),
max_trip_duration = 60
)

write.csv(mat, "boston_block_walk_snap.csv")

@rafapereirabr
Copy link
Member

You said you get this error message below, but when does the error occurr? Is it when you try to build the network with setup_r5() ?

Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), :
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "" is null

@rafapereirabr
Copy link
Member

For the record, I have now downloaded the OSM data from geofabrik and managed to run the analysis without a problem.

ps. You do not need to run rJava::.jinit() to use r5r.

@mrosmann
Copy link

mrosmann commented Apr 8, 2024

Hi,

Thanks for getting back to me. The error occurs when I run the travel_time_matrix() function. setup_r5() runs fine. Odd that it works for you. Do you think it could have something to do with the version of JDK I have installed? I have 21 installed because it would not work with JDK 11. I am also on a Mac, so that could be causing some weird issues.

@rafapereirabr
Copy link
Member

There used to be be an incompatibility problem between Java 11 and some macOs processors. (see #315), and I believe this problem was solved with Java 21, but now I'm not sure. Could you please try to replicate your analysis and code in another computer (either on Windows or Linux) ?

@mrosmann
Copy link

mrosmann commented Apr 9, 2024

Hi! We've actually just managed to run the file on a Mac, but still having the same parameter 1 is null error on a Windows computer. Do you know anything that this could be attributed to or potentially some recommendations for troubleshooting this?

@rafapereirabr
Copy link
Member

If I understand it correctly,

  • you can run the reproducible example from the r5r package on both Mac and on Windows
  • now you're also able to run the analysis with your own data on a Mac but NOT on Windows.

It's hard to tell what could be creating the issue. We will be lauching a new stable version v2.0.0 on CRAN in the next few days. I would recommend you try running your analysis again with the new version once it is released.

@mrosmann
Copy link

mrosmann commented Apr 9, 2024

Yes, that is correct. We are also experiencing an issue where it will work correctly on a Mac for one city, but when reproducing the exact same analysis (with the same code on the same computer), for a different city, will not work. Not really sure what this could be coming from as the code is virtually the same, only the .pbf files and .csv files are changing. Do you know what this paramater1 could be in reference to?

Thank you for mentioning the new version -- will be sure to keep an eye out for it in the next few days.

@mrosmann
Copy link

mrosmann commented Apr 9, 2024

We also noticed that when this error occurs, the network.dat file does not compile -- even though it says it does in the R terminal

@rafapereirabr
Copy link
Member

We also noticed that when this error occurs, the network.dat file does not compile -- even though it says it does in the R terminal

I would suspect this occurrs because you do not have permission to edit/write files to the data path, but it is difficult to tell without a reprex.

@mrosmann
Copy link

Hi. Working on getting a reprex to you. We've been able to set up a few networks on one computer with some success. As far as I can tell, I am not changing any file permissions each time I run the file. I have just been uninstalling rJava and r5r every time the script is run and eventually it works. I've noticed that when the network sets up correctly it appears in the global environment and I am able to click on and expand the variable RStudio. If it sets up incorrectly it still appears in the global environments menu but when clicked on gives the error "RcallMethod: attempt to call a method of a NULL object."

@rafapereirabr
Copy link
Member

The new stable version of r5r v2.0 is now on CRAN. Please install this version and see if the error persists.

@mrosmann
Copy link

Hi -- thanks so much. It's definitely working a lot better and we are able to set up a few networks of smaller US states. When we try to run bigger states (i.e. Texas), the error persists. It is working much better now though, and we are able to run on Mac and Windows.

@dhersz
Copy link
Collaborator

dhersz commented Apr 11, 2024

Hi @mrosmann. Have you tried running setup_r5() with verbose = TRUE in the cases where you're not being able to create the network? Perhaps it help understanding the issue a bit better.

@richardneilbelcher
Copy link

Hi @rafapereirabr I was getting this issue as well when running street_network_to_sf but not when running setup_r5 (which executed with no errors). The error happened when there was nothing inside the .pbf file (i was looping over a bigger grid area to export the roads and some grids had none). In this case setup_r5 still produces two files but no network file. See attached an example of the files.
HP40_pathconnect.osm.zip

@j-bnsch
Copy link

j-bnsch commented May 8, 2024

Ran into the same error and at least in my case the issue seems to have been the network file - the one from geofabrik worked fine but after doing some cleaning in qGIS/saving as shp/converting back to osm.pbf in JOSM, the network.dat didn't get created during setup anymore. Downloading a smaller network using JOSM and cleaning/exporting as osm.pbf directly from there works. I guess the format needed is quite specific and gets messed up easily?

@rafapereirabr
Copy link
Member

Ran into the same error and at least in my case the issue seems to have been the network file - the one from geofabrik worked fine but after doing some cleaning in qGIS/saving as shp/converting back to osm.pbf in JOSM, the network.dat didn't get created during setup anymore. Downloading a smaller network using JOSM and cleaning/exporting as osm.pbf directly from there works. I guess the format needed is quite specific and gets messed up easily?

Hi @j-bnsch . R5 requires OSM tags to work. Afaik, these tags are lost in the process of cleaning in qGIS/saving as shp/converting back to osm.pbf. Hence, it is strongly recommended that any edits to OSM that is done using software that works directly on the .pbf file, such as JOSM and Osmium (see rosmium)

@rafapereirabr
Copy link
Member

Hi @rafapereirabr I was getting this issue as well when running street_network_to_sf but not when running setup_r5 (which executed with no errors). The error happened when there was nothing inside the .pbf file (i was looping over a bigger grid area to export the roads and some grids had none). In this case setup_r5 still produces two files but no network file. See attached an example of the files. HP40_pathconnect.osm.zip

Hi @richardneilbelcher , I guess if there was nothing inside the .pbf file, the cause of the error :)

@randl068
Copy link

randl068 commented May 14, 2024

I'm having the same issue, running setup_r5 works fine, using jdk 21 and the newest dev release, but running detailed_itineraries returns

Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), : java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "<parameter1>" is null

This is being run on a folder with GTFS and pbf files that ran fine on the old JDK 11 version.

I did notice as did someone else that setup_r5 completes but does not compile network.dat, this is true for me even if I start with a fresh .pbf from geofabrik.

Any ideas on what I can do to resolve this?

--

EDIT: I retried this using the non-dev version of r5r v2 and a new geofabrik download and did not experience the same issue, with network.dat writing just fine.

@rafapereirabr
Copy link
Member

I'm having the same issue, running setup_r5 works fine, using jdk 21 and the newest dev release, but running detailed_itineraries returns

Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), : java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "<parameter1>" is null

This is being run on a folder with GTFS and pbf files that ran fine on the old JDK 11 version.

I did notice as did someone else that setup_r5 completes but does not compile network.dat, this is true for me even if I start with a fresh .pbf from geofabrik.

Any ideas on what I can do to resolve this?

--

EDIT: I retried this using the non-dev version of r5r v2 and did not experience the same issue, with network.dat writing just fine.

@randl068, can you please confirm you can run the reprex below using the stable version of r5r v2.0?

# install latest dev version
utils::remove.packages('r5r')
devtools::install_github("ipeaGIT/r5r", subdir = "r-package")


library(r5r)

# build transport network
data_path <- system.file("extdata/poa", package = "r5r")
r5r_core <- setup_r5(data_path)

# load origin/destination points
points <- read.csv(file.path(data_path, "poa_points_of_interest.csv"))

departure_datetime <- as.POSIXct(
  "13-05-2019 14:00:00",
  format = "%d-%m-%Y %H:%M:%S"
)

ttm <- travel_time_matrix(
  r5r_core,
  origins = points,
  destinations = points,
  mode = c("WALK", "TRANSIT"),
  departure_datetime = departure_datetime,
  max_trip_duration = 60
)
head(ttm)

@randl068
Copy link

I receive the following error in the installation:

Warning in file.rename(instdir, final_instdir) :
cannot rename file 'C:/Users/hrandle/AppData/Local/R/win-library/4.3/00LOCK-r5r/00new/r5r' to 'C:/Users/hrandle/AppData/Local/R/win-library/4.3/r5r', reason 'Access is denied'
ERROR: moving to final location failed

  • removing 'C:/Users/hrandle/AppData/Local/R/win-library/4.3/r5r'
    Warning messages:
    1: In file.copy(savedcopy, lib, recursive = TRUE) :
    problem copying C:\Users\hrandle\AppData\Local\R\win-library\4.3\00LOCK\Rcpp\libs\x64\Rcpp.dll to C:\Users\hrandle\AppData\Local\R\win-library\4.3\Rcpp\libs\x64\Rcpp.dll: Permission denied
    2: In file.copy(savedcopy, lib, recursive = TRUE) :
    problem copying C:\Users\hrandle\AppData\Local\R\win-library\4.3\00LOCK\fansi\libs\x64\fansi.dll to C:\Users\hrandle\AppData\Local\R\win-library\4.3\fansi\libs\x64\fansi.dll: Permission denied
    3: In file.copy(savedcopy, lib, recursive = TRUE) :
    problem copying C:\Users\hrandle\AppData\Local\R\win-library\4.3\00LOCK\vctrs\libs\x64\vctrs.dll to C:\Users\hrandle\AppData\Local\R\win-library\4.3\vctrs\libs\x64\vctrs.dll: Permission denied
    4: In file.copy(savedcopy, lib, recursive = TRUE) :
    problem copying C:\Users\hrandle\AppData\Local\R\win-library\4.3\00LOCK\rlang\libs\x64\rlang.dll to C:\Users\hrandle\AppData\Local\R\win-library\4.3\rlang\libs\x64\rlang.dll: Permission denied
    5: In file.copy(savedcopy, lib, recursive = TRUE) :
    problem copying C:\Users\hrandle\AppData\Local\R\win-library\4.3\00LOCK\glue\libs\x64\glue.dll to C:\Users\hrandle\AppData\Local\R\win-library\4.3\glue\libs\x64\glue.dll: Permission denied
    6: In file.copy(savedcopy, lib, recursive = TRUE) :
    problem copying C:\Users\hrandle\AppData\Local\R\win-library\4.3\00LOCK\cli\libs\x64\cli.dll to C:\Users\hrandle\AppData\Local\R\win-library\4.3\cli\libs\x64\cli.dll: Permission denied
    7: In file.copy(savedcopy, lib, recursive = TRUE) :
    problem copying C:\Users\hrandle\AppData\Local\R\win-library\4.3\00LOCK\curl\libs\x64\curl.dll to C:\Users\hrandle\AppData\Local\R\win-library\4.3\curl\libs\x64\curl.dll: Permission denied
    8: In i.p(...) :
    installation of package ‘C:/Users/LODA56~1/Temp/6/RtmpsbKwJw/file912067425b89/r5r_2.0.09999.tar.gz’ had non-zero exit status

@rafapereirabr
Copy link
Member

How did you try to install the package?
It seems {r5r} you are trying to install the package in a directory "C:/Users/hrandle/AppData/Local/R/win-library/4.3/r5r" to which you do not have permission rights

@randl068
Copy link

Another small update: while the non dev version was able to write network.dat, actually running detailed itineraries returns a table with 0 records immediately.

@rafapereirabr
Copy link
Member

could you please provide you r5r::r5r_sitrep() and a reproducible example of your data? It is quite difficult to debug without more information

@randl068
Copy link

randl068 commented May 14, 2024

Yes of course, here is r5r_sitrep:

$r5r_package_version
[1] ‘2.0’

$r5_jar_version
[1] "7.1"

$java_version
[1] "21"

$set_memory
[1] "-Xmx50G"

$session_info
R version 4.2.3 (2023-03-15 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

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

other attached packages:
 [1] r5r_2.0           scales_1.3.0      ggh4x_0.2.6       lehdr_1.1.1       cowplot_1.1.1     tidytransit_1.5.0 lubridate_1.9.2  
 [8] forcats_1.0.0     stringr_1.5.0     dplyr_1.1.1       purrr_1.0.1       readr_2.1.4       tidyr_1.3.0       tibble_3.2.1     
[15] tidyverse_2.0.0   gtfstools_1.2.0   bit64_4.0.5       bit_4.0.5         ggplot2_3.5.0     data.table_1.14.8 sf_1.0-12        
[22] rJava_1.0-11      devtools_2.4.5    usethis_2.2.3    

loaded via a namespace (and not attached):
 [1] httr_1.4.7         pkgload_1.3.4      vroom_1.6.1        shiny_1.8.0        remotes_2.4.2.1    sessioninfo_1.2.2  pillar_1.9.0      
 [8] backports_1.4.1    glue_1.6.2         uuid_1.1-0         digest_0.6.35      promises_1.2.1     checkmate_2.1.0    colorspace_2.1-0  
[15] htmltools_0.5.8.1  httpuv_1.6.14      pkgconfig_2.0.3    geodist_0.0.8      s2_1.1.4           xtable_1.8-4       later_1.3.2       
[22] tigris_2.0.1       tzdb_0.3.0         timechange_0.2.0   proxy_0.4-27       farver_2.1.1       generics_0.1.3     ellipsis_0.3.2    
[29] cachem_1.0.8       withr_3.0.0        cli_3.6.1          crayon_1.5.2       magrittr_2.0.3     mime_0.12          memoise_2.0.1     
[36] fs_1.6.3           fansi_1.0.4        class_7.3-21       pkgbuild_1.4.3     textshaping_0.3.6  profvis_0.3.8      tools_4.2.3       
[43] hms_1.1.3          lifecycle_1.0.4    munsell_0.5.0      compiler_4.2.3     e1071_1.7-13       systemfonts_1.0.5  sfheaders_0.4.2   
[50] rlang_1.1.3        classInt_0.4-9     units_0.8-1        grid_4.2.3         rstudioapi_0.15.0  rappdirs_0.3.3     htmlwidgets_1.6.4 
[57] miniUI_0.1.1.1     labeling_0.4.3     wk_0.8.0           gtable_0.3.4       curl_5.0.0         DBI_1.2.2          R6_2.5.1          
[64] fastmap_1.1.1      utf8_1.2.3         ragg_1.2.5         KernSmooth_2.23-20 gtfsio_1.1.1       stringi_1.7.12     Rcpp_1.0.10       
[71] vctrs_0.6.1        tidyselect_1.2.0   urlchecker_1.0.1  

and here is the script in question

library(r5r)

try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))

r5r_core <- r5r::setup_r5("Q:\\FCAST\\tools_scripts\\r5r\\MSP_Current",verbose = F,
                     overwrite = T)
id <- c("start","end")
lat <- c(44.96517204358236,44.968815862418225)
lon <- c(-93.20391034568037,-93.32679063325018)
points <- data.frame(cbind(id,lat,lon)) %>% 
  mutate(lat = as.numeric(lat),
         lon = as.numeric(lon))
di <- r5r::detailed_itineraries(r5r_core,
                          origins = points[1,],
                          destinations = points[2,],
                          mode = c("WALK","TRANSIT"),
                          departure_datetime = as.POSIXct("2019-10-09 08:00:00",format = "%Y-%m-%d %H:%M:%S"),
                          time_window = 1,
                          verbose = F)
print(paste0("Transit travel time between offices is ",di$total_duration[1]," minutes"))
r5r::stop_r5()
rJava::.jgc(R.gc = TRUE)

@rafapereirabr
Copy link
Member

@randl068,

It is not clear to me from your messages when the error happens. Is it :

  1. when you try to install the stable version v2.0
  2. when you run the code in the reprex below?
  3. when you run the code you shared with your own data?

can you please confirm you can run the reprex below using the stable version of r5r v2.0?

# install stable version
utils::remove.packages('r5r')
install.packages("r5r")


library(r5r)

# build transport network
data_path <- system.file("extdata/poa", package = "r5r")
r5r_core <- setup_r5(data_path)

# load origin/destination points
points <- read.csv(file.path(data_path, "poa_points_of_interest.csv"))

departure_datetime <- as.POSIXct(
  "13-05-2019 14:00:00",
  format = "%d-%m-%Y %H:%M:%S"
)

ttm <- travel_time_matrix(
  r5r_core,
  origins = points,
  destinations = points,
  mode = c("WALK", "TRANSIT"),
  departure_datetime = departure_datetime,
  max_trip_duration = 60
)
head(ttm)

@randl068
Copy link

I believe I have resolved all three errors by installing the stable release to a local library, using new OSM .pbfs, and completely reinstalling some packages.

@rafapereirabr
Copy link
Member

ok, so from all of the discussion above, it seems all of the errors have been caused by problems in the OSM .pbf data files and not due to an issue in {r5r}. I'm closing this issue for now but I'm happy to help address any pending problems on a separate issue.

ps. We have also learned that error messages in Java are not very informative, but we always knew that lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants