-
Notifications
You must be signed in to change notification settings - Fork 3
/
point.h
141 lines (118 loc) · 3.43 KB
/
point.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef __PGS_POINT_H__
#define __PGS_POINT_H__
#include "vector3d.h"
#include "sbuffer.h"
/*!
\file
This file contains declaration for spherical
point and functions
\brief spherical point declarations
*/
/*!
The definition of spherical point.
\brief Spherical point
*/
typedef struct {
float8 lng; //!< longitude value in radians
float8 lat; //!< latitude value in radians
} SPoint;
/*!
Calculate the distance of two spherical points
\brief Distance of two spherical points
\return distance in radians
*/
float8 spoint_dist ( const SPoint * p1, const SPoint * p2 );
/*!
\brief check whether two points are equal
\param p1 first point
\param p2 second point
\return true, if equal
*/
bool spoint_eq ( const SPoint * p1 , const SPoint * p2 );
/*!
Checks the longitude and latitude values and take sure
the right value ranges
\brief validate the spherical point
\param spoint pointer to spherical point
\return pointer to spherical point
*/
SPoint * spoint_check (SPoint * spoint);
/*!
\brief transforms a 3 dim.vector to a spherical point
\param p pointer to spherical point
\param v pointer to 3 dim. vector
\return pointer to spherical point
*/
SPoint * vector3d_spoint ( SPoint * p , const Vector3D * v );
/*!
\brief transforms a spherical point to a 3 dim.vector
\param v pointer to 3 dim. vector
\param p pointer to spherical point
\return pointer to 3 dim. vector
*/
Vector3D * spoint_vector3d ( Vector3D * v , const SPoint * p );
/*!
Take the input and stores it as a spherical point
\return a spherical point datum
\note Does check the input too.
*/
Datum spherepoint_in(PG_FUNCTION_ARGS);
/*!
Create a spherical point from longitude
and latitude both in radians
\brief point created from longitude and latitude
\return a spherical point datum
\note PostgreSQL function
*/
Datum spherepoint_from_long_lat(PG_FUNCTION_ARGS);
/*!
Calculate the distance of two spherical points
\brief Distance of two spherical points
\return distance ( float8 ) as datum
\see spoint_dist ( SPoint *, SPoint * )
\note PostgreSQL function
*/
Datum spherepoint_distance(PG_FUNCTION_ARGS);
/*!
\brief longitude of spherical point
\return longitude datum in radians ( float8 )
\note PostgreSQL function
*/
Datum spherepoint_long(PG_FUNCTION_ARGS);
/*!
\brief latitude of spherical point
\return latitude datum in radians ( float8 )
\note PostgreSQL function
*/
Datum spherepoint_lat(PG_FUNCTION_ARGS);
/*!
\brief cartesian x-value of spherical point
\return x-value datum ( float8 )
\note PostgreSQL function
*/
Datum spherepoint_x(PG_FUNCTION_ARGS);
/*!
\brief cartesian y-value of spherical point
\return y-value datum ( float8 )
\note PostgreSQL function
*/
Datum spherepoint_y(PG_FUNCTION_ARGS);
/*!
\brief cartesian z-value of spherical point
\return z-value datum ( float8 )
\note PostgreSQL function
*/
Datum spherepoint_z(PG_FUNCTION_ARGS);
/*!
\brief cartesian values of spherical point
\return array datum ( float8 )
\note PostgreSQL function
*/
Datum spherepoint_xyz(PG_FUNCTION_ARGS);
/*!
\brief check whether two points are equal
\return boolean datum
\note PostgreSQL function
*/
Datum spherepoint_equal(PG_FUNCTION_ARGS);
#endif