PGROUTING  2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
driving.cpp File Reference
#include <deque>
#include <string>
#include <vector>
Include dependency graph for driving.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void process_drivingDistance (G &graph, const std::vector< std::string > &tokens)
 

Function Documentation

void process_drivingDistance ( G &  graph,
const std::vector< std::string > &  tokens 
)

Definition at line 28 of file driving.cpp.

References equi_cost(), and pgr_drivingDistance().

Referenced by process().

28  {
29  std::string::size_type sz;
30  if (tokens[1].compare("from") != 0) {
31  std::cout << "missing 'from' kewyword\n";
32  return;
33  }
34 
35  std::vector< int64_t > sources;
36  unsigned int i_ptr = 2;
37 
38  for ( ; i_ptr < tokens.size(); ++i_ptr) {
39  if (tokens[i_ptr].compare("dist") == 0) break;
40  try {
41  uint64_t start_vertex(stol(tokens[i_ptr], &sz));
42  sources.push_back(start_vertex);
43  } catch(...) {
44  break;
45  }
46  }
47 
48  if (i_ptr == tokens.size() || tokens[i_ptr].compare("dist") != 0) {
49  std::cout << "drivDist: 'dist' kewyword not found\n";
50  return;
51  }
52 
53  if (sources.size() == 0) {
54  std::cout << "drivDist: No start value found\n";
55  return;
56  }
57 
58  ++i_ptr;
59  if (i_ptr == tokens.size()) {
60  std::cout << " 'distance' value not found\n";
61  return;
62  }
63 
64  double distance = stod(tokens[i_ptr], &sz);
65 
66  ++i_ptr;
67  bool equiCost(false);
68  if (i_ptr != tokens.size()) {
69  if (tokens[i_ptr].compare("equi") != 0) {
70  std::cout << " Unknown keyword '" << tokens[i_ptr] << "' found\n";
71  return;
72  } else {
73  equiCost = true;
74  }
75  }
76 
77  std::cout << "found " << sources.size() << "starting locations\n";
78  Pgr_dijkstra< G > fn_dijkstra;
79 
80  if (sources.size() == 1) {
81  std::cout << "Performing pgr_DrivingDistance for single source\n";
82  Path path;
83  pgr_drivingDistance(graph, path, sources[0], distance);
84  std::cout << "\t\t\tTHE OPUTPUT\n";
85  std::cout << "seq\tfrom\tnode\tedge\tcost\n";
86  path.print_path();
87  } else {
88  std::deque< Path > paths;
89  pgr_drivingDistance(graph, paths, sources, distance);
90  if (equiCost == false) {
91  std::cout << "Performing pgr_DrivingDistance for multiple sources\n";
92  std::cout << "\t\t\tTHE OPUTPUT\n";
93  std::cout << "seq\tfrom\tnode\tedge\tcost\n";
94  for (const auto &path : paths) {
95  if (sizeof(path) == 0) return; // no solution found
96  path.print_path();
97  }
98  } else {
99  std::cout << "Performing pgr_DrivingDistance for multiple sources with equi-cost\n";
100  Path path = equi_cost(paths);
101  std::cout << "\t\t\tTHE EquiCost OPUTPUT\n";
102  std::cout << "seq\tfrom\tnode\tedge\tcost\n";
103  path.print_path();
104  }
105  }
106 }
void equi_cost(std::deque< Path > &paths)
std::deque< Path > pgr_drivingDistance(G &graph, std::vector< int64_t > start_vids, double distance, bool equicost, std::ostringstream &log)

Here is the call graph for this function:

Here is the caller graph for this function: