vrpRouting  0.3
vehicles_input.c
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 File: vehicles_input.c
3 
4 Copyright (c) 2016 pgRouting developers
6 
7 Developer:
8 Copyright (c) 2016 Celia Virginia Vergara Castillo
9 
10 ------
11 
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16 
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 
26  ********************************************************************PGR-GNU*/
27 
29 
30 #include <limits.h>
31 #include <float.h>
32 
33 
34 #include "c_types/column_info_t.h"
35 #include "c_types/vehicle_t.h"
36 
38 
39 #ifdef PROFILE
40 #include "c_common/time_msg.h"
41 #include "c_common/debug_macro.h"
42 #endif
43 
44 /*
45 .. pgr_pickDeliver start
46 
47 A ``SELECT`` statement that returns the following columns:
48 
49 ::
50 
51  id, capacity, [speed,]
52  s_id, s_tw_open, s_tw_close, [s_service,]
53  [e_id, e_tw_open, e_tw_close, e_service]
54 
55 
56 
57 ================== =================== ================ ================================================
58 Column Type Default Description
59 ================== =================== ================ ================================================
60 **id** |ANY-INTEGER| Identifier of the vehicle
61 **capacity** |ANY-NUMERICAL| Capacity of the vehicle
62 **speed** |ANY-NUMERICAL| `1` Average speed of the vehicle.
63 **s_id** |ANY-INTEGER| The node identifier of the starting location, must match a node identifier in the matrix table.
64 **s_tw_open** |ANY-NUMERICAL| `0` The time, relative to 0, when the starting location opens.
65  When `s_tw_open` column exist then `s_tw_close` column is expected
66  Default value when (`s_tw_open`, s_tw_close) columns do not exist
67 **s_tw_close** |ANY-NUMERICAL| `INFINITY` The time, relative to 0, when the starting location closes.
68  When `s_tw_close` column exist then `e_tw_open` column is expected
69  Default value when `(s_tw_open, s_tw_close)` columns do not exist
70 **s_service** |ANY-NUMERICAL| `0` The duration of the loading at the starting location.
71 **e_id** |ANY-INTEGER| `s_id` The node identifier of the ending location, must match a node identifier in the matrix table.
72 **e_tw_open** |ANY-NUMERICAL| `s_tw_open` The time, relative to 0, when the ending location opens.
73  When `e_tw_open` column exist then `e__tw_close` column is expected
74  Default value when (`e_tw_open`, e_tw_close) columns do not exist
75 **e_tw_close** |ANY-NUMERICAL| `s_tw_close` The time, relative to 0, when the ending location closes.
76  When `e_tw_close` column exist then `e_tw_open` column is expected
77  Default value when `(e_tw_open`, e_tw_close)` columns do not exist
78 **e_service** |ANY-NUMERICAL| `s_service` The duration of the unloading at the ending location.
79 ================== =================== ================ ================================================
80 
81 Throws:
82 * When column `id` is missing
83 * When column `capacity` is missing
84 * When column `s_id` is missing
85 * When column `s_tw_open` exists but not `s_tw_close`
86 * When column `s_tw_close`exists but not `s_tw_open`
87 * When column `e_tw_open` exists but not `e_tw_close`
88 * When column `e_tw_close`exists but not `e_tw_open`
89 
90 .. pgr_pickDeliver end
91 .. pgr_pickDeliverEuclidean start
92 
93 A ``SELECT`` statement that returns the following columns:
94 
95 ::
96 
97  id, capacity, [speed,]
98  s_x, s_y, s_tw_open, s_tw_close, [s_service,]
99  [e_x, e_y, e_tw_open, e_tw_close, e_service]
100 
101 ================== =================== ================ ================================================
102 Column Type Default Description
103 ================== =================== ================ ================================================
104 **id** |ANY-INTEGER| Identifier of the vehicle
105 **capacity** |ANY-NUMERICAL| Capacity of the vehicle
106 **speed** |ANY-NUMERICAL| `1` Average speed of the vehicle.
107 **s_x** |ANY-NUMERICAL| :math:`x` value of the coordinate of the starting location.
108 **s_y** |ANY-NUMERICAL| :math:`y` value of the coordinate of the starting location.
109 **s_tw_open** |ANY-NUMERICAL| `0` The time, relative to 0, when the starting location opens.
110  When `s_tw_open` column exist then `s_tw_close` column is expected
111  Default value when (`s_tw_open`, s_tw_close) columns do not exist
112 **s_tw_close** |ANY-NUMERICAL| `INFINITY` The time, relative to 0, when the starting location closes.
113  When `s_tw_close` column exist then `e_tw_open` column is expected
114  Default value when `(s_tw_open, s_tw_close)` columns do not exist
115 **s_service** |ANY-NUMERICAL| `0` The duration of the loading at the starting location.
116 **e_tw_open** |ANY-NUMERICAL| `s_tw_open` The time, relative to 0, when the ending location opens.
117  When `e_tw_open` column exist then `e__tw_close` column is expected
118  Default value when (`e_tw_open`, e_tw_close) columns do not exist
119 **e_tw_close** |ANY-NUMERICAL| `s_tw_close` The time, relative to 0, when the ending location closes.
120  When `e_tw_close` column exist then `e_tw_open` column is expected
121  Default value when `(e_tw_open`, e_tw_close)` columns do not exist
122 **e_service** |ANY-NUMERICAL| `s_service` The duration of the loading at the ending location.
123 **e_x** |ANY-NUMERICAL| `s_x` :math:`x` value of the coordinate of the ending location.
124  Default value when `(e_x, e_y)` columns do not exist
125  Default value when `e_y` column does not exist
126 **e_y** |ANY-NUMERICAL| `s_y` :math:`y` value of the coordinate of the ending location.
127  When `e_y` column exist then `e_x` column is expected
128  Default value when `(e_x, e_y)` columns do not exist
129 ================== =================== ================ ================================================
130 
131 Throws:
132 * When column `id` is missing
133 * When column `capacity` is missing
134 * When column `s_x` is missing
135 * When column `s_y` is missing
136 * When column `s_tw_open` exists but not `s_tw_close`
137 * When column `s_tw_close`exists but not `s_tw_open`
138 * When column `e_y` exists but not `e_x`
139 * When column `e_x` exists but not `e_y`
140 * When column `e_tw_open` exists but not `e_tw_close`
141 * When column `e_tw_close`exists but not `e_tw_open`
142 
143 .. pgr_pickDeliverEuclidean end
144 
145 .. vrp_pickDeliver start
146 
147 A ``SELECT`` statement that returns the following columns:
148 
149 ::
150 
151  id, capacity, [speed,]
152  s_id, s_tw_open, s_tw_close, [s_service,]
153  [e_id, e_tw_open, e_tw_close, e_service]
154 
155 
156 
157 ================== =================== ================ ================================================
158 Column Type Default Description
159 ================== =================== ================ ================================================
160 **id** |ANY-INTEGER| Identifier of the vehicle
161 **capacity** |ANY-NUMERICAL| Capacity of the vehicle
162 **stops** |ANY-NUMERICAL| `[]` Array of shipments identifiers indicating an initial solution
163 **s_id** |ANY-INTEGER| The node identifier of the starting location, must match a node identifier in the matrix table.
164 **s_tw_open** |ANY-NUMERICAL| `0` The time, relative to 0, when the starting location opens.
165  When `s_tw_open` column exist then `s_tw_close` column is expected
166  Default value when (`s_tw_open`, s_tw_close) columns do not exist
167 **s_tw_close** |ANY-NUMERICAL| `INFINITY` The time, relative to 0, when the starting location closes.
168  When `s_tw_close` column exist then `e_tw_open` column is expected
169  Default value when `(s_tw_open, s_tw_close)` columns do not exist
170 **s_service** |ANY-NUMERICAL| `0` The duration of the loading at the starting location.
171 **e_id** |ANY-INTEGER| `s_id` The node identifier of the ending location, must match a node identifier in the matrix table.
172 **e_tw_open** |ANY-NUMERICAL| `s_tw_open` The time, relative to 0, when the ending location opens.
173  When `e_tw_open` column exist then `e__tw_close` column is expected
174  Default value when (`e_tw_open`, e_tw_close) columns do not exist
175 **e_tw_close** |ANY-NUMERICAL| `s_tw_close` The time, relative to 0, when the ending location closes.
176  When `e_tw_close` column exist then `e_tw_open` column is expected
177  Default value when `(e_tw_open`, e_tw_close)` columns do not exist
178 **e_service** |ANY-NUMERICAL| `s_service` The duration of the unloading at the ending location.
179 ================== =================== ================ ================================================
180 
181 Throws:
182 * When column `id` is missing
183 * When column `capacity` is missing
184 * When column `s_id` is missing
185 * When column `s_tw_open` exists but not `s_tw_close`
186 * When column `s_tw_close`exists but not `s_tw_open`
187 * When column `e_tw_open` exists but not `e_tw_close`
188 * When column `e_tw_close`exists but not `e_tw_open`
189 
190 .. pgr_pickDeliver end
191 */
192 
193 static
195  if (!(column_found(lhs.colNumber)) && column_found(rhs.colNumber)) {
196  ereport(ERROR,
197  (errmsg("Column \'%s\' not Found", lhs.name),
198  errhint("%s was found, also column is expected %s ",
199  rhs.name, lhs.name)));
200  }
201 }
202 
203 static
205  HeapTuple *tuple,
206  TupleDesc *tupdesc,
207  Column_info_t *info,
208  Vehicle_t *vehicle,
209  bool with_stops) {
210  bool with_id = false;
211  /*
212  * s_tw_open, s_tw_close must exist or non at all
213  */
214  check_pairs(info[4], info[5]);
215  check_pairs(info[5], info[4]);
216  /*
217  * e_tw_open, e_tw_close must exist or non at all
218  */
219  check_pairs(info[6], info[7]);
220  check_pairs(info[7], info[6]);
221 
222  /*
223  * e_x, e_y must exist or non at all
224  */
225  check_pairs(info[13], info[14]);
226  check_pairs(info[14], info[13]);
227 
228  vehicle->id = get_Id(tuple, tupdesc, info[0], -1);
229  vehicle->capacity = get_PositiveAmount(tuple, tupdesc, info[1], 0);
230  vehicle->cant_v = get_PositiveAmount(tuple, tupdesc, info[2], 1);
231  vehicle->speed = column_found(info[3].colNumber) ? spi_getFloat8(tuple, tupdesc, info[3]) : 1;
232 
233  /*
234  * start values
235  */
236  vehicle->start_open_t = get_TTimestamp_plain(tuple, tupdesc, info[4], 0);
237  vehicle->start_close_t = get_TTimestamp_plain(tuple, tupdesc, info[5], INT64_MAX);
238 
239  /*
240  * end values
241  */
242  vehicle->end_open_t = get_TTimestamp_plain(tuple, tupdesc, info[6], vehicle->start_open_t);
243  vehicle->end_close_t = get_TTimestamp_plain(tuple, tupdesc, info[7], vehicle->start_close_t);
244 
245  /*
246  * service time values
247  */
248  vehicle->start_service_t = get_PositiveTInterval_plain(tuple, tupdesc, info[9], 0);
249  vehicle->end_service_t = get_PositiveTInterval_plain(tuple, tupdesc, info[10], 0);
250 
251  /*
252  * stops
253  */
254  vehicle->stops = NULL;
255  vehicle->stops_size = 0;
256  if (with_stops && column_found(info[8].colNumber)) {
257  vehicle->stops = spi_getBigIntArr_allowEmpty(tuple, tupdesc, info[8], &vehicle->stops_size);
258  }
259 
260  /*
261  * Values for eucledian
262  */
263  vehicle->start_x = with_id ? 0 : spi_getCoordinate(tuple, tupdesc, info[11], 0);
264  vehicle->start_y = with_id ? 0 : spi_getCoordinate(tuple, tupdesc, info[12], 0);
265  vehicle->end_x = with_id ? 0 : spi_getCoordinate(tuple, tupdesc, info[13], vehicle->start_x);
266  vehicle->end_y = with_id ? 0 : spi_getCoordinate(tuple, tupdesc, info[14], vehicle->start_y);
267 }
268 
269 static
271  HeapTuple *tuple,
272  TupleDesc *tupdesc,
273  Column_info_t *info,
274  Vehicle_t *vehicle,
275  bool with_stops) {
276  /*
277  * s_tw_open, s_tw_close must exist or non at all
278  */
279  check_pairs(info[6], info[7]);
280  check_pairs(info[7], info[6]);
281  /*
282  * e_tw_open, e_tw_close must exist or non at all
283  */
284  check_pairs(info[10], info[11]);
285  check_pairs(info[10], info[11]);
286 
287  vehicle->id = get_Id(tuple, tupdesc, info[0], -1);
288  vehicle->capacity = get_PositiveAmount(tuple, tupdesc, info[1], 0);
289  vehicle->cant_v = get_PositiveAmount(tuple, tupdesc, info[2], 1);
290  vehicle->speed = column_found(info[3].colNumber) ? spi_getFloat8(tuple, tupdesc, info[3]) : 1;
291  vehicle->stops = NULL;
292  vehicle->stops_size = 0;
293  if (with_stops && column_found(info[4].colNumber)) {
294  vehicle->stops = spi_getBigIntArr_allowEmpty(tuple, tupdesc, info[4], &vehicle->stops_size);
295  }
296 
297  /*
298  * start values
299  */
300  vehicle->start_node_id = get_Id(tuple, tupdesc, info[5], -1);
301  vehicle->start_open_t = get_TTimestamp_plain(tuple, tupdesc, info[6], 0);
302  vehicle->start_close_t = get_TTimestamp_plain(tuple, tupdesc, info[7], INT64_MAX);
303  vehicle->start_service_t = get_PositiveTInterval_plain(tuple, tupdesc, info[8], 0);
304 
305  /*
306  * end values
307  */
308  vehicle->end_node_id = get_Id(tuple, tupdesc, info[9], vehicle->start_node_id);
309  vehicle->end_open_t = get_TTimestamp_plain(tuple, tupdesc, info[10], vehicle->start_open_t);
310  vehicle->end_close_t = get_TTimestamp_plain(tuple, tupdesc, info[11], vehicle->start_close_t);
311  vehicle->end_service_t = get_PositiveTInterval_plain(tuple, tupdesc, info[12], 0);
312 
313  /*
314  * Ignored values
315  */
316  vehicle->start_x = 0;
317  vehicle->start_y = 0;
318  vehicle->end_x = 0;
319  vehicle->end_y = 0;
320 }
321 
322 static
324  HeapTuple *tuple,
325  TupleDesc *tupdesc,
326  Column_info_t *info,
327  Vehicle_t *vehicle,
328  bool with_stops) {
329  /*
330  * s_tw_open, s_tw_close must exist or non at all
331  */
332  check_pairs(info[6], info[7]);
333  check_pairs(info[7], info[6]);
334  /*
335  * e_tw_open, e_tw_close must exist or non at all
336  */
337  check_pairs(info[10], info[11]);
338  check_pairs(info[10], info[11]);
339 
340  vehicle->id = get_Id(tuple, tupdesc, info[0], -1);
341  vehicle->capacity = get_PositiveAmount(tuple, tupdesc, info[1], 0);
342  vehicle->cant_v = get_PositiveAmount(tuple, tupdesc, info[2], 1);
343  vehicle->speed = column_found(info[3].colNumber) ? spi_getFloat8(tuple, tupdesc, info[3]) : 1;
344  vehicle->stops = NULL;
345  vehicle->stops_size = 0;
346  if (with_stops && column_found(info[4].colNumber)) {
347  vehicle->stops = spi_getBigIntArr_allowEmpty(tuple, tupdesc, info[4], &vehicle->stops_size);
348  }
349 
350  /*
351  * start values
352  */
353  vehicle->start_node_id = get_Id(tuple, tupdesc, info[5], -1);
354  vehicle->start_open_t = get_TTimestamp(tuple, tupdesc, info[6], 0);
355  vehicle->start_close_t = get_TTimestamp(tuple, tupdesc, info[7], INT64_MAX);
356  vehicle->start_service_t = get_PositiveTInterval(tuple, tupdesc, info[8], 0);
357 
358  /*
359  * end values
360  */
361  vehicle->end_node_id = get_Id(tuple, tupdesc, info[9], vehicle->start_node_id);
362  vehicle->end_open_t = get_TTimestamp(tuple, tupdesc, info[10], vehicle->start_open_t);
363  vehicle->end_close_t = get_TTimestamp(tuple, tupdesc, info[11], vehicle->start_close_t);
364  vehicle->end_service_t = get_PositiveTInterval(tuple, tupdesc, info[12], 0);
365 
366  /*
367  * Ignored values
368  */
369  vehicle->start_x = 0;
370  vehicle->start_y = 0;
371  vehicle->end_x = 0;
372  vehicle->end_y = 0;
373 }
374 
375 
376 static
378  char *vehicles_sql,
379  Vehicle_t **vehicles,
380  size_t *total_vehicles,
381 
382  Column_info_t *info,
383  const int column_count,
384 
385  int kind,
386  bool with_stops) {
387 #ifdef PROFILE
388  clock_t start_t = clock();
389  PGR_DBG("%s", vehicles_sql);
390 #endif
391 
392  const int tuple_limit = 1000000;
393 
394  size_t total_tuples;
395 
396  void *SPIplan;
397  SPIplan = pgr_SPI_prepare(vehicles_sql);
398  Portal SPIportal;
399  SPIportal = pgr_SPI_cursor_open(SPIplan);
400 
401  bool moredata = true;
402  (*total_vehicles) = total_tuples = 0;
403 
404  /* on the first tuple get the column numbers */
405 
406  while (moredata == true) {
407  SPI_cursor_fetch(SPIportal, true, tuple_limit);
408  if (total_tuples == 0) {
409  pgr_fetch_column_info(info, column_count);
410  }
411  size_t ntuples = SPI_processed;
412  total_tuples += ntuples;
413  if (ntuples > 0) {
414  if ((*vehicles) == NULL)
415  (*vehicles) = (Vehicle_t *)palloc0(
416  total_tuples * sizeof(Vehicle_t));
417  else
418  (*vehicles) = (Vehicle_t *)repalloc(
419  (*vehicles),
420  total_tuples * sizeof(Vehicle_t));
421 
422  if ((*vehicles) == NULL) {
423  elog(ERROR, "Out of memory");
424  }
425 
426  size_t t;
427  SPITupleTable *tuptable = SPI_tuptable;
428  TupleDesc tupdesc = SPI_tuptable->tupdesc;
429  for (t = 0; t < ntuples; t++) {
430  HeapTuple tuple = tuptable->vals[t];
431  switch (kind) {
432  case 0 : fetch_timestamps(&tuple, &tupdesc, info,
433  &(*vehicles)[total_tuples - ntuples + t], with_stops);
434  break;
435  case 1 : fetch_raw(&tuple, &tupdesc, info,
436  &(*vehicles)[total_tuples - ntuples + t], with_stops);
437  break;
438  case 2 : fetch_euclidean(&tuple, &tupdesc, info,
439  &(*vehicles)[total_tuples - ntuples + t], with_stops);
440  break;
441  }
442  }
443  SPI_freetuptable(tuptable);
444  } else {
445  moredata = false;
446  }
447  }
448 
449  SPI_cursor_close(SPIportal);
450 
451  if (total_tuples == 0) {
452  (*total_vehicles) = 0;
453  return;
454  }
455 
456  (*total_vehicles) = total_tuples;
457 #ifdef PROFILE
458  time_msg("reading vehicles", start_t, clock());
459 #endif
460 }
461 
468 void
470  char *sql,
471  Vehicle_t **rows,
472  size_t *total_rows,
473  bool with_stops) {
474  const int column_count = 13;
475  Column_info_t info[13];
476 
477  for (int i = 0; i < column_count; ++i) {
478  info[i].colNumber = -1;
479  info[i].type = 0;
480  info[i].strict = false;
481  info[i].eType = ANY_INTEGER;
482  }
483 
484  info[0].name = "id";
485  info[1].name = "capacity";
486  info[2].name = "number";
487  info[3].name = "speed";
488  info[4].name = "stops";
489  info[5].name = "s_id";
490  info[6].name = "s_tw_open";
491  info[7].name = "s_tw_close";
492  info[8].name = "s_t_service";
493  info[9].name = "e_id";
494  info[10].name = "e_tw_open";
495  info[11].name = "e_tw_close";
496  info[12].name = "e_t_service";
497 
498  info[6].eType = TIMESTAMP;
499  info[7].eType = TIMESTAMP;
500  info[10].eType = TIMESTAMP;
501  info[11].eType = TIMESTAMP;
502  info[8].eType = INTERVAL;
503  info[12].eType = INTERVAL;
504 
505  info[4].eType = ANY_INTEGER_ARRAY; // stops
506  info[3].eType = ANY_NUMERICAL; // speed
507 
508  info[0].strict = true;
509  info[1].strict = true;
510  info[5].strict = true;
511 
512  db_get_vehicles(sql, rows, total_rows, info, column_count, 0, with_stops);
513 }
514 
521 void
523  char *sql,
524  Vehicle_t **rows,
525  size_t *total_rows,
526  bool with_stops) {
527  const int column_count = 13;
528  Column_info_t info[13];
529 
530  for (int i = 0; i < column_count; ++i) {
531  info[i].colNumber = -1;
532  info[i].type = 0;
533  info[i].strict = false;
534  info[i].eType = ANY_INTEGER;
535  }
536 
537  info[0].name = "id";
538  info[1].name = "capacity";
539  info[2].name = "number";
540  info[3].name = "speed";
541  info[4].name = "stops";
542  info[5].name = "s_id";
543  info[6].name = "s_open";
544  info[7].name = "s_close";
545  info[8].name = "s_service";
546  info[9].name = "e_id";
547  info[10].name = "e_open";
548  info[11].name = "e_close";
549  info[12].name = "e_service";
550 
551 
552  info[4].eType = ANY_INTEGER_ARRAY; // stops
553  info[3].eType = ANY_NUMERICAL; // speed
554 
555  info[0].strict = true;
556  info[1].strict = true;
557  info[5].strict = true;
558 
559  db_get_vehicles(sql, rows, total_rows, info, column_count, 1, with_stops);
560 }
561 
568 void
570  char *sql,
571  Vehicle_t **rows,
572  size_t *total_rows,
573  bool with_stops) {
574  const int column_count = 15;
575  Column_info_t info[15];
576 
577  for (int i = 0; i < column_count; ++i) {
578  info[i].colNumber = -1;
579  info[i].type = 0;
580  info[i].strict = false;
581  info[i].eType = ANY_INTEGER;
582  }
583 
584  info[0].name = "id";
585  info[1].name = "capacity";
586  info[2].name = "number";
587  info[3].name = "speed";
588  info[4].name = "s_open";
589  info[5].name = "s_close";
590  info[6].name = "e_open";
591  info[7].name = "e_close";
592  info[8].name = "stops";
593  info[9].name = "s_service";
594  info[10].name = "e_service";
595  info[11].name = "s_x";
596  info[12].name = "s_y";
597  info[13].name = "e_x";
598  info[14].name = "e_y";
599 
600 
601  info[8].eType = ANY_INTEGER_ARRAY; // stops
602  info[11].eType = ANY_NUMERICAL; // s_x
603  info[12].eType = ANY_NUMERICAL; // s_y
604  info[13].eType = ANY_NUMERICAL; // e_x
605  info[14].eType = ANY_NUMERICAL; // e_y
606 
607  info[0].strict = true;
608  info[1].strict = true;
609  info[11].strict = true;
610  info[12].strict = true;
611 
612  db_get_vehicles(sql, rows, total_rows, info, column_count, 2, with_stops);
613 }
Column_info_t::colNumber
int colNumber
Definition: column_info_t.h:54
time_msg.h
Vehicle_t::start_node_id
Id start_node_id
Stops size.
Definition: vehicle_t.h:58
check_pairs
static void check_pairs(Column_info_t lhs, Column_info_t rhs)
Definition: vehicles_input.c:194
Vehicle_t::stops
Id * stops
Number of vehicles with same description.
Definition: vehicle_t.h:55
vehicle_t.h
Column_info_t::strict
bool strict
Definition: column_info_t.h:56
Vehicle_t::end_node_id
Id end_node_id
Definition: vehicle_t.h:65
pgr_SPI_prepare
SPIPlanPtr pgr_SPI_prepare(char *sql)
Definition: postgres_connection.c:88
get_vehicles_euclidean
void get_vehicles_euclidean(char *sql, Vehicle_t **rows, size_t *total_rows, bool with_stops)
Reads the vehicles information.
Definition: vehicles_input.c:569
get_TTimestamp
TTimestamp get_TTimestamp(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TTimestamp opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:457
get_Id
Id get_Id(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Id opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:562
Vehicle_t
vehicles's attributes
Definition: vehicle_t.h:50
fetch_timestamps
static void fetch_timestamps(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, Vehicle_t *vehicle, bool with_stops)
Definition: vehicles_input.c:323
spi_getBigIntArr_allowEmpty
int64_t * spi_getBigIntArr_allowEmpty(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, size_t *the_size)
Function returns the values of specified columns in array.
Definition: get_check_data.c:354
vehicles_input.h
Vehicle_t::start_open_t
TTimestamp start_open_t
Start node's identifier.
Definition: vehicle_t.h:59
pgr_fetch_column_info
void pgr_fetch_column_info(Column_info_t info[], int info_size)
Function tells expected type of each column and then check the correspondence type of each column.
Definition: get_check_data.c:905
debug_macro.h
Vehicle_t
struct Vehicle_t Vehicle_t
Definition: vehicles_input.h:32
Vehicle_t::end_open_t
TTimestamp end_open_t
End node's identifier.
Definition: vehicle_t.h:66
get_vehicles_raw
void get_vehicles_raw(char *sql, Vehicle_t **rows, size_t *total_rows, bool with_stops)
Reads the vehicles information.
Definition: vehicles_input.c:522
Vehicle_t::start_y
Coordinate start_y
Definition: vehicle_t.h:63
Column_info_t::name
char * name
Definition: column_info_t.h:57
pgr_SPI_cursor_open
Portal pgr_SPI_cursor_open(SPIPlanPtr SPIplan)
Definition: postgres_connection.c:98
Vehicle_t::start_x
Coordinate start_x
Start service duration.
Definition: vehicle_t.h:62
PGR_DBG
#define PGR_DBG(...)
Definition: debug_macro.h:34
INTERVAL
@ INTERVAL
Definition: column_info_t.h:48
get_PositiveTInterval
TInterval get_PositiveTInterval(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TInterval opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:511
Vehicle_t::start_close_t
TTimestamp start_close_t
Start open time.
Definition: vehicle_t.h:60
ANY_INTEGER_ARRAY
@ ANY_INTEGER_ARRAY
Definition: column_info_t.h:46
Vehicle_t::speed
Speed speed
Vehicle's capacity.
Definition: vehicle_t.h:53
Column_info_t::eType
expectType eType
Definition: column_info_t.h:58
spi_getCoordinate
Coordinate spi_getCoordinate(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Coordinate opt_value)
get a coordinate value
Definition: get_check_data.c:819
get_vehicles
void get_vehicles(char *sql, Vehicle_t **rows, size_t *total_rows, bool with_stops)
Reads the vehicles information.
Definition: vehicles_input.c:469
time_msg
void time_msg(char *msg, clock_t start_t, clock_t end_t)
Definition: time_msg.c:32
ANY_INTEGER
@ ANY_INTEGER
Definition: column_info_t.h:40
Vehicle_t::end_close_t
TTimestamp end_close_t
End open time.
Definition: vehicle_t.h:67
get_PositiveTInterval_plain
TInterval get_PositiveTInterval_plain(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TInterval opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:546
db_get_vehicles
static void db_get_vehicles(char *vehicles_sql, Vehicle_t **vehicles, size_t *total_vehicles, Column_info_t *info, const int column_count, int kind, bool with_stops)
Definition: vehicles_input.c:377
column_info_t.h
Vehicle_t::capacity
PAmount capacity
Vehicle's identifier.
Definition: vehicle_t.h:52
Vehicle_t::end_y
Coordinate end_y
Definition: vehicle_t.h:70
Vehicle_t::cant_v
PAmount cant_v
Definition: vehicle_t.h:54
get_PositiveAmount
PAmount get_PositiveAmount(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, PAmount opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:638
ANY_NUMERICAL
@ ANY_NUMERICAL
Definition: column_info_t.h:41
column_found
bool column_found(int colNumber)
Check whether the colNumber represent any specific column or NULL (SPI_ERROR_NOATTRIBUTE).
Definition: get_check_data.c:900
Vehicle_t::stops_size
size_t stops_size
Stops.
Definition: vehicle_t.h:56
Vehicle_t::end_x
Coordinate end_x
End service time.
Definition: vehicle_t.h:69
get_check_data.h
Vehicle_t::id
Id id
Definition: vehicle_t.h:51
Column_info_t::type
uint64_t type
Definition: column_info_t.h:55
TIMESTAMP
@ TIMESTAMP
Definition: column_info_t.h:47
Column_info_t
Definition: column_info_t.h:52
Vehicle_t::end_service_t
TInterval end_service_t
End close time.
Definition: vehicle_t.h:68
get_TTimestamp_plain
TTimestamp get_TTimestamp_plain(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TTimestamp opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:422
Vehicle_t::start_service_t
TInterval start_service_t
Start close time.
Definition: vehicle_t.h:61
fetch_euclidean
static void fetch_euclidean(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, Vehicle_t *vehicle, bool with_stops)
Definition: vehicles_input.c:204
spi_getFloat8
double spi_getFloat8(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
gets value of specified column in double type.
Definition: get_check_data.c:782
fetch_raw
static void fetch_raw(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, Vehicle_t *vehicle, bool with_stops)
Definition: vehicles_input.c:270