PGROUTING  2.5
dijkstraVia_driver.h File Reference
Include dependency graph for dijkstraVia_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_dijkstraVia (pgr_edge_t *data_edges, size_t total_edges, int64_t *via_vidsArr, size_t size_via_vidsArr, bool directed, bool strict, bool U_turn_on_edge, Routes_t **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

void do_pgr_dijkstraVia ( pgr_edge_t data_edges,
size_t  total_edges,
int64_t *  via_vidsArr,
size_t  size_via_vidsArr,
bool  directed,
bool  strict,
bool  U_turn_on_edge,
Routes_t **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 165 of file dijkstraVia_driver.cpp.

References count_tuples(), DIRECTED, get_route(), pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::insert_edges(), pgassert, pgr_alloc(), pgr_dijkstraViaVertex(), pgr_free(), pgr_msg(), UNDIRECTED, and AssertFailedException::what().

Referenced by process().

175  {
176  std::ostringstream log;
177  std::ostringstream err;
178  std::ostringstream notice;
179 
180  try {
181  pgassert(total_edges != 0);
182  pgassert(!(*log_msg));
183  pgassert(!(*notice_msg));
184  pgassert(!(*err_msg));
185  pgassert(!(*return_tuples));
186  pgassert(*return_count == 0);
187 
188  graphType gType = directed? DIRECTED: UNDIRECTED;
189 
190  std::deque< Path >paths;
191  log << "\nInserting vertices into a c++ vector structure";
192  std::vector< int64_t > via_vertices(
193  via_vidsArr, via_vidsArr + size_via_vidsArr);
194 
195  if (directed) {
196  log << "\nWorking with directed Graph";
197  pgrouting::DirectedGraph digraph(gType);
198  digraph.insert_edges(data_edges, total_edges);
200  digraph,
201  via_vertices,
202  paths,
203  strict,
204  U_turn_on_edge,
205  log);
206  } else {
207  log << "\nWorking with Undirected Graph";
208  pgrouting::UndirectedGraph undigraph(gType);
209  undigraph.insert_edges(data_edges, total_edges);
211  undigraph,
212  via_vertices,
213  paths,
214  strict,
215  U_turn_on_edge,
216  log);
217  }
218 
219  size_t count(count_tuples(paths));
220 
221  if (count == 0) {
222  (*return_tuples) = NULL;
223  (*return_count) = 0;
224  notice <<
225  "No paths found";
226  *log_msg = pgr_msg(notice.str().c_str());
227  return;
228  }
229 
230  // get the space required to store all the paths
231  (*return_tuples) = pgr_alloc(count, (*return_tuples));
232  log << "\nConverting a set of paths into the tuples";
233  (*return_count) = (get_route(return_tuples, paths));
234  (*return_tuples)[count - 1].edge = -2;
235 
236  *log_msg = log.str().empty()?
237  *log_msg :
238  pgr_msg(log.str().c_str());
239  *notice_msg = notice.str().empty()?
240  *notice_msg :
241  pgr_msg(notice.str().c_str());
242  } catch (AssertFailedException &except) {
243  (*return_tuples) = pgr_free(*return_tuples);
244  (*return_count) = 0;
245  err << except.what();
246  *err_msg = pgr_msg(err.str().c_str());
247  *log_msg = pgr_msg(log.str().c_str());
248  } catch (std::exception &except) {
249  (*return_tuples) = pgr_free(*return_tuples);
250  (*return_count) = 0;
251  err << except.what();
252  *err_msg = pgr_msg(err.str().c_str());
253  *log_msg = pgr_msg(log.str().c_str());
254  } catch(...) {
255  (*return_tuples) = pgr_free(*return_tuples);
256  (*return_count) = 0;
257  err << "Caught unknown exception!";
258  *err_msg = pgr_msg(err.str().c_str());
259  *log_msg = pgr_msg(log.str().c_str());
260  }
261 }
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:126
void pgr_dijkstraViaVertex(G &graph, const std::vector< int64_t > via_vertices, std::deque< Path > &paths, bool strict, bool U_turn_on_edge, std::ostringstream &log)
T * pgr_free(T *ptr)
Definition: pgr_alloc.hpp:79
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
static size_t get_route(Routes_t **ret_path, const std::deque< Path > &paths)
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

Here is the call graph for this function:

Here is the caller graph for this function: