forked from postgrespro/pgsphere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpg_sphere.h
100 lines (82 loc) · 2.15 KB
/
pg_sphere.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
#ifndef __PGS_PGSPHERE_H__
#define __PGS_PGSPHERE_H__
/* Base declarations and includes */
/*
* pgSphere is an extra module for PostgreSQL which adds spherical data types. It provides:
*
* - input and output of data
* - containing, overlapping, and other operators
* - various input and converting functions and operators
* - circumference and area of an object
* - spherical transformation
* - indexing of spherical data types
* - several input and output formats
*
* Hence, you can do a fast search and analysis for objects with spherical
* attributes as used in geographical, astronomical, or other applications
* using PostgreSQL. For instance, you can manage data of geographical
* objects around the world and astronomical data like star and other
* catalogs conveniently using an SQL interface.
*
* The aim of pgSphere is to
* provide uniform access to spherical data. Because PostgreSQL itself
* supports a lot of software interfaces, you can now use the same database
* with different utilities and applications.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include "postgres.h"
#include "fmgr.h"
#include "utils/array.h"
#include "utils/elog.h"
#include "utils/builtins.h"
#include "catalog/pg_type.h"
#include "access/skey.h"
#include "access/gist.h"
#include "access/itup.h"
#include "pgs_util.h"
#define EPSILON 1.0E-09
#define FPzero(A) (fabs(A) <= EPSILON)
static inline bool
FPeq(double A, double B)
{
return A == B || fabs(A - B) <= EPSILON;
}
static inline bool
FPne(double A, double B)
{
return A != B && fabs(A - B) > EPSILON;
}
static inline bool
FPlt(double A, double B)
{
return A + EPSILON < B;
}
static inline bool
FPle(double A, double B)
{
return A <= B + EPSILON;
}
static inline bool
FPgt(double A, double B)
{
return A > B + EPSILON;
}
static inline bool
FPge(double A, double B)
{
return A + EPSILON >= B;
}
/*---------------------------------------------------------------------
* Point - (x,y)
*-------------------------------------------------------------------*/
typedef struct
{
float8 x,
y;
} Point;
void sphere_yyparse(void);
#endif