PGROUTING  2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
get_new_queries.cpp
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 File: get_new_queries.cpp
3 
4 Generated with Template by:
5 Copyright (c) 2015 pgRouting developers
6 Mail: project@pgrouting.org
7 
8 Function's developer:
9 Copyright (c) 2015 Celia Virginia Vergara Castillo
10 Mail:
11 
12 ------
13 
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18 
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23 
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 
28 ********************************************************************PGR-GNU*/
29 
30 #include "./get_new_queries.h"
31 #include <string.h>
32 #include <sstream>
33 
34 char
35 estimate_drivingSide(char driving_side) {
36  char d_side = static_cast<char>(tolower(driving_side));
37  if (!((d_side == 'r')
38  || (d_side == 'l'))) {
39  d_side = 'b';
40  }
41  return d_side;
42 }
43 
44 void
46  char *edges_sql,
47  char *points_sql,
48  char **edges_of_points_query,
49  char **edges_no_points_query) {
50  std::ostringstream edges_of_points_sql;
51  std::ostringstream edges_no_points_sql;
52 
53  edges_of_points_sql << "WITH "
54  << " edges AS (" << edges_sql << "), "
55  << " points AS (" << points_sql << ")"
56  << " SELECT DISTINCT edges.* FROM edges JOIN points ON (id = edge_id)";
57  *edges_of_points_query = strdup(edges_of_points_sql.str().c_str());
58 
59  edges_no_points_sql << "WITH "
60  << " edges AS (" << edges_sql << "), "
61  << " points AS (" << points_sql << ")"
62  << " SELECT edges.*"
63  << " FROM edges"
64  << " WHERE NOT EXISTS (SELECT edge_id FROM points WHERE id = edge_id)";
65  *edges_no_points_query = strdup(edges_no_points_sql.str().c_str());
66 }
67 
char estimate_drivingSide(char driving_side)
void get_new_queries(char *edges_sql, char *points_sql, char **edges_of_points_query, char **edges_no_points_query)