pgRouting  2.2
pgRouting extends the PostGIS / PostgreSQL geospatial database to provide geospatial routing functionality.
 All Classes Functions Variables Pages
get_new_queries.cpp
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 <sstream>
31 #include "string.h"
32 #include "./get_new_queries.h"
33 
34 
35 void
36 get_new_queries(
37  char *edges_sql,
38  char *points_sql,
39  char **edges_of_points_query,
40  char **edges_no_points_query) {
41 
42  std::ostringstream edges_of_points_sql;
43  std::ostringstream edges_no_points_sql;
44 
45  edges_of_points_sql << "WITH "
46  << " edges AS (" << edges_sql << "),"
47  << " points AS (" << points_sql << ")"
48  << " SELECT DISTINCT edges.* FROM edges JOIN points ON (id = edge_id)";
49  *edges_of_points_query = strdup(edges_of_points_sql.str().c_str());
50 
51  edges_no_points_sql << "WITH "
52  << " edges AS (" << edges_sql << "),"
53  << " points AS (" << points_sql << ")"
54  << " SELECT edges.* FROM edges WHERE NOT EXISTS (SELECT edge_id FROM points WHERE id = edge_id)";
55  *edges_no_points_query = strdup(edges_no_points_sql.str().c_str());
56 }
57 
58 
59