MobilityDB  1.0
tnpoint_static.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * This MobilityDB code is provided under The PostgreSQL License.
4  *
5  * Copyright (c) 2016-2021, Université libre de Bruxelles and MobilityDB
6  * contributors
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation for any purpose, without fee, and without a written
10  * agreement is hereby granted, provided that the above copyright notice and
11  * this paragraph and the following two paragraphs appear in all copies.
12  *
13  * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
15  * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
16  * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
17  * OF SUCH DAMAGE.
18  *
19  * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
22  * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
23  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 
24  *
25  *****************************************************************************/
26 
32 #ifndef __TNPOINT_STATIC_H__
33 #define __TNPOINT_STATIC_H__
34 
35 #include <postgres.h>
36 #include <catalog/pg_type.h>
37 
38 #include "tnpoint.h"
39 
40 /*****************************************************************************
41  * StaticObjects.c
42  *****************************************************************************/
43 
44 extern ArrayType *int64arr_to_array(const int64 *int64arr, int count);
45 extern ArrayType *npointarr_to_array(npoint **npointarr, int count);
46 extern void npointarr_sort(npoint **points, int count);
47 extern ArrayType *nsegmentarr_to_array(nsegment **nsegmentarr, int count);
48 extern int32_t get_srid_ways();
49 extern nsegment **nsegmentarr_normalize(nsegment **segments, int *count);
50 extern int npoint_remove_duplicates(npoint **values, int count);
51 
52 extern Datum npoint_in(PG_FUNCTION_ARGS);
53 extern Datum npoint_out(PG_FUNCTION_ARGS);
54 extern Datum npoint_recv(PG_FUNCTION_ARGS);
55 extern Datum npoint_send(PG_FUNCTION_ARGS);
56 
57 extern Datum nsegment_in(PG_FUNCTION_ARGS);
58 extern Datum nsegment_out(PG_FUNCTION_ARGS);
59 extern Datum nsegment_recv(PG_FUNCTION_ARGS);
60 extern Datum nsegment_send(PG_FUNCTION_ARGS);
61 
62 extern Datum npoint_constructor(PG_FUNCTION_ARGS);
63 extern Datum nsegment_constructor(PG_FUNCTION_ARGS);
64 extern Datum nsegment_from_npoint(PG_FUNCTION_ARGS);
65 
66 extern Datum npoint_set_precision_internal(Datum npoint, Datum size);
67 
68 extern void npoint_set(npoint *np, int64 rid, double pos);
69 extern npoint *npoint_make(int64 rid, double pos);
70 extern void nsegment_set(nsegment *ns, int64 rid, double pos1, double pos2);
71 extern nsegment *nsegment_make(int64 rid, double pos1, double pos2);
72 
73 extern Datum npoint_route(PG_FUNCTION_ARGS);
74 extern Datum npoint_position(PG_FUNCTION_ARGS);
75 extern Datum nsegment_route(PG_FUNCTION_ARGS);
76 extern Datum nsegment_start_position(PG_FUNCTION_ARGS);
77 extern Datum nsegment_end_position(PG_FUNCTION_ARGS);
78 
79 extern Datum npoint_eq(PG_FUNCTION_ARGS);
80 extern Datum npoint_ne(PG_FUNCTION_ARGS);
81 extern Datum npoint_lt(PG_FUNCTION_ARGS);
82 extern Datum npoint_le(PG_FUNCTION_ARGS);
83 extern Datum npoint_gt(PG_FUNCTION_ARGS);
84 extern Datum npoint_ge(PG_FUNCTION_ARGS);
85 
86 extern int npoint_cmp_internal(const npoint *np1, const npoint *np2);
87 extern bool npoint_same_internal(const npoint *np1, const npoint *np2);
88 extern bool npoint_eq_internal(const npoint *np1, const npoint *np2);
89 extern bool npoint_ne_internal(const npoint *np1, const npoint *np2);
90 extern bool npoint_lt_internal(const npoint *np1, const npoint *np2);
91 extern bool npoint_le_internal(const npoint *np1, const npoint *np2);
92 extern bool npoint_gt_internal(const npoint *np1, const npoint *np2);
93 extern bool npoint_ge_internal(const npoint *np1, const npoint *np2);
94 
95 extern Datum nsegment_eq(PG_FUNCTION_ARGS);
96 extern Datum nsegment_ne(PG_FUNCTION_ARGS);
97 extern Datum nsegment_lt(PG_FUNCTION_ARGS);
98 extern Datum nsegment_le(PG_FUNCTION_ARGS);
99 extern Datum nsegment_gt(PG_FUNCTION_ARGS);
100 extern Datum nsegment_ge(PG_FUNCTION_ARGS);
101 
102 extern int nsegment_cmp_internal(const nsegment *ns1, const nsegment *ns2);
103 extern bool nsegment_eq_internal(const nsegment *ns1, const nsegment *ns2);
104 extern bool nsegment_ne_internal(const nsegment *ns1, const nsegment *ns2);
105 extern bool nsegment_lt_internal(const nsegment *ns1, const nsegment *ns2);
106 extern bool nsegment_le_internal(const nsegment *ns1, const nsegment *ns2);
107 extern bool nsegment_gt_internal(const nsegment *ns1, const nsegment *ns2);
108 extern bool nsegment_ge_internal(const nsegment *ns1, const nsegment *ns2);
109 
110 extern bool route_exists(int64 rid);
111 extern double route_length(int64 rid);
112 extern Datum route_geom(int64 rid);
113 extern int64 rid_from_geom(Datum geom);
114 
115 extern int npoint_srid_internal(const npoint *np);
116 extern Datum npoint_as_geom(PG_FUNCTION_ARGS);
117 extern Datum geom_as_npoint(PG_FUNCTION_ARGS);
118 extern Datum nsegment_as_geom(PG_FUNCTION_ARGS);
119 extern Datum geom_as_nsegment(PG_FUNCTION_ARGS);
120 
121 extern Datum npoint_as_geom_internal(const npoint *np);
122 extern Datum nsegment_as_geom_internal(const nsegment *ns);
123 extern npoint *geom_as_npoint_internal(Datum geom);
124 extern nsegment *geom_as_nsegment_internal(Datum line);
125 
126 extern Datum npointarr_to_geom_internal(npoint **points, int count);
127 extern Datum nsegmentarr_to_geom_internal(nsegment **segments, int count);
128 
129 /*****************************************************************************/
130 
131 #endif /* __TNPOINT_STATIC_H__ */
Datum npoint_lt(PG_FUNCTION_ARGS)
Returns true if the first network point is less than the second one.
Definition: tnpoint_static.c:721
npoint * geom_as_npoint_internal(Datum geom)
Transforms the geometry into a network point.
Definition: tnpoint_static.c:1086
Datum npoint_position(PG_FUNCTION_ARGS)
Returns the position of the network point.
Definition: tnpoint_static.c:533
bool npoint_ge_internal(const npoint *np1, const npoint *np2)
Datum nsegment_eq(PG_FUNCTION_ARGS)
Returns true if the first network segment is equal to the second one.
Definition: tnpoint_static.c:787
Datum route_geom(int64 rid)
Access the edge table to get the route geometry from corresponding route identifier.
Definition: tnpoint_static.c:971
Datum nsegment_start_position(PG_FUNCTION_ARGS)
Returns the start position of the network segment.
Definition: tnpoint_static.c:555
Datum nsegment_lt(PG_FUNCTION_ARGS)
Returns true if the first network segment is less than the second one.
Definition: tnpoint_static.c:861
Definition: tnpoint.h:53
ArrayType * npointarr_to_array(npoint **npointarr, int count)
Datum nsegment_from_npoint(PG_FUNCTION_ARGS)
Construct an network segment value from the network point.
Definition: tnpoint_static.c:505
void npoint_set(npoint *np, int64 rid, double pos)
Datum nsegmentarr_to_geom_internal(nsegment **segments, int count)
Convert a network segment array into a geometry.
Definition: tnpoint_static.c:153
Datum nsegment_as_geom_internal(const nsegment *ns)
Transforms the network segment into a geometry.
Definition: tnpoint_static.c:1172
nsegment * geom_as_nsegment_internal(Datum line)
Transforms the geometry into a network segment.
Definition: tnpoint_static.c:1202
bool nsegment_ge_internal(const nsegment *ns1, const nsegment *ns2)
Datum nsegment_ge(PG_FUNCTION_ARGS)
Returns true if the first network segment is greater than or equal to the second one.
Definition: tnpoint_static.c:889
void npointarr_sort(npoint **points, int count)
ArrayType * int64arr_to_array(const int64 *int64arr, int count)
Convert a C array of int64 values into a PostgreSQL array.
Definition: tnpoint_static.c:67
bool npoint_gt_internal(const npoint *np1, const npoint *np2)
Datum nsegment_recv(PG_FUNCTION_ARGS)
Receive function for network segments.
Definition: tnpoint_static.c:366
Datum nsegment_le(PG_FUNCTION_ARGS)
Returns true if the first network segment is less than or equal to the second one.
Definition: tnpoint_static.c:875
Datum nsegment_send(PG_FUNCTION_ARGS)
Send function for network segments.
Definition: tnpoint_static.c:383
Datum geom_as_npoint(PG_FUNCTION_ARGS)
Transforms the geometry into a network point.
Definition: tnpoint_static.c:1125
Datum geom_as_nsegment(PG_FUNCTION_ARGS)
Transforms the geometry into a network segment.
Definition: tnpoint_static.c:1263
bool nsegment_gt_internal(const nsegment *ns1, const nsegment *ns2)
Datum npoint_ne(PG_FUNCTION_ARGS)
Returns true if the first network point is not equal to the second one.
Definition: tnpoint_static.c:661
int npoint_remove_duplicates(npoint **values, int count)
Datum nsegment_gt(PG_FUNCTION_ARGS)
Returns true if the first network segment is greater than the second one.
Definition: tnpoint_static.c:902
Datum npoint_set_precision_internal(Datum npoint, Datum size)
Set the precision of the position of a network point to the number of decimal places.
Definition: tnpoint_static.c:581
nsegment ** nsegmentarr_normalize(nsegment **segments, int *count)
Normalize the array of temporal segments.
Definition: tnpoint_static.c:224
bool nsegment_lt_internal(const nsegment *ns1, const nsegment *ns2)
int npoint_cmp_internal(const npoint *np1, const npoint *np2)
Returns -1, 0, or 1 depending on whether the first network point is less than, equal, or greater than the second one.
Definition: tnpoint_static.c:675
bool npoint_le_internal(const npoint *np1, const npoint *np2)
npoint * npoint_make(int64 rid, double pos)
Construct an network point value from the arguments.
Definition: tnpoint_static.c:420
Datum npointarr_to_geom_internal(npoint **points, int count)
Convert a network point array into a geometry.
Definition: tnpoint_static.c:124
Datum npoint_as_geom_internal(const npoint *np)
Transforms the network point into a geometry.
Definition: tnpoint_static.c:1062
bool nsegment_eq_internal(const nsegment *ns1, const nsegment *ns2)
Returns true if the first network segment is equal to the second one.
Definition: tnpoint_static.c:776
Datum npoint_eq(PG_FUNCTION_ARGS)
Returns true if the first network point is equal to the second one.
Definition: tnpoint_static.c:640
Datum nsegment_in(PG_FUNCTION_ARGS)
Input function for network segments Example of input: (1, 0.5, 0.6)
Definition: tnpoint_static.c:342
Definition: tnpoint.h:45
Datum npoint_gt(PG_FUNCTION_ARGS)
Returns true if the first network point is greater than the second one.
Definition: tnpoint_static.c:762
bool route_exists(int64 rid)
Returns true if the edge table contains a route with the route identifier.
Definition: tnpoint_static.c:918
int64 rid_from_geom(Datum geom)
Datum npoint_ge(PG_FUNCTION_ARGS)
Returns true if the first network point is greater than or equal to the second one.
Definition: tnpoint_static.c:749
void nsegment_set(nsegment *ns, int64 rid, double pos1, double pos2)
Datum npoint_in(PG_FUNCTION_ARGS)
Input function for network points Example of input: (1, 0.5)
Definition: tnpoint_static.c:276
bool npoint_ne_internal(const npoint *np1, const npoint *np2)
Returns true if the first network point is not equal to the second one.
Definition: tnpoint_static.c:651
Functions for temporal network points.
Datum npoint_constructor(PG_FUNCTION_ARGS)
Construct an network point value from the arguments.
Definition: tnpoint_static.c:440
bool npoint_lt_internal(const npoint *np1, const npoint *np2)
Returns true if the first network point is less than the second one.
Definition: tnpoint_static.c:710
Datum npoint_le(PG_FUNCTION_ARGS)
Returns true if the first network point is less than or equal to the second one.
Definition: tnpoint_static.c:735
Datum nsegment_end_position(PG_FUNCTION_ARGS)
Returns the end position of the network segment.
Definition: tnpoint_static.c:566
Datum npoint_send(PG_FUNCTION_ARGS)
Send function for network points.
Definition: tnpoint_static.c:320
Datum npoint_as_geom(PG_FUNCTION_ARGS)
Transforms the network point into a geometry.
Definition: tnpoint_static.c:1075
bool npoint_same_internal(const npoint *np1, const npoint *np2)
Determines the spatial equality for network points.
Definition: tnpoint_spatialfuncs.c:426
Datum nsegment_as_geom(PG_FUNCTION_ARGS)
Transforms the network segment into a geometry.
Definition: tnpoint_static.c:1191
Datum nsegment_ne(PG_FUNCTION_ARGS)
Returns true if the first network segment is not equal to the second one.
Definition: tnpoint_static.c:808
Datum npoint_route(PG_FUNCTION_ARGS)
Returns the route of the network point.
Definition: tnpoint_static.c:521
bool nsegment_ne_internal(const nsegment *ns1, const nsegment *ns2)
Returns true if the first network segment is not equal to the second one.
Definition: tnpoint_static.c:798
int32_t get_srid_ways()
Return the SRID of the routes in the ways table.
Definition: tnpoint_static.c:95
Datum npoint_out(PG_FUNCTION_ARGS)
Output function for network points.
Definition: tnpoint_static.c:288
nsegment * nsegment_make(int64 rid, double pos1, double pos2)
Construct an network segment value from the arguments.
Definition: tnpoint_static.c:470
Datum npoint_recv(PG_FUNCTION_ARGS)
Receive function for network points.
Definition: tnpoint_static.c:304
ArrayType * nsegmentarr_to_array(nsegment **nsegmentarr, int count)
Convert a C array of network segment values into a PostgreSQL array.
Definition: tnpoint_static.c:85
int npoint_srid_internal(const npoint *np)
Returns the SRID of the network point.
Definition: tnpoint_static.c:1037
bool nsegment_le_internal(const nsegment *ns1, const nsegment *ns2)
Datum nsegment_out(PG_FUNCTION_ARGS)
Output function for network segments.
Definition: tnpoint_static.c:354
Datum nsegment_route(PG_FUNCTION_ARGS)
Returns the route of the network segment.
Definition: tnpoint_static.c:544
Datum nsegment_constructor(PG_FUNCTION_ARGS)
Construct an network segment value from the arguments.
Definition: tnpoint_static.c:491
double route_length(int64 rid)
Access the edge table to return the route length from the corresponding route identifier.
Definition: tnpoint_static.c:942
int nsegment_cmp_internal(const nsegment *ns1, const nsegment *ns2)
Returns -1, 0, or 1 depending on whether the first network segment is less than, equal, or greater than the second one.
Definition: tnpoint_static.c:822
bool npoint_eq_internal(const npoint *np1, const npoint *np2)
Returns true if the first network point is equal to the second one.
Definition: tnpoint_static.c:630