PGROUTING  2.6
astar_driver.h File Reference
Include dependency graph for astar_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_astarManyToMany (Pgr_edge_xy_t *data_edges, size_t total_edges, int64_t *start_vidsArr, size_t size_start_vidsArr, int64_t *end_vidsArr, size_t size_end_vidsArr, bool directed, int heuristic, double factor, double epsilon, bool only_cost, bool normal, General_path_element_t **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

void do_pgr_astarManyToMany ( Pgr_edge_xy_t data_edges,
size_t  total_edges,
int64_t *  start_vidsArr,
size_t  size_start_vidsArr,
int64_t *  end_vidsArr,
size_t  size_end_vidsArr,
bool  directed,
int  heuristic,
double  factor,
double  epsilon,
bool  only_cost,
bool  normal,
General_path_element_t **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 84 of file astar_driver.cpp.

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

Referenced by process().

98  {
99  std::ostringstream log;
100  std::ostringstream notice;
101  std::ostringstream err;
102  try {
103  pgassert(!(*log_msg));
104  pgassert(!(*err_msg));
105  pgassert(!(*return_tuples));
106  pgassert(*return_count == 0);
107  pgassert(total_edges != 0);
108 
109 
110  log << "Inserting target vertices into a c++ vector structure\n";
111  std::vector< int64_t > end_vids(
112  end_vidsArr,
113  end_vidsArr + size_end_vidsArr);
114  std::vector< int64_t > start_vids(
115  start_vidsArr,
116  start_vidsArr + size_start_vidsArr);
117 
118  graphType gType = directed? DIRECTED: UNDIRECTED;
119 
120  std::deque< Path >paths;
121  if (directed) {
122  log << "Working with directed Graph\n";
124  pgrouting::extract_vertices(edges, total_edges),
125  gType);
126  digraph.insert_edges(edges, total_edges);
127  paths = pgr_astar(digraph, start_vids, end_vids,
128  heuristic, factor, epsilon, only_cost, normal);
129  } else {
130  log << "Working with Undirected Graph\n";
132  pgrouting::extract_vertices(edges, total_edges),
133  gType);
134  undigraph.insert_edges(edges, total_edges);
135  paths = pgr_astar(undigraph, start_vids, end_vids,
136  heuristic, factor, epsilon, only_cost, normal);
137  }
138 
139  size_t count(0);
140  count = count_tuples(paths);
141 
142 
143  if (count == 0) {
144  (*return_tuples) = NULL;
145  (*return_count) = 0;
146  notice <<
147  "No paths found\n";
148  *log_msg = pgr_msg(notice.str().c_str());
149  return;
150  }
151 
152  (*return_tuples) = pgr_alloc(count, (*return_tuples));
153  log << "Converting a set of paths into the tuples\n";
154  (*return_count) = (collapse_paths(return_tuples, paths));
155 
156  *log_msg = log.str().empty()?
157  *log_msg :
158  pgr_msg(log.str().c_str());
159  *notice_msg = notice.str().empty()?
160  *notice_msg :
161  pgr_msg(notice.str().c_str());
162  } catch (AssertFailedException &except) {
163  (*return_tuples) = pgr_free(*return_tuples);
164  (*return_count) = 0;
165  err << except.what();
166  *err_msg = pgr_msg(err.str().c_str());
167  *log_msg = pgr_msg(log.str().c_str());
168  } catch (std::exception &except) {
169  (*return_tuples) = pgr_free(*return_tuples);
170  (*return_count) = 0;
171  err << except.what();
172  *err_msg = pgr_msg(err.str().c_str());
173  *log_msg = pgr_msg(log.str().c_str());
174  } catch(...) {
175  (*return_tuples) = pgr_free(*return_tuples);
176  (*return_count) = 0;
177  err << "Caught unknown exception!";
178  *err_msg = pgr_msg(err.str().c_str());
179  *log_msg = pgr_msg(log.str().c_str());
180  }
181 }
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:77
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
std::deque< Path > pgr_astar(G &graph, std::vector< int64_t > sources, std::vector< int64_t > targets, int heuristic, double factor, double epsilon, bool only_cost, bool normal)
std::vector< Basic_vertex > extract_vertices(std::vector< Basic_vertex > vertices, const std::vector< pgr_edge_t > data_edges)
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

Here is the call graph for this function:

Here is the caller graph for this function: