PGROUTING  3.2
dijkstraVia_driver.h File Reference
#include <stddef.h>
#include "c_types/routes_t.h"
#include "c_types/pgr_edge_t.h"
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

◆ do_pgr_dijkstraVia()

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 90 of file dijkstraVia_driver.cpp.

100  {
101  std::ostringstream log;
102  std::ostringstream err;
103  std::ostringstream notice;
104 
105  try {
106  pgassert(total_edges != 0);
107  pgassert(!(*log_msg));
108  pgassert(!(*notice_msg));
109  pgassert(!(*err_msg));
110  pgassert(!(*return_tuples));
111  pgassert(*return_count == 0);
112 
113  graphType gType = directed? DIRECTED: UNDIRECTED;
114 
115  std::deque< Path >paths;
116  log << "\nInserting vertices into a c++ vector structure";
117  std::vector< int64_t > via_vertices(
118  via_vidsArr, via_vidsArr + size_via_vidsArr);
119 
120  if (directed) {
121  log << "\nWorking with directed Graph";
122  pgrouting::DirectedGraph digraph(gType);
123  digraph.insert_edges(data_edges, total_edges);
125  digraph,
126  via_vertices,
127  paths,
128  strict,
129  U_turn_on_edge,
130  log);
131  } else {
132  log << "\nWorking with Undirected Graph";
133  pgrouting::UndirectedGraph undigraph(gType);
134  undigraph.insert_edges(data_edges, total_edges);
136  undigraph,
137  via_vertices,
138  paths,
139  strict,
140  U_turn_on_edge,
141  log);
142  }
143 
144  size_t count(count_tuples(paths));
145 
146  if (count == 0) {
147  (*return_tuples) = NULL;
148  (*return_count) = 0;
149  notice <<
150  "No paths found";
151  *log_msg = pgr_msg(notice.str().c_str());
152  return;
153  }
154 
155  // get the space required to store all the paths
156  (*return_tuples) = pgr_alloc(count, (*return_tuples));
157  log << "\nConverting a set of paths into the tuples";
158  (*return_count) = (get_route(return_tuples, paths));
159  (*return_tuples)[count - 1].edge = -2;
160 
161  *log_msg = log.str().empty()?
162  *log_msg :
163  pgr_msg(log.str().c_str());
164  *notice_msg = notice.str().empty()?
165  *notice_msg :
166  pgr_msg(notice.str().c_str());
167  } catch (AssertFailedException &except) {
168  (*return_tuples) = pgr_free(*return_tuples);
169  (*return_count) = 0;
170  err << except.what();
171  *err_msg = pgr_msg(err.str().c_str());
172  *log_msg = pgr_msg(log.str().c_str());
173  } catch (std::exception &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(...) {
180  (*return_tuples) = pgr_free(*return_tuples);
181  (*return_count) = 0;
182  err << "Caught unknown exception!";
183  *err_msg = pgr_msg(err.str().c_str());
184  *log_msg = pgr_msg(log.str().c_str());
185  }
186 }

References count_tuples(), DIRECTED, get_route(), pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::insert_edges(), pgassert, pgr_alloc(), pgRouting::pgr_dijkstraVia(), 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
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
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
UNDIRECTED
@ UNDIRECTED
Definition: graph_enum.h:30
get_route
static size_t get_route(Routes_t **ret_path, std::deque< Path > &paths)
Definition: dijkstraVia_driver.cpp:71
graphType
graphType
Definition: graph_enum.h:30
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
pgRouting::pgr_dijkstraVia
void pgr_dijkstraVia(G &graph, const std::vector< int64_t > &via_vertices, std::deque< Path > &paths, bool strict, bool U_turn_on_edge, std::ostringstream &log)
Definition: pgr_dijkstraVia.hpp:45
AssertFailedException
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:139