PGROUTING  3.2
lineGraphFull_driver.cpp File Reference
#include "drivers/lineGraph/lineGraphFull_driver.h"
#include <sstream>
#include <deque>
#include <vector>
#include "dijkstra/pgr_dijkstra.hpp"
#include "cpp_common/pgr_alloc.hpp"
#include "cpp_common/pgr_assert.h"
#include "lineGraph/pgr_lineGraphFull.hpp"
#include "cpp_common/linear_directed_graph.h"
Include dependency graph for lineGraphFull_driver.cpp:

Go to the source code of this file.

Functions

void do_pgr_lineGraphFull (pgr_edge_t *data_edges, size_t total_edges, Line_graph_full_rt **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 
void get_turn_penalty_postgres_result (std::vector< Line_graph_full_rt > edge_result, Line_graph_full_rt **return_tuples, size_t &sequence)
 

Function Documentation

◆ do_pgr_lineGraphFull()

void do_pgr_lineGraphFull ( pgr_edge_t data_edges,
size_t  total_edges,
Line_graph_full_rt **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 62 of file lineGraphFull_driver.cpp.

69  {
70  std::ostringstream log;
71  std::ostringstream err;
72  std::ostringstream notice;
73  try {
74  pgassert(!(*log_msg));
75  pgassert(!(*notice_msg));
76  pgassert(!(*err_msg));
77  pgassert(!(*return_tuples));
78  pgassert(*return_count == 0);
79  pgassert(total_edges != 0);
80 
81  graphType gType = DIRECTED;
82 
83  pgrouting::DirectedGraph digraph(gType);
84  digraph.insert_edges_neg(data_edges, total_edges);
85 
86 #if 0
87  log << digraph << "\n";
88 #endif
92  pgrouting::Basic_edge > line(digraph);
93 
94  std::vector< Line_graph_full_rt > line_graph_edges;
95  line_graph_edges = line.get_postgres_results_directed();
96 
97  auto count = line_graph_edges.size();
98 
99  if (count == 0) {
100  (*return_tuples) = NULL;
101  (*return_count) = 0;
102  /* TODO change the notice message */
103  notice <<
104  "No paths found between start_vid and end_vid vertices";
105  } else {
106  size_t sequence = 0;
107 
109  line_graph_edges,
110  return_tuples,
111  sequence);
112  (*return_count) = sequence;
113  }
114 #if 1
115  log << line.log.str().c_str() << "\n\n\n";
116  log << line << "\n";
117 #endif
118  pgassert(*err_msg == NULL);
119  *log_msg = log.str().empty()?
120  *log_msg :
121  pgr_msg(log.str().c_str());
122  *notice_msg = notice.str().empty()?
123  *notice_msg :
124  pgr_msg(notice.str().c_str());
125  } catch (AssertFailedException &except) {
126  (*return_tuples) = pgr_free(*return_tuples);
127  (*return_count) = 0;
128  err << except.what();
129  *err_msg = pgr_msg(err.str().c_str());
130  *log_msg = pgr_msg(log.str().c_str());
131  } catch (std::exception &except) {
132  (*return_tuples) = pgr_free(*return_tuples);
133  (*return_count) = 0;
134  err << except.what();
135  *err_msg = pgr_msg(err.str().c_str());
136  *log_msg = pgr_msg(log.str().c_str());
137  } catch(...) {
138  (*return_tuples) = pgr_free(*return_tuples);
139  (*return_count) = 0;
140  err << "Caught unknown exception!";
141  *err_msg = pgr_msg(err.str().c_str());
142  *log_msg = pgr_msg(log.str().c_str());
143  }
144 }

References DIRECTED, get_turn_penalty_postgres_result(), pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::insert_edges_neg(), pgassert, pgr_free(), pgr_msg(), and AssertFailedException::what().

Referenced by process().

◆ get_turn_penalty_postgres_result()

void get_turn_penalty_postgres_result ( std::vector< Line_graph_full_rt edge_result,
Line_graph_full_rt **  return_tuples,
size_t &  sequence 
)

Definition at line 44 of file lineGraphFull_driver.cpp.

47  {
48  (*return_tuples) = pgr_alloc(edge_result.size(), (*return_tuples));
49 
50  for (const auto &edge : edge_result) {
51  (*return_tuples)[sequence] =
52  {edge.id,
53  edge.source,
54  edge.target,
55  edge.cost,
56  edge.edge};
57  sequence++;
58  }
59 }

References edge::cost, edge::id, pgr_alloc(), edge::source, and edge::target.

Referenced by do_pgr_lineGraphFull().

pgr_alloc
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:66
edge::cost
float8 cost
Definition: trsp.h:45
edge::target
int64 target
Definition: trsp.h:44
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
pgrouting::LinearDirectedGraph
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, Line_vertex, Basic_edge > LinearDirectedGraph
Data type to handle graph -> lineGaph transformation.
Definition: linear_directed_graph.h:55
pgrouting::Basic_edge
Definition: basic_edge.h:35
edge
Definition: trsp.h:41
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
pgrouting::graph::Pgr_lineGraphFull
Definition: pgr_lineGraphFull.hpp:47
edge::source
int64 source
Definition: trsp.h:43
graphType
graphType
Definition: graph_enum.h:30
DIRECTED
@ DIRECTED
Definition: graph_enum.h:30
get_turn_penalty_postgres_result
void get_turn_penalty_postgres_result(std::vector< Line_graph_full_rt > edge_result, Line_graph_full_rt **return_tuples, size_t &sequence)
Definition: lineGraphFull_driver.cpp:44
edge::id
int64 id
Definition: trsp.h:42
pgr_free
T * pgr_free(T *ptr)
Definition: pgr_alloc.hpp:77
pgrouting::Line_vertex
Definition: line_vertex.h:45
pgrouting::graph::Pgr_base_graph
Definition: pgr_base_graph.hpp:168
AssertFailedException
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:139