MobilityDB  1.0
tnpoint.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_H__
33 #define __TNPOINT_H__
34 
35 #include <postgres.h>
36 #include <catalog/pg_type.h>
37 #include "general/temporal.h"
38 
39 /*****************************************************************************
40  * Struct definitions
41  *****************************************************************************/
42 
43 /* Network-based point */
44 
45 typedef struct
46 {
47  int64 rid;
48  double pos;
49 } npoint;
50 
51 /* Network-based segment */
52 
53 typedef struct
54 {
55  int64 rid;
56  double pos1;
57  double pos2;
58 } nsegment;
59 
60 /*****************************************************************************
61  * fmgr macros
62  *****************************************************************************/
63 
64 /* npoint */
65 #define DatumGetNpoint(X) ((npoint *) DatumGetPointer(X))
66 #define NpointGetDatum(X) PointerGetDatum(X)
67 #define PG_GETARG_NPOINT(X) DatumGetNpoint(PG_GETARG_DATUM(X))
68 #define PG_RETURN_NPOINT(X) PG_RETURN_POINTER(X)
69 
70 /* nsegment */
71 #define DatumGetNsegment(X) ((nsegment *) DatumGetPointer(X))
72 #define NsegmentGetDatum(X) PointerGetDatum(X)
73 #define PG_GETARG_NSEGMENT(X) DatumGetNsegment(PG_GETARG_DATUM(X))
74 
75 /*****************************************************************************
76  * TNPoint.c
77  *****************************************************************************/
78 
79 extern Datum tnpoint_in(PG_FUNCTION_ARGS);
80 
81 extern Datum tnpoint_make_tnpointseq(PG_FUNCTION_ARGS);
82 
83 extern Datum tnpoint_as_tgeompoint(PG_FUNCTION_ARGS);
84 extern Datum tgeompoint_as_tnpoint(PG_FUNCTION_ARGS);
85 
92 
97 
98 extern Datum tnpoint_positions(PG_FUNCTION_ARGS);
99 extern Datum tnpoint_route(PG_FUNCTION_ARGS);
100 extern Datum tnpoint_routes(PG_FUNCTION_ARGS);
101 
102 extern int64 tnpointinst_route(const TInstant *inst);
103 extern int64 tnpointiseq_route(const TSequence *seq);
104 extern nsegment **tnpointinst_positions(const TInstant *inst);
105 extern nsegment **tnpointinstset_positions(const TInstantSet *ti, int *count);
107 extern nsegment **tnpointseq_positions(const TSequence *seq, int *count);
108 extern nsegment **tnpointseqset_positions(const TSequenceSet *ts, int *count);
109 extern nsegment **tnpoint_positions_internal(const Temporal *temp, int *count);
110 
111 extern ArrayType *tnpointinst_routes(const TInstant *inst);
112 extern ArrayType *tnpointinstset_routes(const TInstantSet *ti);
113 extern ArrayType *tnpointseq_routes(const TSequence *seq);
114 extern ArrayType *tnpointseqset_routes(const TSequenceSet *ts);
115 
116 /*****************************************************************************/
117 
118 #endif /* __TNPOINT_H__ */
nsegment ** tnpointseq_positions(const TSequence *seq, int *count)
Return the network segments covered by the temporal network point.
Definition: tnpoint.c:437
Datum tnpoint_in(PG_FUNCTION_ARGS)
Input function for temporal network points.
Definition: tnpoint.c:59
nsegment ** tnpointseqset_positions(const TSequenceSet *ts, int *count)
Return the network segments covered by the temporal network point.
Definition: tnpoint.c:493
nsegment ** tnpointinstset_positions(const TInstantSet *ti, int *count)
Return the network segments covered by the temporal network point.
Definition: tnpoint.c:379
nsegment ** tnpoint_positions_internal(const Temporal *temp, int *count)
Return the network segments covered by the temporal network point (dispatch function) ...
Definition: tnpoint.c:508
Definition: tnpoint.h:53
ArrayType * tnpointseqset_routes(const TSequenceSet *ts)
Return the array of routes of a temporal network point.
Definition: tnpoint.c:611
TSequence * tgeompointseq_as_tnpointseq(const TSequence *seq)
Cast a temporal geometric point as a temporal network point.
Definition: tnpoint.c:226
Datum tnpoint_positions(PG_FUNCTION_ARGS)
Return the network segments covered by the temporal network point.
Definition: tnpoint.c:531
Structure to represent the common structure of temporal values of any temporal subtype.
Definition: temporal.h:241
ArrayType * tnpointinstset_routes(const TInstantSet *ti)
Return the array of routes of a temporal network point.
Definition: tnpoint.c:581
TInstant * tgeompointinst_as_tnpointinst(const TInstant *inst)
Cast a temporal geometric point as a temporal network point.
Definition: tnpoint.c:188
Temporal * tgeompoint_as_tnpoint_internal(Temporal *temp)
Cast a temporal geometric point as a temporal network point (dispatch function)
Definition: tnpoint.c:277
TSequenceSet * tnpointseqset_as_tgeompointseqset(const TSequenceSet *ts)
Cast a temporal network point as a temporal geometric point.
Definition: tnpoint.c:137
ArrayType * tnpointinst_routes(const TInstant *inst)
Return the array of routes of a temporal network point.
Definition: tnpoint.c:570
nsegment * tnpointseq_linear_positions(const TSequence *seq)
Return the network segments covered by the temporal network point.
Definition: tnpoint.c:417
Basic functions for temporal types of any subtype.
Datum tnpoint_route(PG_FUNCTION_ARGS)
Return the route of a temporal network point.
Definition: tnpoint.c:551
Temporal * tnpoint_as_tgeompoint_internal(const Temporal *temp)
Cast a temporal network point as a temporal geometric point (dispatch function)
Definition: tnpoint.c:154
double pos1
position1
Definition: tnpoint.h:56
Structure to represent temporal values of sequence set subtype.
Definition: temporal.h:293
Definition: tnpoint.h:45
double pos2
position2
Definition: tnpoint.h:57
TInstant * tnpointinst_as_tgeompointinst(const TInstant *inst)
Cast a temporal network point as a temporal geometric point.
Definition: tnpoint.c:76
double pos
position
Definition: tnpoint.h:48
Datum tnpoint_make_tnpointseq(PG_FUNCTION_ARGS)
Structure to represent temporal values of instant set subtype.
Definition: temporal.h:266
TSequence * tnpointseq_as_tgeompointseq(const TSequence *seq)
Cast a temporal network point as a temporal geometric point.
Definition: tnpoint.c:105
int64 tnpointiseq_route(const TSequence *seq)
Return the route of the temporal network point.
Definition: tnpoint.c:356
Datum tnpoint_routes(PG_FUNCTION_ARGS)
Return the array of routes of a temporal network point.
Definition: tnpoint.c:631
int64 rid
route identifier
Definition: tnpoint.h:47
int64 tnpointinst_route(const TInstant *inst)
Return the route of the temporal network point.
Definition: tnpoint.c:346
TSequenceSet * tgeompointseqset_as_tnpointseqset(const TSequenceSet *ts)
Cast a temporal geometric point as a temporal network point.
Definition: tnpoint.c:252
int64 rid
route identifier
Definition: tnpoint.h:55
TInstantSet * tnpointinstset_as_tgeompointi(const TInstantSet *ti)
Cast a temporal network point as a temporal geometric point.
Definition: tnpoint.c:89
TInstantSet * tgeompointinstset_as_tnpointinstset(const TInstantSet *ti)
Cast a temporal geometric point as a temporal network point.
Definition: tnpoint.c:204
nsegment ** tnpointinst_positions(const TInstant *inst)
Return the network segments covered by the temporal network point.
Definition: tnpoint.c:367
Datum tnpoint_as_tgeompoint(PG_FUNCTION_ARGS)
Cast a temporal network point as a temporal geometric point.
Definition: tnpoint.c:174
Structure to represent temporal values of sequence subtype.
Definition: temporal.h:279
ArrayType * tnpointseq_routes(const TSequence *seq)
Return the array of routes of a temporal network point.
Definition: tnpoint.c:599
Datum tgeompoint_as_tnpoint(PG_FUNCTION_ARGS)
Cast a temporal geometric point as a temporal network point.
Definition: tnpoint.c:297
Structure to represent temporal values of instant subtype.
Definition: temporal.h:253