MobilityDB 1.1
tnpoint_static.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * This MobilityDB code is provided under The PostgreSQL License.
4 * Copyright (c) 2016-2023, 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-2023, 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_STATIC_H__
35#define __TNPOINT_STATIC_H__
36
37/* PostgreSQL */
38#include <postgres.h>
39/* MEOS */
40#include "npoint/tnpoint.h"
41
42/*****************************************************************************/
43
44/* General functions */
45
46extern int32_t get_srid_ways();
47extern GSERIALIZED *npointarr_geom(Npoint **points, int count);
48extern GSERIALIZED *nsegmentarr_geom(Nsegment **segments, int count);
49extern Nsegment **nsegmentarr_normalize(Nsegment **segments, int *count);
50
51/* Input/Output functions */
52
53extern Npoint *npoint_in(const char *str, bool end);
54extern char *npoint_out(const Npoint *np, int maxdd);
55
56/* Constructor functions */
57
58extern Npoint *npoint_make(int64 rid, double pos);
59extern void npoint_set(int64 rid, double pos, Npoint *np);
60extern Nsegment *nsegment_make(int64 rid, double pos1, double pos2);
61extern void nsegment_set(int64 rid, double pos1, double pos2, Nsegment *ns);
62
63/* Cast functions */
64
65extern Nsegment *npoint_to_nsegment(const Npoint *np);
66
67/* Input/output functions */
68
69extern Nsegment *nsegment_in(const char *str);
70extern char *nsegment_out(const Nsegment *ns, int maxdd);
71
72/* Accessor functions */
73
74extern int64 npoint_route(const Npoint *np);
75extern double npoint_position(const Npoint *np);
76extern int64 nsegment_route(const Nsegment *ns);
77extern double nsegment_start_position(const Nsegment *ns);
78extern double nsegment_end_position(const Nsegment *ns);
79
80/* Conversions between network and Euclidean space */
81
82extern bool route_exists(int64 rid);
83extern double route_length(int64 rid);
84extern GSERIALIZED *route_geom(int64 rid);
85extern GSERIALIZED *npoint_geom(const Npoint *np);
86extern Npoint *geom_npoint(const GSERIALIZED *gs);
87extern GSERIALIZED *nsegment_geom(const Nsegment *ns);
88extern Nsegment *geom_nsegment(const GSERIALIZED *gs);
89
90/* SRID functions */
91
92extern int npoint_srid(const Npoint *np);
93extern int nsegment_srid(const Nsegment *ns);
94
95/* Comparison functions */
96
97extern bool npoint_eq(const Npoint *np1, const Npoint *np2);
98extern bool npoint_ne(const Npoint *np1, const Npoint *np2);
99extern int npoint_cmp(const Npoint *np1, const Npoint *np2);
100extern bool npoint_lt(const Npoint *np1, const Npoint *np2);
101extern bool npoint_le(const Npoint *np1, const Npoint *np2);
102extern bool npoint_gt(const Npoint *np1, const Npoint *np2);
103extern bool npoint_ge(const Npoint *np1, const Npoint *np2);
104
105extern bool nsegment_eq(const Nsegment *ns1, const Nsegment *ns2);
106extern bool nsegment_ne(const Nsegment *ns1, const Nsegment *ns2);
107extern int nsegment_cmp(const Nsegment *ns1, const Nsegment *ns2);
108extern bool nsegment_lt(const Nsegment *ns1, const Nsegment *ns2);
109extern bool nsegment_le(const Nsegment *ns1, const Nsegment *ns2);
110extern bool nsegment_gt(const Nsegment *ns1, const Nsegment *ns2);
111extern bool nsegment_ge(const Nsegment *ns1, const Nsegment *ns2);
112
113/* Hash functions */
114
115extern uint32 npoint_hash(const Npoint *np);
116extern uint64 npoint_hash_extended(const Npoint *np, uint64 seed);
117
118/*****************************************************************************/
119
120#endif /* __TNPOINT_STATIC_H__ */
bool nsegment_ne(const Nsegment *ns1, const Nsegment *ns2)
Return true if the first network segment is not equal to the second one.
Definition: tnpoint_static.c:802
GSERIALIZED * npointarr_geom(Npoint **points, int count)
Convert a network point array into a geometry.
Definition: tnpoint_static.c:99
int npoint_cmp(const Npoint *np1, const Npoint *np2)
Return -1, 0, or 1 depending on whether the first network point is less than, equal,...
Definition: tnpoint_static.c:730
Nsegment * nsegment_in(const char *str)
Return a network point from its string representation.
Definition: tnpoint_static.c:276
char * npoint_out(const Npoint *np, int maxdd)
Return the string representation of a network point.
Definition: tnpoint_static.c:260
uint32 npoint_hash(const Npoint *np)
Return the 32-bit hash value of a network point.
Definition: tnpoint_static.c:885
void npoint_set(int64 rid, double pos, Npoint *np)
Set a network segment from the arguments.
Definition: tnpoint_static.c:316
Npoint * geom_npoint(const GSERIALIZED *gs)
Transforms the geometry into a network point.
Definition: tnpoint_static.c:557
Nsegment * geom_nsegment(const GSERIALIZED *gs)
Transforms the geometry into a network segment.
Definition: tnpoint_static.c:618
bool nsegment_gt(const Nsegment *ns1, const Nsegment *ns2)
Return true if the first network segment is greater than the second one.
Definition: tnpoint_static.c:858
void nsegment_set(int64 rid, double pos1, double pos2, Nsegment *ns)
Set a network segment from the arguments.
Definition: tnpoint_static.c:346
int nsegment_srid(const Nsegment *ns)
Return the SRID of the network segment.
Definition: tnpoint_static.c:693
double route_length(int64 rid)
Access the edge table to return the route length from the corresponding route identifier.
Definition: tnpoint_static.c:452
bool npoint_lt(const Npoint *np1, const Npoint *np2)
Return true if the first network point is less than the second one.
Definition: tnpoint_static.c:748
bool npoint_ge(const Npoint *np1, const Npoint *np2)
Return true if the first network point is greater than or equal to the second one.
Definition: tnpoint_static.c:780
bool nsegment_le(const Nsegment *ns1, const Nsegment *ns2)
Return true if the first network segment is less than or equal to the second one.
Definition: tnpoint_static.c:848
double npoint_position(const Npoint *np)
Return the position of the network point.
Definition: tnpoint_static.c:388
bool nsegment_eq(const Nsegment *ns1, const Nsegment *ns2)
Return true if the first network segment is equal to the second one.
Definition: tnpoint_static.c:792
GSERIALIZED * nsegment_geom(const Nsegment *ns)
Transforms the network segment into a geometry.
Definition: tnpoint_static.c:602
GSERIALIZED * npoint_geom(const Npoint *np)
Transforms the network point into a geometry.
Definition: tnpoint_static.c:545
int64 nsegment_route(const Nsegment *ns)
Return the route of the network segment.
Definition: tnpoint_static.c:397
bool route_exists(int64 rid)
Return true if the edge table contains a route with the route identifier.
Definition: tnpoint_static.c:428
Npoint * npoint_in(const char *str, bool end)
Return a network point from its string representation.
Definition: tnpoint_static.c:251
Nsegment ** nsegmentarr_normalize(Nsegment **segments, int *count)
Normalize the array of temporal segments.
Definition: tnpoint_static.c:200
Npoint * npoint_make(int64 rid, double pos)
Construct a network segment from the arguments.
Definition: tnpoint_static.c:304
Nsegment * npoint_to_nsegment(const Npoint *np)
Cast a network point as a network segment.
Definition: tnpoint_static.c:366
double nsegment_end_position(const Nsegment *ns)
Return the end position of the network segment.
Definition: tnpoint_static.c:415
GSERIALIZED * nsegmentarr_geom(Nsegment **segments, int count)
Convert a network segment array into a geometry.
Definition: tnpoint_static.c:130
bool npoint_le(const Npoint *np1, const Npoint *np2)
Return true if the first network point is less than or equal to the second one.
Definition: tnpoint_static.c:759
int npoint_srid(const Npoint *np)
Return the SRID of the network point.
Definition: tnpoint_static.c:681
uint64 npoint_hash_extended(const Npoint *np, uint64 seed)
Return the 32-bit hash value of a network point.
Definition: tnpoint_static.c:902
bool npoint_gt(const Npoint *np1, const Npoint *np2)
Return true if the first network point is greater than the second one.
Definition: tnpoint_static.c:769
bool npoint_eq(const Npoint *np1, const Npoint *np2)
Return true if the first network point is equal to the second one.
Definition: tnpoint_static.c:709
int nsegment_cmp(const Nsegment *ns1, const Nsegment *ns2)
Return -1, 0, or 1 depending on whether the first network segment is less than, equal,...
Definition: tnpoint_static.c:814
bool npoint_ne(const Npoint *np1, const Npoint *np2)
Return true if the first network point is not equal to the second one.
Definition: tnpoint_static.c:718
bool nsegment_lt(const Nsegment *ns1, const Nsegment *ns2)
Return true if the first network segment is less than the second one.
Definition: tnpoint_static.c:837
char * nsegment_out(const Nsegment *ns, int maxdd)
Output function for network segments.
Definition: tnpoint_static.c:285
GSERIALIZED * route_geom(int64 rid)
Access the edge table to get the route geometry from corresponding route identifier.
Definition: tnpoint_static.c:480
int32_t get_srid_ways()
Network-based static point/segments.
Definition: tnpoint_static.c:70
double nsegment_start_position(const Nsegment *ns)
Return the start position of the network segment.
Definition: tnpoint_static.c:406
Nsegment * nsegment_make(int64 rid, double pos1, double pos2)
Construct a network segment from the arguments.
Definition: tnpoint_static.c:334
bool nsegment_ge(const Nsegment *ns1, const Nsegment *ns2)
Return true if the first network segment is greater than or equal to the second one.
Definition: tnpoint_static.c:869
int64 npoint_route(const Npoint *np)
Return the route of the network point.
Definition: tnpoint_static.c:379
unsigned int uint32
Definition: pg_ext_defs.in.h:13
unsigned long int uint64
Definition: pg_ext_defs.in.h:14
long int int64
Definition: pg_ext_defs.in.h:9
Definition: postgis_ext_defs.in.h:139
Functions for temporal network points.
Definition: tnpoint.h:50
Definition: tnpoint.h:58