pgRouting  2.2
pgRouting extends the PostGIS / PostgreSQL geospatial database to provide geospatial routing functionality.
 All Classes Functions Variables Pages
bdastar_core.cpp
1 /*PGR-MIT*****************************************************************
2 
3 * $Id$
4 *
5 * Project: pgRouting bdsp and bdastar algorithms
6 * Purpose:
7 * Author: Razequl Islam <ziboncsedu@gmail.com>
8 *
9 
10 ------
11 MIT/X license
12 
13 Permission is hereby granted, free of charge, to any person obtaining a copy
14 of this software and associated documentation files (the "Software"), to deal
15 in the Software without restriction, including without limitation the rights
16 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 copies of the Software, and to permit persons to whom the Software is
18 furnished to do so, subject to the following conditions:
19 
20 
21 The above copyright notice and this permission notice shall be included in
22 all copies or substantial portions of the Software.
23 
24 
25 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31 THE SOFTWARE.
32 
33 ********************************************************************PGR-MIT*/
34 
35 #ifdef __MINGW32__
36 #include <winsock2.h>
37 #include <windows.h>
38 #endif
39 
40 
41 #include <exception>
42 #include "BiDirAStar.h"
43 #include "bdastar.h"
44 
45 int bdastar_wrapper(edge_astar_t *edges, size_t edge_count, int maxnode,
46  int source_vertex_id, int target_vertex_id,
47  bool directed, bool has_reverse_cost,
48  path_element_t **path, size_t *path_count, char **err_msg)
49 {
50  int res;
51 
52  try {
53  BiDirAStar bdastar;
54  res = bdastar.bidir_astar(edges, edge_count, maxnode, source_vertex_id, target_vertex_id, path, path_count, err_msg);
55  // TODO this are an unused parameters have to be used
56  if (has_reverse_cost) {};
57  if (directed) {};
58  }
59  catch(std::exception& e) {
60  *err_msg = (char *) e.what();
61  return -1;
62  }
63  catch(...) {
64  *err_msg = (char *) "Caught unknown exception!";
65  return -1;
66  }
67 
68  if (res < 0)
69  return res;
70  else
71  return EXIT_SUCCESS;
72 }
73