MobilityDB 1.3
Loading...
Searching...
No Matches
meos_rgeo.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * This MobilityDB code is provided under The PostgreSQL License.
4 * Copyright (c) 2016-2025, Université libre de Bruxelles and MobilityDB
5 * contributors
6 *
7 * MobilityDB includes portions of PostGIS version 3 source code released
8 * under the GNU General Public License (GPLv2 or later).
9 * Copyright (c) 2001-2025, PostGIS contributors
10 *
11 * Permission to use, copy, modify, and distribute this software and its
12 * documentation for any purpose, without fee, and without a written
13 * agreement is hereby granted, provided that the above copyright notice and
14 * this paragraph and the following two paragraphs appear in all copies.
15 *
16 * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
17 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
18 * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
19 * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
20 * OF SUCH DAMAGE.
21 *
22 * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURRGEO. THE SOFTWARE PROVIDED HEREUNDER IS ON
25 * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
26 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
27 *
28 *****************************************************************************/
29
34#ifndef __MEOS_RGEO_H__
35#define __MEOS_RGEO_H__
36
37/* C */
38#include <stdbool.h>
39/* PostgreSQL */
40#include <postgres.h>
41/* MEOS */
42#include <meos.h>
43#include <meos_pose.h>
44#include <meos_internal.h>
45#include "geo/stbox.h"
46
47/*****************************************************************************
48 * Validity macros
49 *****************************************************************************/
50
57#if MEOS
58 #define VALIDATE_TRGEOMETRY(temp, ret) \
59 do { \
60 if (! ensure_not_null((void *) (temp)) || \
61 ! ensure_temporal_isof_type((Temporal *) (temp), T_TRGEOMETRY) ) \
62 return (ret); \
63 } while (0)
64#else
65 #define VALIDATE_TRGEOMETRY(temp, ret) \
66 do { \
67 assert(temp); \
68 assert(((Temporal *) (temp))->temptype == T_TRGEOMETRY); \
69 } while (0)
70#endif
71
72/*===========================================================================*
73 * Functions for temporal rigid geometries
74 *===========================================================================*/
75
76/*****************************************************************************
77 * Input/output functions
78 *****************************************************************************/
79
80extern char *trgeo_out(const Temporal *temp);
81
82/*****************************************************************************
83 * Constructor functions
84 *****************************************************************************/
85
86extern TInstant *trgeoinst_make(const GSERIALIZED *geom, const Pose *pose, TimestampTz t);
87extern Temporal *geo_tpose_to_trgeo(const GSERIALIZED *gs, const Temporal *temp);
88
89/*****************************************************************************
90 * Conversion functions
91 *****************************************************************************/
92
93extern Temporal *trgeo_to_tpose(const Temporal *temp);
94extern Temporal *trgeo_to_tpoint(const Temporal *temp);
95
96/*****************************************************************************
97 * Accessor functions
98 *****************************************************************************/
99
100extern TInstant *trgeo_end_instant(const Temporal *temp);
101extern TSequence *trgeo_end_sequence(const Temporal *temp);
102extern GSERIALIZED *trgeo_end_value(const Temporal *temp);
103extern GSERIALIZED *trgeo_geom(const Temporal *temp);
104extern TInstant *trgeo_instant_n(const Temporal *temp, int n);
105extern TInstant **trgeo_instants(const Temporal *temp, int *count);
106extern Set *trgeo_points(const Temporal *temp);
107extern Temporal *trgeo_rotation(const Temporal *temp);
108extern TSequence **trgeo_segments(const Temporal *temp, int *count);
109extern TSequence *trgeo_sequence_n(const Temporal *temp, int i);
110extern TSequence **trgeo_sequences(const Temporal *temp, int *count);
111extern TInstant *trgeo_start_instant(const Temporal *temp);
112extern TSequence *trgeo_start_sequence(const Temporal *temp);
113extern GSERIALIZED *trgeo_start_value(const Temporal *temp);
114extern bool trgeo_value_n(const Temporal *temp, int n, GSERIALIZED **result);
116
117/*****************************************************************************
118 * Transformation functions
119 *****************************************************************************/
120
121extern Temporal *trgeo_append_tinstant(Temporal *temp, const TInstant *inst, interpType interp, double maxdist, const Interval *maxt, bool expand);
122extern Temporal *trgeo_append_tsequence(Temporal *temp, const TSequence *seq, bool expand);
123extern Temporal *trgeo_delete_timestamptz(const Temporal *temp, TimestampTz t, bool connect);
124extern Temporal *trgeo_delete_tstzset(const Temporal *temp, const Set *s, bool connect);
125extern Temporal *trgeo_delete_tstzspan(const Temporal *temp, const Span *s, bool connect);
126extern Temporal *trgeo_delete_tstzspanset(const Temporal *temp, const SpanSet *ss, bool connect);
127extern Temporal *trgeo_round(const Temporal *temp, int maxdd);
128extern Temporal *trgeo_set_interp(const Temporal *temp, interpType interp);
129extern TInstant *trgeo_to_tinstant(const Temporal *temp);
130
131/*****************************************************************************
132 * Restriction functions
133 *****************************************************************************/
134
135extern Temporal *trgeo_restrict_value(const Temporal *temp, Datum value, bool atfunc);
136extern Temporal *trgeo_restrict_values(const Temporal *temp, const Set *s, bool atfunc);
137
138extern Temporal *trgeo_restrict_timestamptz(const Temporal *temp, TimestampTz t, bool atfunc);
139extern Temporal *trgeo_restrict_tstzset(const Temporal *temp, const Set *s, bool atfunc);
140extern Temporal *trgeo_restrict_tstzspan(const Temporal *temp, const Span *s, bool atfunc);
141extern Temporal *trgeo_restrict_tstzspanset(const Temporal *temp, const SpanSet *ss, bool atfunc);
142
143// extern Temporal *trgeo_at_geom(const Temporal *temp, const GSERIALIZED *gs, const Span *zspan);
144// extern Temporal *trgeo_at_geo(const Temporal *temp, const GSERIALIZED *gs, const Span *zspan);
145// extern Temporal *trgeo_at_stbox(const Temporal *temp, const STBox *box, bool border_inc);
146// extern Temporal *trgeo_minus_geom(const Temporal *temp, const GSERIALIZED *gs, const Span *zspan);
147// extern Temporal *trgeo_minus_geo(const Temporal *temp, const GSERIALIZED *gs, const Span *zspan);
148// extern Temporal *trgeo_minus_stbox(const Temporal *temp, const STBox *box, bool border_inc);
149
150/*****************************************************************************
151 * Distance functions
152 *****************************************************************************/
153
154extern Temporal *distance_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs);
155extern Temporal *distance_trgeo_tpoint(const Temporal *temp1, const Temporal *temp2);
156extern Temporal *distance_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2);
157extern double nad_stbox_trgeo(const STBox *box, const Temporal *temp);
158extern double nad_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs);
159extern double nad_trgeo_stbox(const Temporal *temp, const STBox *box);
160extern double nad_trgeo_tpoint(const Temporal *temp1, const Temporal *temp2);
161extern double nad_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2);
162extern TInstant *nai_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs);
163extern TInstant *nai_trgeo_tpoint(const Temporal *temp1, const Temporal *temp2);
164extern TInstant *nai_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2);
165extern GSERIALIZED *shortestline_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs);
166extern GSERIALIZED *shortestline_trgeo_tpoint(const Temporal *temp1, const Temporal *temp2);
167extern GSERIALIZED *shortestline_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2);
168
169/*****************************************************************************
170 * Comparison functions
171 *****************************************************************************/
172
173/* Ever/always and temporal comparison functions */
174
175extern int always_eq_geo_trgeo(const GSERIALIZED *gs, const Temporal *temp);
176extern int always_eq_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs);
177extern int always_eq_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2);
178extern int always_ne_geo_trgeo(const GSERIALIZED *gs, const Temporal *temp);
179extern int always_ne_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs);
180extern int always_ne_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2);
181extern int ever_eq_geo_trgeo(const GSERIALIZED *gs, const Temporal *temp);
182extern int ever_eq_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs);
183extern int ever_eq_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2);
184extern int ever_ne_geo_trgeo(const GSERIALIZED *gs, const Temporal *temp);
185extern int ever_ne_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs);
186extern int ever_ne_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2);
187extern Temporal *teq_geo_trgeo(const GSERIALIZED *gs, const Temporal *temp);
188extern Temporal *teq_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs);
189extern Temporal *tne_geo_trgeo(const GSERIALIZED *gs, const Temporal *temp);
190extern Temporal *tne_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs);
191
192/*****************************************************************************/
193
194/* Ever and always spatial relationship functions */
195
196
197/*****************************************************************************/
198
199/* Spatiotemporal relationship functions */
200
201
202/*****************************************************************************/
203
204#endif /* __MEOS_RGEO_H__ */
Temporal * trgeo_restrict_timestamptz(const Temporal *temp, TimestampTz t, bool atfunc)
Restrict a temporal rigid geometry to (the complement of) a timestamptz.
Definition: trgeo.c:1034
Temporal * trgeo_restrict_tstzset(const Temporal *temp, const Set *s, bool atfunc)
Restrict a temporal rigid geometry to (the complement of) a timestamptz set.
Definition: trgeo.c:1088
Temporal * trgeo_restrict_tstzspanset(const Temporal *temp, const SpanSet *ss, bool atfunc)
Restrict a temporal rigid geometry to (the complement of) a timestamptz span set.
Definition: trgeo.c:1194
Temporal * trgeo_restrict_tstzspan(const Temporal *temp, const Span *s, bool atfunc)
Restrict a temporal rigid geometry to (the complement of) a timestamptz span.
Definition: trgeo.c:1141
Temporal * trgeo_restrict_values(const Temporal *temp, const Set *s, bool atfunc)
Restrict a temporal rigid geometry to (the complement of) a set of geometries.
Definition: trgeo.c:983
Temporal * trgeo_restrict_value(const Temporal *temp, Datum value, bool atfunc)
Restrict a temporal rigid geometry to (the complement of) a geometry.
Definition: trgeo.c:932
TInstant * trgeo_instant_n(const Temporal *temp, int n)
Return a copy of the n-th instant of a temporal rigid geometry.
Definition: trgeo.c:615
TSequence ** trgeo_sequences(const Temporal *temp, int *count)
Return an array of copies of the sequences of a temporal sequence (set)
Definition: trgeo.c:752
GSERIALIZED * trgeo_start_value(const Temporal *temp)
Return a copy of the start value of a temporal rigid geometry.
Definition: trgeo.c:446
TSequence * trgeo_start_sequence(const Temporal *temp)
Return a copy of the start sequence of a temporal sequence (set)
Definition: trgeo.c:667
TSequence * trgeo_sequence_n(const Temporal *temp, int i)
Return a copy of the n-th sequence of a temporal sequence (set)
Definition: trgeo.c:717
TInstant * trgeo_end_instant(const Temporal *temp)
Return a copy of the end instant of a temporal rigid geometry.
Definition: trgeo.c:594
TSequence * trgeo_end_sequence(const Temporal *temp)
Return a copy of the end sequence of a temporal sequence (set)
Definition: trgeo.c:691
TInstant * trgeo_start_instant(const Temporal *temp)
Return a copy of the start instant of a temporal rigid geometry.
Definition: trgeo.c:574
GSERIALIZED * trgeo_end_value(const Temporal *temp)
Return a copy of the end base value of a temporal rigid geometry.
Definition: trgeo.c:474
bool trgeo_value_n(const Temporal *temp, int n, GSERIALIZED **result)
Return in the last argument a copy of the n-th value of a temporal value.
Definition: trgeo.c:511
TInstant ** trgeo_instants(const Temporal *temp, int *count)
Return a copy of the distinct instants of a temporal rigid geometry.
Definition: trgeo.c:640
int always_eq_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2)
Return true if two temporal rigid geometries are always equal.
Definition: trgeo_compops.c:235
int ever_eq_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs)
Return true if a temporal rigid geometry is ever equal to a rigid geometry.
Definition: trgeo_compops.c:113
int always_ne_geo_trgeo(const GSERIALIZED *gs, const Temporal *temp)
Return true if a geometry is always different from a temporal rigid geometry.
Definition: trgeo_compops.c:183
int ever_ne_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs)
Return true if a temporal rigid geometry is ever different from a geometry.
Definition: trgeo_compops.c:141
int always_ne_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2)
Return true if two temporal rigid geometries are always different.
Definition: trgeo_compops.c:247
int always_ne_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs)
Return true if a temporal rigid geometry is always different from a geometry.
Definition: trgeo_compops.c:197
int always_eq_geo_trgeo(const GSERIALIZED *gs, const Temporal *temp)
Return true if a geometry is always equal to a temporal rigid geometry.
Definition: trgeo_compops.c:155
int ever_eq_geo_trgeo(const GSERIALIZED *gs, const Temporal *temp)
Return true if a geometry is ever equal to a temporal rigid geometry.
Definition: trgeo_compops.c:99
int always_eq_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs)
Return true if a temporal rigid geometry is always equal to a geometry.
Definition: trgeo_compops.c:169
int ever_ne_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2)
Return true if two temporal rigid geometries are ever different.
Definition: trgeo_compops.c:223
int ever_ne_geo_trgeo(const GSERIALIZED *gs, const Temporal *temp)
Return true if a geometry is ever different from a temporal rigid geometry.
Definition: trgeo_compops.c:127
int ever_eq_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2)
Return true if two temporal rigid geometries are ever equal.
Definition: trgeo_compops.c:211
Temporal * tne_geo_trgeo(const GSERIALIZED *gs, const Temporal *temp)
Return the temporal inequality of a geometry and a temporal rigid geometry.
Definition: trgeo_compops.c:317
Temporal * teq_geo_trgeo(const GSERIALIZED *gs, const Temporal *temp)
Return the temporal equality of a geometry and a temporal rigid geometry.
Definition: trgeo_compops.c:303
Temporal * tne_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs)
Return the temporal inequality of a temporal rigid geometry and a geometry.
Definition: trgeo_compops.c:347
Temporal * teq_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs)
Return the temporal equality of a temporal rigid geometry and a geometry.
Definition: trgeo_compops.c:333
Temporal * trgeo_to_tpoint(const Temporal *temp)
Return a temporal point obtained from the points of the temporal pose of a temporal rigid geometry.
Definition: trgeo.c:275
Temporal * trgeo_to_tpose(const Temporal *temp)
Return a temporal pose obtained by removing the reference geometry of a temporal rigid geometry.
Definition: trgeo.c:252
GSERIALIZED * trgeo_geom(const Temporal *temp)
Return a copy of the reference geometry of a temporal rigid geometry.
Definition: trgeo.c:316
TInstant * nai_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2)
Return the nearest approach instant between two temporal rigid geometries @sqlfn nearestApproachInsta...
Definition: trgeo_distance.c:1968
TInstant * nai_trgeo_tpoint(const Temporal *temp1, const Temporal *temp2)
Return the nearest approach instant between a temporal rigid geometry and a temporal point @sqlfn nea...
Definition: trgeo_distance.c:1940
double nad_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs)
Return the nearest approach distance between a temporal rigid geometry and a geometry.
Definition: trgeo_distance.c:2000
double nad_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2)
Return the nearest approach distance between two temporal rigid geometries.
Definition: trgeo_distance.c:2077
GSERIALIZED * shortestline_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs)
Return the line connecting the nearest approach point between a temporal rigid geometry and a geometr...
Definition: trgeo_distance.c:2103
GSERIALIZED * shortestline_trgeo_tpoint(const Temporal *temp1, const Temporal *temp2)
Return the line connecting the nearest approach point between a temporal rigid geometry and a tempora...
Definition: trgeo_distance.c:2127
GSERIALIZED * shortestline_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2)
Return the line connecting the nearest approach point between two temporal rigid geometries @sqlfn sh...
Definition: trgeo_distance.c:2154
TInstant * nai_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs)
Return the nearest approach instant between a temporal rigid geometry and a geometry @sqlfn nearestAp...
Definition: trgeo_distance.c:1906
Temporal * distance_trgeo_geo(const Temporal *temp, const GSERIALIZED *gs)
Return the temporal distance between a temporal rigid geometry and a geometry/geography point.
Definition: trgeo_distance.c:1831
double nad_trgeo_tpoint(const Temporal *temp1, const Temporal *temp2)
Return the nearest approach distance between two temporal rigid geometries.
Definition: trgeo_distance.c:2055
double nad_trgeo_stbox(const Temporal *temp, const STBox *box)
Return the nearest approach distance between a temporal rigid geometry and a spatiotemporal box.
Definition: trgeo_distance.c:2019
char * trgeo_out(const Temporal *temp)
Return the Well-Known Text (WKT) representation of a temporal rigid geometry.
Definition: trgeo.c:171
interpType
Enumeration that defines the interpolation types used in MEOS.
Definition: meos.h:161
External API of the Mobility Engine Open Source (MEOS) library.
Temporal * trgeo_set_interp(const Temporal *temp, interpType interp)
Restrict a temporal rigid geometry transformed to an interpolation.
Definition: trgeo.c:901
Temporal * trgeo_append_tinstant(Temporal *temp, const TInstant *inst, interpType interp, double maxdist, const Interval *maxt, bool expand)
Append an instant to a temporal value.
Definition: trgeo.c:1259
TSequence ** trgeo_segments(const Temporal *temp, int *count)
Temporal * trgeo_delete_tstzspanset(const Temporal *temp, const SpanSet *ss, bool connect)
Delete a timestamptz span set from a temporal rigid geometry.
Definition: trgeo.c:1390
GSERIALIZED * trgeo_traversed_area(const Temporal *temp)
double nad_stbox_trgeo(const STBox *box, const Temporal *temp)
Temporal * distance_trgeo_trgeo(const Temporal *temp1, const Temporal *temp2)
Temporal * trgeo_delete_tstzset(const Temporal *temp, const Set *s, bool connect)
Delete a timestamp set from a temporal rigid geometry connecting the instants before and after the gi...
Definition: trgeo.c:1342
Temporal * trgeo_delete_timestamptz(const Temporal *temp, TimestampTz t, bool connect)
Return the value of a temporal rigid geometry at a timestamptz @csqlfn Temporal_delete_timestamptz.
Definition: trgeo.c:1317
Temporal * trgeo_append_tsequence(Temporal *temp, const TSequence *seq, bool expand)
Append a sequence to a temporal value.
Definition: trgeo.c:1289
Temporal * trgeo_round(const Temporal *temp, int maxdd)
Return a temporal rigid geometry rounded to a given number of decimal places.
Definition: trgeo.c:785
Temporal * distance_trgeo_tpoint(const Temporal *temp1, const Temporal *temp2)
TInstant * trgeo_to_tinstant(const Temporal *temp)
Return a temporal rigid geometry transformed to a temporal instant.
Definition: trgeo.c:810
Set * trgeo_points(const Temporal *temp)
TInstant * trgeoinst_make(const GSERIALIZED *geom, const Pose *pose, TimestampTz t)
Construct a temporal geometry instant value from the arguments.
Definition: trgeo_inst.c:197
Temporal * trgeo_rotation(const Temporal *temp)
Temporal * geo_tpose_to_trgeo(const GSERIALIZED *gs, const Temporal *temp)
Construct a temporal rigid geometry from a geometry and a temporal pose.
Definition: trgeo.c:399
Temporal * trgeo_delete_tstzspan(const Temporal *temp, const Span *s, bool connect)
Delete a timestamptz span from a temporal rigid geometry.
Definition: trgeo.c:1366
int64 TimestampTz
Definition: postgres_ext_defs.in.h:22
uintptr_t Datum
Definition: postgres_ext_defs.in.h:7
Definition: postgis_ext_defs.in.h:170
Definition: postgres_ext_defs.in.h:27
Basic functions for static pose objects.
Definition: pose.h:56
Structure to represent spatiotemporal boxes.
Definition: meos.h:134
Structure to represent sets of values.
Definition: meos.h:80
Structure to represent span sets.
Definition: meos.h:108
Structure to represent spans (a.k.a.
Definition: meos.h:94
Structure to represent temporal values of instant subtype.
Definition: meos.h:185
Structure to represent temporal values of sequence subtype.
Definition: meos.h:202
Structure to represent the common structure of temporal values of any temporal subtype.
Definition: meos.h:173
int const GSERIALIZED * gs
Definition: trgeo_spatialrels.h:52
#define connect(s, name, namelen)
Definition: win32_port.h:463