diff --git a/DESCRIPTION b/DESCRIPTION index 0e4485232..971427016 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dodgr Title: Distances on Directed Graphs -Version: 0.2.15.008 +Version: 0.2.15.009 Authors@R: c( person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre")), person("Andreas", "Petutschnig", role = "aut"), diff --git a/R/match-points.R b/R/match-points.R index 92ededa0d..a6fccce1f 100644 --- a/R/match-points.R +++ b/R/match-points.R @@ -150,8 +150,15 @@ match_pts_to_graph <- function (graph, xy, connected = FALSE) { graph <- graph [, gr_cols] names (graph) <- names (gr_cols) + res <- rcpp_points_to_edges_par (graph, xy) + index <- seq (nrow (xy)) + # rcpp_points_index is 0-indexed, so ... - rcpp_points_to_edges_par (graph, xy) + 1L + graph_index <- as.integer (res [index]) + 1L + # edge_dist not yet used here; see #103 + # edge_dist <- res [index + nrow (xy)] + + return (graph_index) } #' match_points_to_graph diff --git a/codemeta.json b/codemeta.json index c38551499..b9552dc1c 100644 --- a/codemeta.json +++ b/codemeta.json @@ -7,7 +7,7 @@ "codeRepository": "https://github.com/ATFutures/dodgr", "issueTracker": "https://github.com/ATFutures/dodgr/issues", "license": "https://spdx.org/licenses/GPL-3.0", - "version": "0.2.15.008", + "version": "0.2.15.009", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", diff --git a/src/match-points.cpp b/src/match-points.cpp index eecca7a36..6bf63b94c 100644 --- a/src/match-points.cpp +++ b/src/match-points.cpp @@ -94,6 +94,7 @@ struct OneEdgeIndex : public RcppParallel::Worker { double dmin = INFINITE_DOUBLE; long int jmin = INFINITE_INT; + int which_side = INFINITE_INT; for (size_t j = 0; j < nxy; j++) { @@ -137,9 +138,12 @@ struct OneEdgeIndex : public RcppParallel::Worker { dmin = dij; jmin = static_cast (j); + which_side = which_side_of_line (xfr [j], yfr [j], + xto [j], yto [j], pt_x [i], pt_y [i]); } } index [i] = static_cast (jmin); + index [i + npts] = which_side * dmin; } } @@ -206,7 +210,7 @@ Rcpp::NumericVector rcpp_points_to_edges_par (const Rcpp::DataFrame &graph, const size_t nxy = static_cast (graph.nrow ()), npts = static_cast (pts.nrow ()); - Rcpp::NumericVector index (npts); + Rcpp::NumericVector index (npts * 2L); // Create parallel worker OneEdgeIndex one_edge_indx (RcppParallel::RVector (ptx),