PGROUTING  2.6
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 87 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(), pgRouting::pgr_dijkstraVia(), pgr_free(), pgr_msg(), UNDIRECTED, and AssertFailedException::what().

Referenced by process().

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

Here is the call graph for this function:

Here is the caller graph for this function: