@@ -31,12 +31,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31
31
#include "c_common/postgres_connection.h"
32
32
33
33
#include "c_types/path_rt.h"
34
- #include "c_types/point_on_edge_t.h"
35
34
#include "c_common/debug_macro.h"
36
35
#include "c_common/e_report.h"
37
36
#include "c_common/time_msg.h"
38
-
39
- #include "c_common/trsp_pgget.h"
40
37
#include "drivers/withPoints/get_new_queries.h"
41
38
#include "drivers/withPoints/withPoints_driver.h"
42
39
@@ -69,26 +66,6 @@ process(
69
66
char * notice_msg = NULL ;
70
67
char * err_msg = NULL ;
71
68
72
- size_t size_start_pidsArr = 0 ;
73
- int64_t * start_pidsArr = NULL ;
74
-
75
- size_t size_end_pidsArr = 0 ;
76
- int64_t * end_pidsArr = NULL ;
77
-
78
- II_t_rt * combinations = NULL ;
79
- size_t total_combinations = 0 ;
80
-
81
- Point_on_edge_t * points = NULL ;
82
- size_t total_points = 0 ;
83
- pgr_get_points (points_sql , & points , & total_points , & err_msg );
84
- throw_error (err_msg , points_sql );
85
-
86
- #ifndef NDEBUG
87
- size_t i ;
88
- for (i = 0 ; i < total_points ; i ++ ) {
89
- PGR_DBG ("%ld " , points [i ].pid );
90
- }
91
- #endif
92
69
char * edges_of_points_query = NULL ;
93
70
char * edges_no_points_query = NULL ;
94
71
get_new_queries (
@@ -97,61 +74,13 @@ process(
97
74
& edges_no_points_query );
98
75
99
76
100
- Edge_t * edges_of_points = NULL ;
101
- size_t total_edges_of_points = 0 ;
102
-
103
- Edge_t * edges = NULL ;
104
- size_t total_edges = 0 ;
105
-
106
- if (normal ) {
107
- pgr_get_edges (edges_of_points_query , & edges_of_points , & total_edges_of_points , true, false, & err_msg );
108
- throw_error (err_msg , edges_of_points_query );
109
- pgr_get_edges (edges_no_points_query , & edges , & total_edges , true, false, & err_msg );
110
- throw_error (err_msg , edges_no_points_query );
111
-
112
- if (starts && ends ) {
113
- start_pidsArr = pgr_get_bigIntArray (& size_start_pidsArr , starts , false, & err_msg );
114
- throw_error (err_msg , "While getting start vids" );
115
- end_pidsArr = pgr_get_bigIntArray (& size_end_pidsArr , ends , false, & err_msg );
116
- throw_error (err_msg , "While getting end vids" );
117
- } else if (combinations_sql ) {
118
- pgr_get_combinations (combinations_sql , & combinations , & total_combinations , & err_msg );
119
- throw_error (err_msg , combinations_sql );
120
- }
121
- } else {
122
- pgr_get_edges (edges_of_points_query , & edges_of_points , & total_edges_of_points , false, false, & err_msg );
123
- throw_error (err_msg , edges_of_points_query );
124
- pgr_get_edges (edges_no_points_query , & edges , & total_edges , false, false, & err_msg );
125
- throw_error (err_msg , edges_no_points_query );
126
-
127
- end_pidsArr = pgr_get_bigIntArray (& size_end_pidsArr , starts , false, & err_msg );
128
- throw_error (err_msg , "While getting start vids" );
129
- start_pidsArr = pgr_get_bigIntArray (& size_start_pidsArr , ends , false, & err_msg );
130
- throw_error (err_msg , "While getting end vids" );
131
- }
132
-
133
-
134
- pfree (edges_of_points_query );
135
- pfree (edges_no_points_query );
136
- edges_of_points_query = NULL ;
137
- edges_no_points_query = NULL ;
138
-
139
- if ((total_edges + total_edges_of_points ) == 0 ) {
140
- pgr_SPI_finish ();
141
- return ;
142
- }
143
-
144
77
clock_t start_t = clock ();
145
-
146
- do_pgr_withPoints (
147
- edges , total_edges ,
148
- points , total_points ,
149
- edges_of_points , total_edges_of_points ,
150
-
151
- combinations , total_combinations ,
152
-
153
- start_pidsArr , size_start_pidsArr ,
154
- end_pidsArr , size_end_pidsArr ,
78
+ pgr_do_withPoints (
79
+ edges_no_points_query ,
80
+ points_sql ,
81
+ edges_of_points_query ,
82
+ combinations_sql ,
83
+ starts , ends ,
155
84
156
85
driving_side [0 ],
157
86
details ,
@@ -178,16 +107,10 @@ process(
178
107
179
108
pgr_global_report (log_msg , notice_msg , err_msg );
180
109
181
- #if 0
182
110
if (log_msg ) pfree (log_msg );
183
111
if (notice_msg ) pfree (notice_msg );
184
112
if (err_msg ) pfree (err_msg );
185
- if (edges ) pfree (edges );
186
- if (points ) pfree (points );
187
- if (edges_of_points ) pfree (edges_of_points );
188
- if (start_pidsArr ) pfree (start_pidsArr );
189
- if (end_pidsArr ) pfree (end_pidsArr );
190
- #endif
113
+
191
114
pgr_SPI_finish ();
192
115
}
193
116
@@ -199,10 +122,8 @@ _pgr_withpoints(PG_FUNCTION_ARGS) {
199
122
FuncCallContext * funcctx ;
200
123
TupleDesc tuple_desc ;
201
124
202
- /**********************************************************************/
203
125
Path_rt * result_tuples = 0 ;
204
126
size_t result_count = 0 ;
205
- /**********************************************************************/
206
127
207
128
if (SRF_IS_FIRSTCALL ()) {
208
129
MemoryContext oldcontext ;
@@ -249,8 +170,6 @@ _pgr_withpoints(PG_FUNCTION_ARGS) {
249
170
& result_count );
250
171
}
251
172
252
- /**********************************************************************/
253
-
254
173
funcctx -> max_calls = result_count ;
255
174
256
175
funcctx -> user_fctx = result_tuples ;
@@ -275,15 +194,6 @@ _pgr_withpoints(PG_FUNCTION_ARGS) {
275
194
Datum * values ;
276
195
bool * nulls ;
277
196
278
- /**********************************************************************/
279
- // OUT seq BIGINT,
280
- // OUT path_seq,
281
- // OUT node BIGINT,
282
- // OUT edge BIGINT,
283
- // OUT cost FLOAT,
284
- // OUT agg_cost FLOAT)
285
-
286
-
287
197
values = palloc (8 * sizeof (Datum ));
288
198
nulls = palloc (8 * sizeof (bool ));
289
199
@@ -301,7 +211,6 @@ _pgr_withpoints(PG_FUNCTION_ARGS) {
301
211
values [5 ] = Int64GetDatum (result_tuples [funcctx -> call_cntr ].edge );
302
212
values [6 ] = Float8GetDatum (result_tuples [funcctx -> call_cntr ].cost );
303
213
values [7 ] = Float8GetDatum (result_tuples [funcctx -> call_cntr ].agg_cost );
304
- /**********************************************************************/
305
214
306
215
tuple = heap_form_tuple (tuple_desc , values , nulls );
307
216
result = HeapTupleGetDatum (tuple );
@@ -310,4 +219,3 @@ _pgr_withpoints(PG_FUNCTION_ARGS) {
310
219
SRF_RETURN_DONE (funcctx );
311
220
}
312
221
}
313
-
0 commit comments