PGROUTING  2.5
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 check_parameters (int heuristic, double factor, double epsilon)
 
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 check_parameters ( int  heuristic,
double  factor,
double  epsilon 
)

Definition at line 34 of file check_parameters.c.

Referenced by process().

37  {
38  if (heuristic > 5 || heuristic < 0) {
39  ereport(ERROR,
40  (errmsg("Unknown heuristic"),
41  errhint("Valid values: 0~5")));
42  }
43  if (factor <= 0) {
44  ereport(ERROR,
45  (errmsg("Factor value out of range"),
46  errhint("Valid values: positive non zero")));
47  }
48  if (epsilon < 1) {
49  ereport(ERROR,
50  (errmsg("Epsilon value out of range"),
51  errhint("Valid values: 1 or greater than 1")));
52  }
53 }

Here is the caller graph for this function:

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 108 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().

122  {
123  std::ostringstream log;
124  std::ostringstream notice;
125  std::ostringstream err;
126  try {
127  pgassert(!(*log_msg));
128  pgassert(!(*err_msg));
129  pgassert(!(*return_tuples));
130  pgassert(*return_count == 0);
131  pgassert(total_edges != 0);
132 
133 
134  log << "Inserting target vertices into a c++ vector structure\n";
135  std::vector< int64_t > end_vids(
136  end_vidsArr,
137  end_vidsArr + size_end_vidsArr);
138  std::vector< int64_t > start_vids(
139  start_vidsArr,
140  start_vidsArr + size_start_vidsArr);
141 
142  graphType gType = directed? DIRECTED: UNDIRECTED;
143 
144  std::deque< Path >paths;
145  if (directed) {
146  log << "Working with directed Graph\n";
148  pgrouting::extract_vertices(edges, total_edges),
149  gType);
150  digraph.insert_edges(edges, total_edges);
151  paths = pgr_astar(digraph, start_vids, end_vids,
152  heuristic, factor, epsilon, only_cost, normal);
153  } else {
154  log << "Working with Undirected Graph\n";
156  pgrouting::extract_vertices(edges, total_edges),
157  gType);
158  undigraph.insert_edges(edges, total_edges);
159  paths = pgr_astar(undigraph, start_vids, end_vids,
160  heuristic, factor, epsilon, only_cost, normal);
161  }
162 
163  size_t count(0);
164  count = count_tuples(paths);
165 
166 
167  if (count == 0) {
168  (*return_tuples) = NULL;
169  (*return_count) = 0;
170  notice <<
171  "No paths found\n";
172  *log_msg = pgr_msg(notice.str().c_str());
173  return;
174  }
175 
176  (*return_tuples) = pgr_alloc(count, (*return_tuples));
177  log << "Converting a set of paths into the tuples\n";
178  (*return_count) = (collapse_paths(return_tuples, paths));
179 
180  *log_msg = log.str().empty()?
181  *log_msg :
182  pgr_msg(log.str().c_str());
183  *notice_msg = notice.str().empty()?
184  *notice_msg :
185  pgr_msg(notice.str().c_str());
186  } catch (AssertFailedException &except) {
187  (*return_tuples) = pgr_free(*return_tuples);
188  (*return_count) = 0;
189  err << except.what();
190  *err_msg = pgr_msg(err.str().c_str());
191  *log_msg = pgr_msg(log.str().c_str());
192  } catch (std::exception &except) {
193  (*return_tuples) = pgr_free(*return_tuples);
194  (*return_count) = 0;
195  err << except.what();
196  *err_msg = pgr_msg(err.str().c_str());
197  *log_msg = pgr_msg(log.str().c_str());
198  } catch(...) {
199  (*return_tuples) = pgr_free(*return_tuples);
200  (*return_count) = 0;
201  err << "Caught unknown exception!";
202  *err_msg = pgr_msg(err.str().c_str());
203  *log_msg = pgr_msg(log.str().c_str());
204  }
205 }
static edge_t edges[22573]
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
#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: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: