PGROUTING
3.2
isPlanar.c
Go to the documentation of this file.
1
/*PGR-GNU*****************************************************************
2
File: isPlanar.c
3
4
Generated with Template by:
5
Copyright (c) 2020 pgRouting developers
6
Mail:
[email protected]
7
8
Function's developer:
9
Copyright (c) 2020 Himanshu Raj
10
Mail:
[email protected]
11
12
13
------
14
15
This program is free software; you can redistribute it and/or modify
16
it under the terms of the GNU General Public License as published by
17
the Free Software Foundation; either version 2 of the License, or
18
(at your option) any later version.
19
20
This program is distributed in the hope that it will be useful,
21
but WITHOUT ANY WARRANTY; without even the implied warranty of
22
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
GNU General Public License for more details.
24
25
You should have received a copy of the GNU General Public License
26
along with this program; if not, write to the Free Software
27
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28
29
********************************************************************PGR-GNU*/
30
31
#include <stdbool.h>
32
#include "
c_common/postgres_connection.h
"
33
#include "utils/array.h"
34
35
#include "
c_common/debug_macro.h
"
36
#include "
c_common/e_report.h
"
37
#include "
c_common/time_msg.h
"
38
39
#include "
c_common/edges_input.h
"
40
41
#include "
drivers/planar/isPlanar_driver.h
"
42
PGDLLEXPORT Datum
_pgr_isplanar
(PG_FUNCTION_ARGS);
43
PG_FUNCTION_INFO_V1
(
_pgr_isplanar
);
44
45
static
bool
46
process
(
47
char
*edges_sql
48
) {
49
bool
planarity =
false
;
50
pgr_SPI_connect
();
51
52
pgr_edge_t
*edges = NULL;
53
size_t
total_edges = 0;
54
55
pgr_get_edges
(edges_sql, &edges, &total_edges);
56
57
if
(total_edges == 0) {
58
pgr_SPI_finish
();
59
return
(
false
);
60
}
61
62
clock_t start_t = clock();
63
char
*log_msg = NULL;
64
char
*notice_msg = NULL;
65
char
*err_msg = NULL;
66
67
68
planarity =
do_pgr_isPlanar
(
69
edges,
70
total_edges,
71
72
&log_msg,
73
¬ice_msg,
74
&err_msg);
75
76
time_msg
(
" processing pgr_isPlanar"
, start_t, clock());
77
78
pgr_global_report
(log_msg, notice_msg, err_msg);
79
80
if
(edges)
81
pfree(edges);
82
if
(log_msg)
83
pfree(log_msg);
84
if
(notice_msg)
85
pfree(notice_msg);
86
if
(err_msg)
87
pfree(err_msg);
88
89
pgr_SPI_finish
();
90
91
return
planarity;
92
}
93
94
PGDLLEXPORT Datum
_pgr_isplanar
(PG_FUNCTION_ARGS) {
95
/**********************************************************************/
96
/*
97
pgr_isPlanar(
98
edge_sql TEXT)
99
*/
100
/**********************************************************************/
101
PG_RETURN_BOOL(
process
(text_to_cstring(PG_GETARG_TEXT_P(0))));
102
/**********************************************************************/
103
}
isPlanar_driver.h
time_msg.h
postgres_connection.h
pgr_edge_t
Definition:
pgr_edge_t.h:37
pgr_SPI_connect
void pgr_SPI_connect(void)
Definition:
postgres_connection.c:82
do_pgr_isPlanar
bool do_pgr_isPlanar(pgr_edge_t *data_edges, size_t total_edges, char **log_msg, char **notice_msg, char **err_msg)
Definition:
isPlanar_driver.cpp:45
pgr_SPI_finish
void pgr_SPI_finish(void)
Definition:
postgres_connection.c:71
e_report.h
debug_macro.h
PG_FUNCTION_INFO_V1
PG_FUNCTION_INFO_V1(_pgr_isplanar)
pgr_get_edges
void pgr_get_edges(char *edges_sql, pgr_edge_t **edges, size_t *total_edges)
basic edge_sql
Definition:
edges_input.c:711
_pgr_isplanar
PGDLLEXPORT Datum _pgr_isplanar(PG_FUNCTION_ARGS)
Definition:
isPlanar.c:94
time_msg
void time_msg(char *msg, clock_t start_t, clock_t end_t)
Definition:
time_msg.c:32
process
static bool process(char *edges_sql)
Definition:
isPlanar.c:46
edges_input.h
pgr_global_report
void pgr_global_report(char *log, char *notice, char *err)
notice & error
Definition:
e_report.c:93
src
planar
isPlanar.c
Generated on Tue May 25 2021 15:09:47 for PGROUTING by
1.8.17