PGROUTING  2.5
testXYedges_driver.cpp File Reference
#include "./testXYedges_driver.h"
#include <sstream>
#include <iomanip>
#include <vector>
#include "./../../common/src/pgr_base_graph.hpp"
#include "./../../dijkstra/src/pgr_dijkstra.hpp"
#include "./../../common/src/pgr_assert.h"
Include dependency graph for testXYedges_driver.cpp:

Go to the source code of this file.

Functions

bool do_pgr_testXYedges (Pgr_edge_xy_t *data_edges, size_t total_edges, char **log_msg, char **err_msg)
 

Function Documentation

bool do_pgr_testXYedges ( Pgr_edge_xy_t data_edges,
size_t  total_edges,
char **  log_msg,
char **  err_msg 
)

Definition at line 45 of file testXYedges_driver.cpp.

References edge::cost, DIRECTED, edges, pgrouting::extract_vertices(), edge::id, pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::insert_edges(), pgassert, pgr_dijkstra(), edge::reverse_cost, edge::source, edge::target, UNDIRECTED, and AssertFailedException::what().

Referenced by process().

49  {
50  std::ostringstream log;
51  std::ostringstream err;
52  try {
53  pgassert(!(*log_msg));
54  pgassert(!(*err_msg));
55 
56  std::vector< Pgr_edge_xy_t > edges(data_edges, data_edges + total_edges);
57  auto vertices(pgrouting::extract_vertices(edges));
58 
59 
60  log << "Original: \n" <<
61  std::setprecision(32);
62  for (const auto edge : edges) {
63  log << "id = " << edge.id
64  << "\tsource = " << edge.source
65  << "\ttarget = " << edge.target
66  << "\tcost = " << edge.cost
67  << "\treverse_cost = " << edge.reverse_cost
68  << "\n\t(x1,y1) = (" << edge.x1 << "," << edge.y1 << ")"
69  << "\t(x2,y2) = (" << edge.x2 << "," << edge.y2 << ")\n";
70  }
71 
72  {
73  log << "Testing Directed , insertion using vector\n";
75  log << " - Created graph:\n";
76  log << graph;
77 
78  log << " - Inserting Edges:\n";
79  graph.insert_edges(edges);
80  log << graph;
81 
82  log << " - Can do a dijKstra:\n";
83  pgr_dijkstra(graph, 2, 3, true);
84  }
85  {
86  log << "Testing Directed , insertion using C array\n";
88  log << " - Created graph:\n";
89  log << graph;
90 
91  log << " - Inserting Edges:\n";
92  graph.insert_edges(data_edges, total_edges);
93  log << graph;
94 
95  log << " - Can do a dijKstra:\n";
96  pgr_dijkstra(graph, 2, 3, true);
97  }
98  {
99  log << "Testing Directed , creating with vertices, insertion using vector\n";
100  pgrouting::xyDirectedGraph graph(vertices, DIRECTED);
101  log << " - Created graph:\n";
102  log << graph;
103 
104  log << " - Inserting Edges:\n";
105  graph.insert_edges(edges);
106  log << graph;
107 
108  log << " - Can do a dijKstra:\n";
109  pgr_dijkstra(graph, 2, 3, true);
110  }
111  {
112  log << "Testing Directed , creating with vertices, insertion using C array\n";
113  pgrouting::xyDirectedGraph graph(vertices, DIRECTED);
114  log << " - Created graph:\n";
115  log << graph;
116 
117  log << " - Inserting Edges:\n";
118  graph.insert_edges(data_edges, total_edges);
119  log << graph;
120 
121  log << " - Can do a dijKstra:\n";
122  pgr_dijkstra(graph, 2, 3, true);
123  }
124 
125  {
126  log << "Testing Undirected , insertion using vector\n";
128  log << " - Created graph:\n";
129  log << graph;
130 
131  log << " - Inserting Edges:\n";
132  graph.insert_edges(edges);
133  log << graph;
134 
135  log << " - Can do a dijKstra:\n";
136  pgr_dijkstra(graph, 2, 3, true);
137  }
138  {
139  log << "Testing Directed , insertion using C array\n";
141  log << " - Created graph:\n";
142  log << graph;
143 
144  log << " - Inserting Edges:\n";
145  graph.insert_edges(data_edges, total_edges);
146  log << graph;
147 
148  log << " - Can do a dijKstra:\n";
149  pgr_dijkstra(graph, 2, 3, true);
150  }
151  {
152  log << "Testing Undirected , insertion using C array\n";
154  log << " - Created graph:\n";
155  log << graph;
156 
157  log << " - Inserting Edges:\n";
158  graph.insert_edges(data_edges, total_edges);
159  log << graph;
160 
161  log << " - Can do a dijKstra:\n";
162  pgr_dijkstra(graph, 2, 3, true);
163  }
164  {
165  log << "Testing Undirected , creating with vertices, insertion using vector\n";
166  pgrouting::xyUndirectedGraph graph(vertices, UNDIRECTED);
167  log << " - Created graph:\n";
168  log << graph;
169 
170  log << " - Inserting Edges:\n";
171  graph.insert_edges(edges);
172  log << graph;
173 
174  log << " - Can do a dijKstra:\n";
175  pgr_dijkstra(graph, 2, 3, true);
176  }
177 
178  *err_msg = NULL;
179  *log_msg = strdup(log.str().c_str());
180  return true;
181  } catch (AssertFailedException &except) {
182  log << except.what() << "\n";
183  *err_msg = strdup(log.str().c_str());
184  return false;
185  } catch (std::exception& except) {
186  log << except.what() << "\n";
187  *err_msg = strdup(log.str().c_str());
188  return false;
189  } catch(...) {
190  log << "Caught unknown exception!\n";
191  *err_msg = strdup(log.str().c_str());
192  return false;
193  }
194 }
static edge_t edges[22573]
float8 cost
Definition: trsp.h:35
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:126
Definition: trsp.h:31
std::deque< Path > pgr_dijkstra(G &graph, std::vector< int64_t > sources, std::vector< int64_t > targets, bool only_cost, bool normal)
long id
Definition: trsp.h:32
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
std::vector< Basic_vertex > extract_vertices(std::vector< Basic_vertex > vertices, const std::vector< pgr_edge_t > data_edges)
virtual const char * what() const
Definition: pgr_assert.cpp:53
long target
Definition: trsp.h:34
float8 reverse_cost
Definition: trsp.h:36
long source
Definition: trsp.h:33

Here is the call graph for this function:

Here is the caller graph for this function: