MobilityDB 1.3
Loading...
Searching...
No Matches
tnpoint.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 PURPOSE. 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 __TNPOINT_H__
35#define __TNPOINT_H__
36
37/* PostgreSQL */
38#include <postgres.h>
39/* MEOS */
40#include <meos_npoint.h>
41#include "temporal/temporal.h"
42
43/*****************************************************************************
44 * fmgr macros
45 *****************************************************************************/
46
47/* Npoint */
48#define DatumGetNpointP(X) ((Npoint *) DatumGetPointer(X))
49#define NpointPGetDatum(X) PointerGetDatum(X)
50#define PG_GETARG_NPOINT_P(X) DatumGetNpointP(PG_GETARG_DATUM(X))
51#define PG_RETURN_NPOINT_P(X) PG_RETURN_POINTER(X)
52
53/* Nsegment */
54#define DatumGetNsegmentP(X) ((Nsegment *) DatumGetPointer(X))
55#define NsegmentPGetDatum(X) PointerGetDatum(X)
56#define PG_GETARG_NSEGMENT_P(X) DatumGetNsegmentP(PG_GETARG_DATUM(X))
57#define PG_RETURN_NSEGMENT_P(X) PG_RETURN_POINTER(X)
58
59/*****************************************************************************
60 * Npoint functions
61 *****************************************************************************/
62
63/* Validity functions */
64
65extern bool ensure_valid_tnpoint_npoint(const Temporal *temp,
66 const Npoint *np);
67extern bool ensure_valid_tnpoint_npointset(const Temporal *temp, const Set *s);
68extern bool ensure_valid_tnpoint_geo(const Temporal *temp,
69 const GSERIALIZED *gs);
70extern bool ensure_valid_tnpoint_stbox(const Temporal *temp, const STBox *box);
71extern bool ensure_valid_tnpoint_tnpoint(const Temporal *temp1,
72 const Temporal *temp2);
73
74extern bool common_rid_tnpoint_npoint(const Temporal *temp, const Npoint *np);
75extern bool common_rid_tnpoint_npointset(const Temporal *temp, const Set *s);
76extern bool common_rid_tnpoint_tnpoint(const Temporal *temp1,
77 const Temporal *temp2);
78
79/* Collinear functions */
80
81extern bool npoint_collinear(const Npoint *np1, const Npoint *np2,
82 const Npoint *np3, double ratio);
83
84/* Interpolation functions */
85
86extern Npoint *npointsegm_interpolate(const Npoint *start, const Npoint *end,
87 long double ratio);
88extern long double npointsegm_locate(const Npoint *start, const Npoint *end,
89 const Npoint *value);
90
91/* General functions */
92
93extern GSERIALIZED *npointarr_geom(Npoint **points, int count);
94extern GSERIALIZED *nsegmentarr_geom(Nsegment **segments, int count);
95extern Nsegment **nsegmentarr_normalize(Nsegment **segments, int *count);
96
97/* Input/output functions */
98
99extern char *npoint_wkt_out(Datum value, int maxdd);
100
101/* Constructor functions */
102
103extern void npoint_set(int64 rid, double pos, Npoint *np);
104extern void nsegment_set(int64 rid, double pos1, double pos2, Nsegment *ns);
105
106/* Transformation functions */
107
108extern Datum datum_npoint_round(Datum npoint, Datum size);
109
110/*****************************************************************************
111 * Temporal network point functions
112 *****************************************************************************/
113
114/* Input/output functions */
115
116/* Conversion functions */
117
119#define NPOINT_TO_GEOM true
120#define GEOM_TO_NPOINT false
121
122extern TInstant *tnpointinst_tgeompointinst(const TInstant *inst);
126
127extern TInstant *tgeompointinst_tnpointinst(const TInstant *inst);
130
131/* Accessor functions */
132
133extern Nsegment **tnpointinst_positions(const TInstant *inst);
134extern Nsegment **tnpointseq_positions(const TSequence *seq, int *count);
135extern Nsegment **tnpointseqset_positions(const TSequenceSet *ss, int *count);
136extern int64 tnpointinst_route(const TInstant *inst);
137extern Set *tnpointinst_routes(const TInstant *inst);
138extern Set *tnpointseq_disc_routes(const TSequence *is);
139extern Set *tnpointseq_cont_routes(const TSequence *seq);
140extern Set *tnpointseqset_routes(const TSequenceSet *ss);
141
143
144extern Temporal *tnpoint_restrict_stbox(const Temporal *temp, const STBox *box,
145 bool border_inc, bool atfunc);
146extern Temporal *tnpoint_restrict_npoint(const Temporal *temp, const Npoint
147 *np, bool atfunc);
148extern Temporal *tnpoint_restrict_npointset(const Temporal *temp, const Set *s,
149 bool atfunc);
150
151/*****************************************************************************/
152
153#endif /* __TNPOINT_H__ */
GSERIALIZED * npointarr_geom(Npoint **points, int count)
Return a geometry converted from an array of network points.
Definition: npoint.c:1473
GSERIALIZED * nsegmentarr_geom(Nsegment **segments, int count)
Return a geometry converted from an array of network segments.
Definition: npoint.c:1503
Temporal * tnpoint_restrict_stbox(const Temporal *temp, const STBox *box, bool border_inc, bool atfunc)
Return a temporal network point restricted to (the complement of) a spatiotemporal box.
Definition: tnpoint_spatialfuncs.c:600
Temporal * tnpoint_restrict_npoint(const Temporal *temp, const Npoint *np, bool atfunc)
Restrict a temporal network point to (the complement of) a network point.
Definition: tnpoint.c:742
Temporal * tnpoint_restrict_npointset(const Temporal *temp, const Set *s, bool atfunc)
Restrict a temporal network point to (the complement of) a set of network points.
Definition: tnpoint.c:793
uintptr_t Datum
Definition: postgres_ext_defs.in.h:7
long int int64
Definition: postgres_ext_defs.in.h:12
Definition: postgis_ext_defs.in.h:170
API of the Mobility Engine Open Source (MEOS) library.
Definition: meos_npoint.h:52
Definition: meos_npoint.h:60
Structure to represent spatiotemporal boxes.
Definition: meos.h:134
Structure to represent sets of values.
Definition: meos.h:80
Structure to represent temporal values of instant subtype.
Definition: meos.h:185
Structure to represent temporal values of sequence set subtype.
Definition: meos.h:224
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
bool npoint_collinear(const Npoint *np1, const Npoint *np2, const Npoint *np3, double ratio)
Return true if the three values are collinear.
Definition: npoint.c:87
TInstant * tgeompointinst_tnpointinst(const TInstant *inst)
Convert a temporal geometry point into a temporal network point.
Definition: tnpoint.c:363
TSequenceSet * tnpointseqset_tgeompointseqset(const TSequenceSet *ss)
Convert a temporal network point into a temporal geometry point.
Definition: tnpoint.c:322
Set * tnpointseqset_routes(const TSequenceSet *ss)
Return the routes of a temporal network point.
Definition: tnpoint.c:664
Set * tnpointseq_cont_routes(const TSequence *seq)
Return the routes of a temporal network point.
Definition: tnpoint.c:652
void npoint_set(int64 rid, double pos, Npoint *np)
Return in the last argument a network point constructed from a route identifier and a position.
Definition: npoint.c:1129
Datum datum_npoint_round(Datum npoint, Datum size)
Return a network point with the precision of the position set to a number of decimal places.
Definition: npoint.c:1548
TSequenceSet * tgeompointseqset_tnpointseqset(const TSequenceSet *ss)
Convert a temporal geometry point into a temporal network point.
Definition: tnpoint.c:398
void nsegment_set(int64 rid, double pos1, double pos2, Nsegment *ns)
Return in the last argument a network segment constructed from a route identifier and two positions.
Definition: npoint.c:1166
bool ensure_valid_tnpoint_stbox(const Temporal *temp, const STBox *box)
Ensure the validity of a temporal network point and a spatiotemporal box.
Definition: tnpoint.c:153
bool ensure_valid_tnpoint_npoint(const Temporal *temp, const Npoint *np)
Return true if a temporal network point and a network point are valid for operations.
Definition: tnpoint.c:107
char * npoint_wkt_out(Datum value, int maxdd)
Output a network point in the Well-Known Text (WKT) representation (internal function)
Definition: npoint.c:962
long double npointsegm_locate(const Npoint *start, const Npoint *end, const Npoint *value)
Return a float in (0,1) if a network point segment intersects a network point, return -1....
Definition: tnpoint_spatialfuncs.c:81
bool ensure_valid_tnpoint_geo(const Temporal *temp, const GSERIALIZED *gs)
Ensure the validity of a temporal network point and a geometry.
Definition: tnpoint.c:138
int64 tnpointinst_route(const TInstant *inst)
Return the route of the temporal network point.
Definition: tnpoint.c:593
Nsegment ** nsegmentarr_normalize(Nsegment **segments, int *count)
Normalize an array of temporal segments.
Definition: npoint.c:721
Set * tnpointinst_routes(const TInstant *inst)
Return the routes of a temporal network point.
Definition: tnpoint.c:624
bool ensure_valid_tnpoint_tnpoint(const Temporal *temp1, const Temporal *temp2)
Return true if a temporal network point and a network point are valid for operations.
Definition: tnpoint.c:168
Nsegment ** tnpointinst_positions(const TInstant *inst)
Return the network segments covered by the temporal network point.
Definition: tnpoint.c:452
TInstant * tnpointinst_tgeompointinst(const TInstant *inst)
Convert a temporal network point into a temporal geometry point.
Definition: tnpoint.c:266
TSequence * tgeompointseq_tnpointseq(const TSequence *seq)
Convert a temporal geometry point into a temporal network point.
Definition: tnpoint.c:376
Set * tnpointseq_disc_routes(const TSequence *is)
Return the routes of a temporal network point.
Definition: tnpoint.c:635
Npoint * npointsegm_interpolate(const Npoint *start, const Npoint *end, long double ratio)
Return a network point interpolated from a network point segment with respect to a fraction of its to...
Definition: tnpoint_spatialfuncs.c:59
bool common_rid_tnpoint_npoint(const Temporal *temp, const Npoint *np)
Return true if temporal network point and a network point have a common route identifier.
Definition: tnpoint.c:57
Nsegment ** tnpointseq_positions(const TSequence *seq, int *count)
Return the network segments covered by the temporal network point.
Definition: tnpoint.c:504
Nsegment * tnpointseq_linear_positions(const TSequence *seq)
Return the network segments covered by the temporal network point.
Definition: tnpoint.c:485
bool common_rid_tnpoint_tnpoint(const Temporal *temp1, const Temporal *temp2)
TSequence * tnpointseq_tgeompointseq_disc(const TSequence *is)
Convert a temporal network point into a temporal geometry point.
Definition: tnpoint.c:277
Nsegment ** tnpointseqset_positions(const TSequenceSet *ss, int *count)
Return the network segments covered by the temporal network point.
Definition: tnpoint.c:556
bool common_rid_tnpoint_npointset(const Temporal *temp, const Set *s)
Return true if temporal network point and a network point have a common route identifier.
Definition: tnpoint.c:71
bool ensure_valid_tnpoint_npointset(const Temporal *temp, const Set *s)
Return true if a temporal network point and a network point set are valid for operations.
Definition: tnpoint.c:123
TSequence * tnpointseq_tgeompointseq_cont(const TSequence *seq)
Convert a temporal network point into a temporal geometry point.
Definition: tnpoint.c:291
int const GSERIALIZED * gs
Definition: trgeo_spatialrels.h:52