PGROUTING  2.5
withPoints_dd_driver.h File Reference
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

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.

References Path_t::agg_cost, check_points(), collapse_paths(), count_tuples(), create_new_edges(), DIRECTED, eliminate_details_dd(), pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::insert_edges(), Path_t::node, pgassert, pgr_alloc(), pgr_drivingDistance(), pgr_free(), pgr_msg(), UNDIRECTED, and AssertFailedException::what().

Referenced by process().

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  /*
91  * storing on C++ containers
92  */
93  std::vector<int64_t> start_vids(
94  start_pidsArr, start_pidsArr + s_len);
95 
96  std::vector<Point_on_edge_t>
97  points(points_p, points_p + total_points);
98 
99  std::vector<pgr_edge_t> edges_to_modify(
100  edges_of_points, edges_of_points + total_edges_of_points);
101 
102  log << "start_vids :";
103  for (const auto v : start_vids) log << v << ", ";
104  /*
105  * checking here is easier than on the C code
106  */
107  int errcode = check_points(points, log);
108  if (errcode) {
109  *log_msg = strdup(log.str().c_str());
110  err << "Unexpected point(s) with same pid"
111  << " but different edge/fraction/side combination found.";
112  *err_msg = pgr_msg(err.str().c_str());
113  return;
114  }
115 
116  std::vector< pgr_edge_t > new_edges;
118  points,
119  edges_to_modify,
120  driving_side,
121  new_edges,
122  log);
123 
124  graphType gType = directed? DIRECTED: UNDIRECTED;
125 
126  std::deque< Path >paths;
127 
128  if (directed) {
129  pgrouting::DirectedGraph digraph(gType);
130  digraph.insert_edges(edges, total_edges);
131  digraph.insert_edges(new_edges);
132  paths = pgr_drivingDistance(
133  digraph, start_vids, distance, equiCost, log);
134  } else {
135  pgrouting::UndirectedGraph undigraph(gType);
136  undigraph.insert_edges(edges, total_edges);
137  undigraph.insert_edges(new_edges);
138  paths = pgr_drivingDistance(
139  undigraph, start_vids, distance, equiCost, log);
140  }
141 
142  for (auto &path : paths) {
143  log << path;
144 
145  if (!details) {
146  eliminate_details_dd(path);
147  }
148  log << path;
149  std::sort(path.begin(), path.end(),
150  [](const Path_t &l, const Path_t &r)
151  {return l.node < r.node;});
152  std::stable_sort(path.begin(), path.end(),
153  [](const Path_t &l, const Path_t &r)
154  {return l.agg_cost < r.agg_cost;});
155  log << path;
156  }
157 
158  size_t count(count_tuples(paths));
159 
160 
161  if (count == 0) {
162  *notice_msg = pgr_msg("No return values was found");
163  return;
164  }
165  *return_tuples = pgr_alloc(count, (*return_tuples));
166  *return_count = collapse_paths(return_tuples, paths);
167  *log_msg = log.str().empty()?
168  *log_msg :
169  pgr_msg(log.str().c_str());
170  *notice_msg = notice.str().empty()?
171  *notice_msg :
172  pgr_msg(notice.str().c_str());
173  } catch (AssertFailedException &except) {
174  (*return_tuples) = pgr_free(*return_tuples);
175  (*return_count) = 0;
176  err << except.what();
177  *err_msg = pgr_msg(err.str().c_str());
178  *log_msg = pgr_msg(log.str().c_str());
179  } catch (std::exception &except) {
180  (*return_tuples) = pgr_free(*return_tuples);
181  (*return_count) = 0;
182  err << except.what();
183  *err_msg = pgr_msg(err.str().c_str());
184  *log_msg = pgr_msg(log.str().c_str());
185  } catch(...) {
186  (*return_tuples) = pgr_free(*return_tuples);
187  (*return_count) = 0;
188  err << "Caught unknown exception!";
189  *err_msg = pgr_msg(err.str().c_str());
190  *log_msg = pgr_msg(log.str().c_str());
191  }
192 }
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:126
size_t collapse_paths(General_path_element_t **ret_path, const std::deque< Path > &paths)
T * pgr_free(T *ptr)
Definition: pgr_alloc.hpp:79
int check_points(std::vector< Point_on_edge_t > &points, std::ostringstream &log)
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
int64_t node
Definition: path_t.h:37
bool create_new_edges(std::vector< Point_on_edge_t > &points, const std::vector< pgr_edge_t > &edges, char driving_side, std::vector< pgr_edge_t > &new_edges)
std::deque< Path > pgr_drivingDistance(G &graph, std::vector< int64_t > start_vids, double distance, bool equicost, std::ostringstream &log)
void eliminate_details_dd(Path &path)
Definition: path_t.h:36
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:29
size_t count_tuples(const std::deque< Path > &paths)
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:68
virtual const char * what() const
Definition: pgr_assert.cpp:53
graphType
Definition: graph_enum.h:30
double agg_cost
Definition: path_t.h:40

Here is the call graph for this function:

Here is the caller graph for this function: