MobilityDB  1.0
tpoint_distance.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 __TPOINT_DISTANCE_H__
33 #define __TPOINT_DISTANCE_H__
34 
35 #include <postgres.h>
36 #include <catalog/pg_type.h>
37 
38 #include "general/temporal.h"
39 #include <liblwgeom.h>
40 #include "tpoint.h"
41 
42 /*****************************************************************************/
43 
44 extern double lw_dist_sphere_point_dist(const LWGEOM *lw1, const LWGEOM *lw2,
45  int mode, long double *fraction);
46 
47 /* Distance functions */
48 
49 extern Datum distance_geo_tpoint(PG_FUNCTION_ARGS);
50 extern Datum distance_tpoint_geo(PG_FUNCTION_ARGS);
51 extern Datum distance_tpoint_tpoint(PG_FUNCTION_ARGS);
52 
53 extern bool tpoint_min_dist_at_timestamp(const TInstant *start1,
54  const TInstant *end1, bool linear1, const TInstant *start2,
55  const TInstant *end2, bool linear2, Datum *value, TimestampTz *t);
56 
57 extern Temporal *distance_tpoint_geo_internal(const Temporal *temp, Datum geo);
59  const Temporal *temp2);
60 
61 /* Nearest approach distance/instance and shortest line functions */
62 
63 extern Datum NAI_geo_tpoint(PG_FUNCTION_ARGS);
64 extern Datum NAI_tpoint_geo(PG_FUNCTION_ARGS);
65 extern Datum NAI_tpoint_tpoint(PG_FUNCTION_ARGS);
66 
67 extern TInstant *NAI_tpoint_geo_internal(FunctionCallInfo fcinfo,
68  const Temporal *temp, GSERIALIZED *gs);
69 
70 extern Datum NAD_geo_tpoint(PG_FUNCTION_ARGS);
71 extern Datum NAD_tpoint_geo(PG_FUNCTION_ARGS);
72 extern Datum NAD_geo_stbox(PG_FUNCTION_ARGS);
73 extern Datum NAD_stbox_geo(PG_FUNCTION_ARGS);
74 extern Datum NAD_stbox_stbox(PG_FUNCTION_ARGS);
75 extern Datum NAD_stbox_tpoint(PG_FUNCTION_ARGS);
76 extern Datum NAD_tpoint_stbox(PG_FUNCTION_ARGS);
77 extern Datum NAD_tpoint_tpoint(PG_FUNCTION_ARGS);
78 
79 extern double NAD_stbox_stbox_internal(const STBOX *box1, const STBOX *box2);
80 
81 extern Datum shortestline_geo_tpoint(PG_FUNCTION_ARGS);
82 extern Datum shortestline_tpoint_geo(PG_FUNCTION_ARGS);
83 extern Datum shortestline_tpoint_tpoint(PG_FUNCTION_ARGS);
84 
85 extern bool shortestline_tpoint_tpoint_internal(const Temporal *temp1,
86  const Temporal *temp2, Datum *line);
87 
88 /*****************************************************************************/
89 
90 #endif
Datum shortestline_tpoint_geo(PG_FUNCTION_ARGS)
Returns the line connecting the nearest approach point between the temporal instant point and the geo...
Definition: tpoint_distance.c:1242
Temporal * distance_tpoint_geo_internal(const Temporal *temp, Datum geo)
Returns the temporal distance between the temporal point and the geometry/geography point (distpatch ...
Definition: tpoint_distance.c:391
bool tpoint_min_dist_at_timestamp(const TInstant *start1, const TInstant *end1, bool linear1, const TInstant *start2, const TInstant *end2, bool linear2, Datum *value, TimestampTz *t)
Returns the value and timestamp at which the two temporal point segments are at the minimum distance ...
Definition: tpoint_distance.c:373
Datum distance_tpoint_geo(PG_FUNCTION_ARGS)
Returns the temporal distance between the temporal point and the geometry/geography point...
Definition: tpoint_distance.c:438
Datum NAI_geo_tpoint(PG_FUNCTION_ARGS)
Returns the nearest approach instant between the geometry and the temporal point. ...
Definition: tpoint_distance.c:813
Datum NAD_geo_stbox(PG_FUNCTION_ARGS)
Returns the nearest approach distance between the geometry and the spatiotemporal box...
Definition: tpoint_distance.c:978
double lw_dist_sphere_point_dist(const LWGEOM *lw1, const LWGEOM *lw2, int mode, long double *fraction)
Compute the projected point and the distance between the closest point (geodetic version).
Definition: tpoint_distance.c:119
Datum shortestline_tpoint_tpoint(PG_FUNCTION_ARGS)
Returns the line connecting the nearest approach point between the temporal points.
Definition: tpoint_distance.c:1281
Structure to represent the common structure of temporal values of any temporal subtype.
Definition: temporal.h:241
Structure to represent spatiotemporal boxes.
Definition: stbox.h:51
Datum NAD_geo_tpoint(PG_FUNCTION_ARGS)
Returns the nearest approach distance between the geometry and the temporal point.
Definition: tpoint_distance.c:910
Datum NAD_tpoint_stbox(PG_FUNCTION_ARGS)
Returns the nearest approach distance between the temporal point and the spatio-temporal box...
Definition: tpoint_distance.c:1149
double NAD_stbox_stbox_internal(const STBOX *box1, const STBOX *box2)
Returns the nearest approach distance between the spatio-temporal boxes (internal function) ...
Definition: tpoint_distance.c:1011
Functions for temporal points.
Basic functions for temporal types of any subtype.
Datum NAD_stbox_geo(PG_FUNCTION_ARGS)
Returns the nearest approach distance between the spatiotemporal box and the geometry.
Definition: tpoint_distance.c:995
Datum distance_tpoint_tpoint(PG_FUNCTION_ARGS)
Returns the temporal distance between the two temporal points.
Definition: tpoint_distance.c:482
Datum distance_geo_tpoint(PG_FUNCTION_ARGS)
Returns the temporal distance between the geometry/geography point and the temporal point...
Definition: tpoint_distance.c:415
Datum NAI_tpoint_geo(PG_FUNCTION_ARGS)
Returns the nearest approach instant between the temporal point and the geometry. ...
Definition: tpoint_distance.c:831
Datum NAD_stbox_stbox(PG_FUNCTION_ARGS)
Returns the nearest approach distance between the spatio-temporal boxes.
Definition: tpoint_distance.c:1062
TInstant * NAI_tpoint_geo_internal(FunctionCallInfo fcinfo, const Temporal *temp, GSERIALIZED *gs)
Returns the nearest approach instant between the temporal point and the geometry (dispatch function) ...
Definition: tpoint_distance.c:782
Datum NAI_tpoint_tpoint(PG_FUNCTION_ARGS)
Returns the nearest approach instant between the temporal points.
Definition: tpoint_distance.c:848
bool shortestline_tpoint_tpoint_internal(const Temporal *temp1, const Temporal *temp2, Datum *line)
Returns the line connecting the nearest approach point between the temporal points.
Definition: tpoint_distance.c:1259
Datum NAD_tpoint_tpoint(PG_FUNCTION_ARGS)
Returns the nearest approach distance between the temporal points.
Definition: tpoint_distance.c:1167
Datum NAD_stbox_tpoint(PG_FUNCTION_ARGS)
Returns the nearest approach distance between the spatio-temporal box and the temporal point...
Definition: tpoint_distance.c:1130
Datum NAD_tpoint_geo(PG_FUNCTION_ARGS)
Returns the nearest approach distance between the temporal point and the geometry.
Definition: tpoint_distance.c:928
Datum shortestline_geo_tpoint(PG_FUNCTION_ARGS)
Returns the line connecting the nearest approach point between the geometry and the temporal instant ...
Definition: tpoint_distance.c:1224
Temporal * distance_tpoint_tpoint_internal(const Temporal *temp1, const Temporal *temp2)
Returns the temporal distance between the two temporal points (dispatch function) ...
Definition: tpoint_distance.c:460
Structure to represent temporal values of instant subtype.
Definition: temporal.h:253