PGROUTING  2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
trsp_core.cpp
Go to the documentation of this file.
1 #ifdef __MINGW32__
2 #include <winsock2.h>
3 #include <windows.h>
4 #endif
5 
6 #include "GraphDefinition.h"
7 #include "utils.h"
8 
9 
11  edge_t *edges,
12  unsigned int edge_count,
13  restrict_t *restricts,
14  int restrict_count,
15  int start_vertex,
16  int end_vertex,
17  bool directed,
18  bool has_reverse_cost,
20  int *path_count,
21  char **err_msg
22  )
23 {
24  try {
25 
26  std::vector<PDVI> ruleTable;
27 
28  int i, j;
29  ruleTable.clear();
30  for (i=0; i<restrict_count; i++) {
31  std::vector<int> seq;
32  seq.clear();
33  seq.push_back(restricts[i].target_id);
34  for(j = 0; j<MAX_RULE_LENGTH && restricts[i].via[j]>-1; j++)
35  {
36  seq.push_back(restricts[i].via[j]);
37  }
38  ruleTable.push_back(make_pair(restricts[i].to_cost, seq));
39  }
40 
41  GraphDefinition gdef;
42  int res = gdef.my_dijkstra(edges, edge_count, start_vertex, end_vertex, directed, has_reverse_cost, path, path_count, err_msg, ruleTable);
43 
44 
45  if (res < 0)
46  return res;
47  else
48  return EXIT_SUCCESS;
49  }
50  catch(std::exception& e) {
51  *err_msg = (char *) e.what();
52  return -1;
53  }
54  catch(...) {
55  *err_msg = (char *) "Caught unknown exception!";
56  return -1;
57  }
58 }
59 
61  edge_t *edges,
62  unsigned int edge_count,
63  restrict_t *restricts,
64  int restrict_count,
65  int start_edge,
66  double start_pos,
67  int end_edge,
68  double end_pos,
69  bool directed,
70  bool has_reverse_cost,
72  int *path_count,
73  char **err_msg
74  )
75 {
76  try {
77 
78  std::vector<PDVI> ruleTable;
79 
80  int i, j;
81  ruleTable.clear();
82  for (i=0; i<restrict_count; i++) {
83  std::vector<int> seq;
84  seq.clear();
85  seq.push_back(restricts[i].target_id);
86  for(j = 0; j<MAX_RULE_LENGTH && restricts[i].via[j]>-1; j++)
87  {
88  seq.push_back(restricts[i].via[j]);
89  }
90  ruleTable.push_back(make_pair(restricts[i].to_cost, seq));
91  }
92 
93  GraphDefinition gdef;
94  int res = gdef.my_dijkstra(edges, edge_count, start_edge, start_pos, end_edge, end_pos, directed, has_reverse_cost, path, path_count, err_msg, ruleTable);
95 
96 
97  if (res < 0)
98  return res;
99  else
100  return EXIT_SUCCESS;
101  }
102  catch(std::exception& e) {
103  *err_msg = (char *) e.what();
104  return -1;
105  }
106  catch(...) {
107  *err_msg = (char *) "Caught unknown exception!";
108  return -1;
109  }
110 }
int path_count
Definition: BDATester.cpp:51
int my_dijkstra(long start_vertex, long end_vertex, unsigned int edge_count, char **err_msg)
int edge_count
Definition: BDATester.cpp:47
edge_astar_t * edges
Definition: BDATester.cpp:46
path_element_t * path
Definition: BDATester.cpp:49
int via[5]
Definition: trsp.h:42
char * err_msg
Definition: BDATester.cpp:50
#define MAX_RULE_LENGTH
Definition: pgr_types.h:172
int trsp_node_wrapper(edge_t *edges, unsigned int edge_count, restrict_t *restricts, int restrict_count, int start_vertex, int end_vertex, bool directed, bool has_reverse_cost, path_element_t **path, int *path_count, char **err_msg)
Definition: trsp_core.cpp:10
int trsp_edge_wrapper(edge_t *edges, unsigned int edge_count, restrict_t *restricts, int restrict_count, int start_edge, double start_pos, int end_edge, double end_pos, bool directed, bool has_reverse_cost, path_element_t **path, int *path_count, char **err_msg)
Definition: trsp_core.cpp:60