PGROUTING  3.2
withPoints_dd_driver.h File Reference
#include <stddef.h>
#include "c_types/point_on_edge_t.h"
#include "c_types/pgr_edge_t.h"
#include "c_types/general_path_element_t.h"
Include dependency graph for withPoints_dd_driver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void do_pgr_many_withPointsDD (pgr_edge_t *edges, size_t total_edges, Point_on_edge_t *points_p, size_t total_points, pgr_edge_t *edges_of_points, size_t total_edges_of_points, int64_t *start_pids_arr, size_t s_len, double distance, bool directed, char driving_side, bool details, bool equiCost, General_path_element_t **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

◆ do_pgr_many_withPointsDD()

void do_pgr_many_withPointsDD ( pgr_edge_t edges,
size_t  total_edges,
Point_on_edge_t points_p,
size_t  total_points,
pgr_edge_t edges_of_points,
size_t  total_edges_of_points,
int64_t *  start_pids_arr,
size_t  s_len,
double  distance,
bool  directed,
char  driving_side,
bool  details,
bool  equiCost,
General_path_element_t **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 59 of file withPoints_dd_driver.cpp.

75  {
76  std::ostringstream log;
77  std::ostringstream notice;
78  std::ostringstream err;
79  try {
80  pgassert(!(*log_msg));
81  pgassert(!(*notice_msg));
82  pgassert(!(*err_msg));
83  pgassert(!(*return_tuples));
84  pgassert((*return_count) == 0);
85  pgassert(edges);
86  pgassert(points_p);
87  pgassert(edges_of_points);
88  pgassert(start_pidsArr);
89 
90 
92  std::vector<Point_on_edge_t>(
93  points_p,
94  points_p + total_points),
95  std::vector< pgr_edge_t >(
96  edges_of_points,
97  edges_of_points + total_edges_of_points),
98  true,
99  driving_side,
100  directed);
101 
102  if (pg_graph.has_error()) {
103  log << pg_graph.get_log();
104  err << pg_graph.get_error();
105  *log_msg = pgr_msg(log.str().c_str());
106  *err_msg = pgr_msg(err.str().c_str());
107  return;
108  }
109 
110 
111 
112  /*
113  * storing on C++ containers
114  */
115  std::vector<int64_t> start_vids(
116  start_pidsArr, start_pidsArr + s_len);
117 
118 
119  graphType gType = directed? DIRECTED: UNDIRECTED;
120 
121  std::deque< Path >paths;
122 
123  if (directed) {
124  pgrouting::DirectedGraph digraph(gType);
125  digraph.insert_edges(edges, total_edges);
126  digraph.insert_edges(pg_graph.new_edges());
127  paths = pgr_drivingDistance(
128  digraph, start_vids, distance, equiCost, log);
129  } else {
130  pgrouting::UndirectedGraph undigraph(gType);
131  undigraph.insert_edges(edges, total_edges);
132  undigraph.insert_edges(pg_graph.new_edges());
133 
134  paths = pgr_drivingDistance(
135  undigraph, start_vids, distance, equiCost, log);
136  }
137 
138  for (auto &path : paths) {
139  log << path;
140 
141  if (!details) {
142  pg_graph.eliminate_details_dd(path);
143  }
144  log << path;
145  std::sort(path.begin(), path.end(),
146  [](const Path_t &l, const Path_t &r)
147  {return l.node < r.node;});
148  std::stable_sort(path.begin(), path.end(),
149  [](const Path_t &l, const Path_t &r)
150  {return l.agg_cost < r.agg_cost;});
151  log << path;
152  }
153 
154  size_t count(count_tuples(paths));
155 
156 
157  if (count == 0) {
158  *notice_msg = pgr_msg("No return values was found");
159  return;
160  }
161  *return_tuples = pgr_alloc(count, (*return_tuples));
162  *return_count = collapse_paths(return_tuples, paths);
163  *log_msg = log.str().empty()?
164  *log_msg :
165  pgr_msg(log.str().c_str());
166  *notice_msg = notice.str().empty()?
167  *notice_msg :
168  pgr_msg(notice.str().c_str());
169  } catch (AssertFailedException &except) {
170  (*return_tuples) = pgr_free(*return_tuples);
171  (*return_count) = 0;
172  err << except.what();
173  *err_msg = pgr_msg(err.str().c_str());
174  *log_msg = pgr_msg(log.str().c_str());
175  } catch (std::exception &except) {
176  (*return_tuples) = pgr_free(*return_tuples);
177  (*return_count) = 0;
178  err << except.what();
179  *err_msg = pgr_msg(err.str().c_str());
180  *log_msg = pgr_msg(log.str().c_str());
181  } catch(...) {
182  (*return_tuples) = pgr_free(*return_tuples);
183  (*return_count) = 0;
184  err << "Caught unknown exception!";
185  *err_msg = pgr_msg(err.str().c_str());
186  *log_msg = pgr_msg(log.str().c_str());
187  }
188 }

References collapse_paths(), count_tuples(), DIRECTED, pgrouting::Pg_points_graph::eliminate_details_dd(), pgrouting::Pgr_messages::get_error(), pgrouting::Pgr_messages::get_log(), pgrouting::Pgr_messages::has_error(), pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::insert_edges(), pgrouting::Pg_points_graph::new_edges(), pgassert, pgr_alloc(), pgrouting::pgr_drivingDistance(), pgr_free(), pgr_msg(), UNDIRECTED, and AssertFailedException::what().

Referenced by process().

pgr_alloc
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:66
count_tuples
size_t count_tuples(const std::deque< Path > &paths)
Definition: basePath_SSEC.cpp:387
Path_t
Definition: path_t.h:36
pgr_msg
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:30
AssertFailedException::what
virtual const char * what() const
Definition: pgr_assert.cpp:67
pgrouting::Pg_points_graph
Definition: pgr_withPoints.hpp:40
collapse_paths
size_t collapse_paths(General_path_element_t **ret_path, const std::deque< Path > &paths)
Definition: basePath_SSEC.cpp:310
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
UNDIRECTED
@ UNDIRECTED
Definition: graph_enum.h:30
graphType
graphType
Definition: graph_enum.h:30
pgrouting::pgr_drivingDistance
std::deque< Path > pgr_drivingDistance(G &graph, std::vector< int64_t > start_vids, double distance, bool equicost, std::ostringstream &log)
Definition: pgr_dijkstra.hpp:68
DIRECTED
@ DIRECTED
Definition: graph_enum.h:30
pgr_free
T * pgr_free(T *ptr)
Definition: pgr_alloc.hpp:77
pgrouting::graph::Pgr_base_graph
Definition: pgr_base_graph.hpp:168
AssertFailedException
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:139