JosiahParry / rsgeo

R bindings to the geo Rust crate
https://rsgeo.josiahparry.com/
Other
46 stars 5 forks source link

Error in `src/types.rs:91:55`? #2

Closed kadyb closed 1 year ago

kadyb commented 1 year ago

I wanted to test this package, but probably the objects conversion from {sf} doesn't work or something?

library("sf")
library("rsgeo") # 0.0.0.9000

n = 100
df = data.frame(x = runif(n, 0, 1), y = runif(n, 0, 1))
pts_sf = st_as_sf(df, coords = c("x", "y"), crs = "epsg:2180")
pts_rs = as_rsgeom(st_as_sfc(pts_sf))

euclidean_distance_matrix(pts_rs, pts_rs)
# thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ExpectedExternalPtr(list!(ExternalPtr.set_class(["point"]).set_class(["rs_POINT", "vctrs_vctr", "list"])', src/types.rs:91:55
# Error in euclidean_distance_matrix(pts_rs, pts_rs) :
#   euclidean_distance_matrix panicked.

poly_sf = st_bbox(c(xmin = 0.2, xmax = 0.8, ymax = 0.2, ymin = 0.8),
                  crs = st_crs(2180))
poly_sf = st_as_sfc(poly_sf)
poly_rs = as_rsgeom(poly_sf)
intersects_sparse(pts_rs, poly_rs)
# thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ExpectedExternalPtr(list!(ExternalPtr.set_class(["point"]).set_class(["rs_POINT", "vctrs_vctr", "list"])', src/types.rs:91:55
# Error in intersects_sparse(pts_rs, poly_rs) : intersects_sparse panicked.
JosiahParry commented 1 year ago

Thanks! This is an issue with class assignment that I didn't fully fix after a large refactor.

When did you install the package? I fixed a version of this issue quite recently.

kadyb commented 1 year ago

I installed it today using remotes::install_github("josiahparry/rsgeo").

JosiahParry commented 1 year ago

Thanks! I apologize for the inconvenience. I’m on vacation until tomorrow. I’ll review as soon as possible.

On Mon, Jun 26, 2023 at 09:00 Krzysztof Dyba @.***> wrote:

I installed it today using remotes::install_github("josiahparry/rsgeo").

— Reply to this email directly, view it on GitHub https://github.com/JosiahParry/rsgeo/issues/2#issuecomment-1607422158, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADHIKLBDO5F7J4N5P3FFHF3XNGBYPANCNFSM6AAAAAAZT7ARTU . You are receiving this because you commented.Message ID: @.***>

JosiahParry commented 1 year ago

I had forgotten to push just one file! Oops!

This should be working now. Let me know if it isnt. Sent from 25k feet in the air :)

library(sf)
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(rsgeo)
#> 
#> Attaching package: 'rsgeo'
#> The following object is masked from 'package:base':
#> 
#>     within
n = 100
df = data.frame(x = runif(n, 0, 1), y = runif(n, 0, 1))
pts_sf = st_as_sf(df, coords = c("x", "y"), crs = "epsg:2180")
pts_rs = as_rsgeom(st_as_sfc(pts_sf))

euclidean_distance_matrix(pts_rs, pts_rs)
#>              [,1]       [,2]        [,3]       [,4]       [,5]       [,6]
#>   [1,] 0.00000000 0.63483894 0.254187648 0.37472173 0.73889613 0.54648472
#>   [2,] 0.63483894 0.00000000 0.425019439 0.31895817 0.88416374 0.36036759
kadyb commented 1 year ago

Thank you very much, now it works!

JosiahParry commented 1 year ago

Thank you very much for making an issue and not giving up quietly :)

if you run into any other bugs or have other questions please make another issue

Robinlovelace commented 1 year ago

Good to see this activity, keep us posted on benchmarking findings :pray: