PGROUTING  3.2
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
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 
31 #include <string.h>
32 #include <sstream>
33 #include "cpp_common/pgr_alloc.hpp"
34 
35 char
36 estimate_drivingSide(char driving_side) {
37  char d_side = static_cast<char>(tolower(driving_side));
38  if (!((d_side == 'r')
39  || (d_side == 'l'))) {
40  d_side = 'b';
41  }
42  return d_side;
43 }
44 
45 void
47  char *edges_sql,
48  char *points_sql,
49  char **edges_of_points_query,
50  char **edges_no_points_query) {
51  std::ostringstream edges_of_points_sql;
52  std::ostringstream edges_no_points_sql;
53 
54  edges_of_points_sql << "WITH "
55  << " edges AS (" << edges_sql << "), "
56  << " points AS (" << points_sql << ")"
57  << " SELECT DISTINCT edges.* FROM edges JOIN points ON (id = edge_id)";
58  *edges_of_points_query = pgr_msg(edges_of_points_sql.str().c_str());
59 
60  edges_no_points_sql << "WITH "
61  << " edges AS (" << edges_sql << "), "
62  << " points AS (" << points_sql << ")"
63  << " SELECT edges.*"
64  << " FROM edges"
65  << " WHERE NOT EXISTS (SELECT edge_id FROM points WHERE id = edge_id)";
66  *edges_no_points_query = pgr_msg(edges_no_points_sql.str().c_str());
67 }
68 
estimate_drivingSide
char estimate_drivingSide(char driving_side)
Definition: get_new_queries.cpp:36
pgr_msg
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:30
pgr_alloc.hpp
get_new_queries
void get_new_queries(char *edges_sql, char *points_sql, char **edges_of_points_query, char **edges_no_points_query)
Definition: get_new_queries.cpp:46
get_new_queries.h