PGROUTING  2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
drivedist_driver.h File Reference
Include dependency graph for drivedist_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_driving_many_to_dist (pgr_edge_t *edges, size_t total_edges, int64_t *start_vertex, size_t s_len, double distance, bool directed, bool equicost, General_path_element_t **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

void do_pgr_driving_many_to_dist ( pgr_edge_t edges,
size_t  total_edges,
int64_t *  start_vertex,
size_t  s_len,
double  distance,
bool  directed,
bool  equicost,
General_path_element_t **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 82 of file drivedist_driver.cpp.

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

Referenced by process().

91  {
92  std::ostringstream log;
93  std::ostringstream err;
94  std::ostringstream notice;
95 
96  try {
97  pgassert(total_edges != 0);
98  pgassert(!(*log_msg));
99  pgassert(!(*notice_msg));
100  pgassert(!(*err_msg));
101  pgassert(!(*return_tuples));
102  pgassert(*return_count == 0);
103  pgassert((*return_tuples) == NULL);
104 
105  graphType gType = directedFlag? DIRECTED: UNDIRECTED;
106 
107  std::deque<Path> paths;
108  std::vector<int64_t> start_vertices(start_vertex, start_vertex + s_len);
109 
110  auto vertices(pgrouting::extract_vertices(data_edges, total_edges));
111 
112 #ifdef WITH_TIME
113  clock_t begin;
114  std::time_t start_t;
115  std::chrono::steady_clock::time_point begin_elapsed;
116 #endif
117 
118  if (directedFlag) {
119 #ifdef WITH_TIME
120  start_timing(start_t, begin_elapsed, begin);
121  log << "*********Creating graph at time: " << std::ctime(&start_t) << "\n";
122 #endif
123  pgrouting::DirectedGraph digraph(vertices, gType);
124 #ifdef WITH_TIME
125  end_timing(start_t, begin_elapsed, begin, log);
126 #endif
127 
128 #ifdef WITH_TIME
129  start_timing(start_t, begin_elapsed, begin);
130  log << "********Inserting edges at time: " << std::ctime(&start_t) << "\n";
131 #endif
132  digraph.insert_edges(data_edges, total_edges, true);
133 #ifdef WITH_TIME
134  end_timing(start_t, begin_elapsed, begin, log);
135 #endif
136 
137 #ifdef WITH_TIME
138  start_timing(start_t, begin_elapsed, begin);
139  log << "*******Calling the C++ call to pgr_drivingDistance: " << std::ctime(&start_t) << "\n";
140 #endif
141  paths = pgr_drivingDistance(
142  digraph, start_vertices, distance, equiCostFlag, log);
143 #ifdef WITH_TIME
144  end_timing(start_t, begin_elapsed, begin, log);
145 #endif
146  } else {
147 #ifdef WITH_TIME
148  start_timing(start_t, begin_elapsed, begin);
149  log << "******Creating graph at time: " << std::ctime(&start_t) << "\n";
150 #endif
151  pgrouting::UndirectedGraph undigraph(vertices, gType);
152 #ifdef WITH_TIME
153  end_timing(start_t, begin_elapsed, begin, log);
154 #endif
155 
156 #ifdef WITH_TIME
157  start_timing(start_t, begin_elapsed, begin);
158  log << "*******Inserting edges at time: " << std::ctime(&start_t) << "\n";
159 #endif
160  undigraph.insert_edges(data_edges, total_edges, true);
161 #ifdef WITH_TIME
162  end_timing(start_t, begin_elapsed, begin, log);
163 #endif
164 
165 #ifdef WITH_TIME
166  start_timing(start_t, begin_elapsed, begin);
167  log << "*******Calling the C++ call to pgr_drivingDistance: " << std::ctime(&start_t) << "\n";
168 #endif
169  paths = pgr_drivingDistance(
170  undigraph, start_vertices, distance, equiCostFlag, log);
171 #ifdef WITH_TIME
172  end_timing(start_t, begin_elapsed, begin, log);
173 #endif
174  }
175 
176  size_t count(count_tuples(paths));
177 
178 
179  if (count == 0) {
180  log << "\nNo return values were found";
181  *notice_msg = pgr_msg(log.str().c_str());
182  return;
183  }
184  *return_tuples = pgr_alloc(count, (*return_tuples));
185  auto trueCount(collapse_paths(return_tuples, paths));
186  *return_count = trueCount;
187 
188 
189  *log_msg = log.str().empty()?
190  *log_msg :
191  pgr_msg(log.str().c_str());
192  *notice_msg = notice.str().empty()?
193  *notice_msg :
194  pgr_msg(notice.str().c_str());
195  } catch (AssertFailedException &except) {
196  (*return_tuples) = pgr_free(*return_tuples);
197  (*return_count) = 0;
198  err << except.what();
199  *err_msg = pgr_msg(err.str().c_str());
200  *log_msg = pgr_msg(log.str().c_str());
201  } catch (std::exception &except) {
202  (*return_tuples) = pgr_free(*return_tuples);
203  (*return_count) = 0;
204  err << except.what();
205  *err_msg = pgr_msg(err.str().c_str());
206  *log_msg = pgr_msg(log.str().c_str());
207  } catch( ... ) {
208  (*return_tuples) = pgr_free(*return_tuples);
209  (*return_count) = 0;
210  err << "Caught unknown exception!";
211  *err_msg = pgr_msg(err.str().c_str());
212  *log_msg = pgr_msg(log.str().c_str());
213  }
214 }
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:75
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
std::deque< Path > pgr_drivingDistance(G &graph, std::vector< int64_t > start_vids, double distance, bool equicost, std::ostringstream &log)
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:64
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: