PostgreSQL Source Code git master
Data Structures | Macros | Functions
geo_decls.h File Reference
#include <math.h>
#include "fmgr.h"
Include dependency graph for geo_decls.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct   Point
 
struct   LSEG
 
struct   PATH
 
struct   LINE
 
struct   BOX
 
struct   POLYGON
 
struct   CIRCLE
 

Macros

#define  EPSILON   1.0E-06
 
#define  FPzero(A)   (fabs(A) <= EPSILON)
 
#define  HYPOT(A, B)   pg_hypot(A, B)
 
 
#define  PG_RETURN_POINT_P(x)   return PointPGetDatum(x)
 
 
#define  PG_RETURN_LSEG_P(x)   return LsegPGetDatum(x)
 
 
 
#define  PG_RETURN_PATH_P(x)   return PathPGetDatum(x)
 
 
#define  PG_RETURN_LINE_P(x)   return LinePGetDatum(x)
 
 
#define  PG_RETURN_BOX_P(x)   return BoxPGetDatum(x)
 
 
 
#define  PG_RETURN_POLYGON_P(x)   return PolygonPGetDatum(x)
 
 
#define  PG_RETURN_CIRCLE_P(x)   return CirclePGetDatum(x)
 

Functions

static bool  FPeq (double A, double B)
 
static bool  FPne (double A, double B)
 
static bool  FPlt (double A, double B)
 
static bool  FPle (double A, double B)
 
static bool  FPgt (double A, double B)
 
static bool  FPge (double A, double B)
 
static PointDatumGetPointP (Datum X)
 
static Datum  PointPGetDatum (const Point *X)
 
static LSEGDatumGetLsegP (Datum X)
 
static Datum  LsegPGetDatum (const LSEG *X)
 
static PATHDatumGetPathP (Datum X)
 
static PATHDatumGetPathPCopy (Datum X)
 
static Datum  PathPGetDatum (const PATH *X)
 
static LINEDatumGetLineP (Datum X)
 
static Datum  LinePGetDatum (const LINE *X)
 
static BOXDatumGetBoxP (Datum X)
 
static Datum  BoxPGetDatum (const BOX *X)
 
 
 
static Datum  PolygonPGetDatum (const POLYGON *X)
 
static CIRCLEDatumGetCircleP (Datum X)
 
static Datum  CirclePGetDatum (const CIRCLE *X)
 
 

Macro Definition Documentation

EPSILON

#define EPSILON   1.0E-06

Definition at line 41 of file geo_decls.h.

FPzero

#define FPzero (   A )    (fabs(A) <= EPSILON)

Definition at line 44 of file geo_decls.h.

HYPOT

#define HYPOT (   A,
  B 
)    pg_hypot(A, B)

Definition at line 91 of file geo_decls.h.

PG_GETARG_BOX_P

#define PG_GETARG_BOX_P (   n )    DatumGetBoxP(PG_GETARG_DATUM(n))

Definition at line 243 of file geo_decls.h.

PG_GETARG_CIRCLE_P

#define PG_GETARG_CIRCLE_P (   n )    DatumGetCircleP(PG_GETARG_DATUM(n))

Definition at line 275 of file geo_decls.h.

PG_GETARG_LINE_P

#define PG_GETARG_LINE_P (   n )    DatumGetLineP(PG_GETARG_DATUM(n))

Definition at line 230 of file geo_decls.h.

PG_GETARG_LSEG_P

#define PG_GETARG_LSEG_P (   n )    DatumGetLsegP(PG_GETARG_DATUM(n))

Definition at line 198 of file geo_decls.h.

PG_GETARG_PATH_P

#define PG_GETARG_PATH_P (   n )    DatumGetPathP(PG_GETARG_DATUM(n))

Definition at line 216 of file geo_decls.h.

PG_GETARG_PATH_P_COPY

#define PG_GETARG_PATH_P_COPY (   n )    DatumGetPathPCopy(PG_GETARG_DATUM(n))

Definition at line 217 of file geo_decls.h.

PG_GETARG_POINT_P

#define PG_GETARG_POINT_P (   n )    DatumGetPointP(PG_GETARG_DATUM(n))

Definition at line 185 of file geo_decls.h.

PG_GETARG_POLYGON_P

#define PG_GETARG_POLYGON_P (   n )    DatumGetPolygonP(PG_GETARG_DATUM(n))

Definition at line 261 of file geo_decls.h.

PG_GETARG_POLYGON_P_COPY

#define PG_GETARG_POLYGON_P_COPY (   n )    DatumGetPolygonPCopy(PG_GETARG_DATUM(n))

Definition at line 262 of file geo_decls.h.

PG_RETURN_BOX_P

#define PG_RETURN_BOX_P (   x )    return BoxPGetDatum(x)

Definition at line 244 of file geo_decls.h.

PG_RETURN_CIRCLE_P

#define PG_RETURN_CIRCLE_P (   x )    return CirclePGetDatum(x)

Definition at line 276 of file geo_decls.h.

PG_RETURN_LINE_P

#define PG_RETURN_LINE_P (   x )    return LinePGetDatum(x)

Definition at line 231 of file geo_decls.h.

PG_RETURN_LSEG_P

#define PG_RETURN_LSEG_P (   x )    return LsegPGetDatum(x)

Definition at line 199 of file geo_decls.h.

PG_RETURN_PATH_P

#define PG_RETURN_PATH_P (   x )    return PathPGetDatum(x)

Definition at line 218 of file geo_decls.h.

PG_RETURN_POINT_P

#define PG_RETURN_POINT_P (   x )    return PointPGetDatum(x)

Definition at line 186 of file geo_decls.h.

PG_RETURN_POLYGON_P

#define PG_RETURN_POLYGON_P (   x )    return PolygonPGetDatum(x)

Definition at line 263 of file geo_decls.h.

Function Documentation

BoxPGetDatum()

static Datum BoxPGetDatum ( const BOXX )
inlinestatic

Definition at line 239 of file geo_decls.h.

240{
241 return PointerGetDatum(X);
242}
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:332

References PointerGetDatum().

Referenced by fallbackSplit(), gist_point_compress(), spg_box_quad_choose(), spg_box_quad_leaf_consistent(), spg_box_quad_picksplit(), spg_kd_inner_consistent(), and spg_quad_inner_consistent().

CirclePGetDatum()

static Datum CirclePGetDatum ( const CIRCLEX )
inlinestatic

Definition at line 271 of file geo_decls.h.

272{
273 return PointerGetDatum(X);
274}

References PointerGetDatum().

Referenced by gist_point_consistent().

DatumGetBoxP()

static BOX * DatumGetBoxP ( Datum  X )
inlinestatic

Definition at line 234 of file geo_decls.h.

235{
236 return (BOX *) DatumGetPointer(X);
237}
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:322
Definition: geo_decls.h:141

References DatumGetPointer().

Referenced by fallbackSplit(), gist_bbox_distance(), gist_bbox_zorder_abbrev_convert(), gist_bbox_zorder_cmp(), gist_box_consistent(), gist_box_penalty(), gist_box_picksplit(), gist_box_union(), gist_circle_consistent(), gist_point_consistent(), gist_point_distance(), gist_point_fetch(), gist_poly_consistent(), spg_box_quad_choose(), spg_box_quad_get_scankey_bbox(), spg_box_quad_inner_consistent(), spg_box_quad_picksplit(), spg_kd_inner_consistent(), spg_key_orderbys_distances(), and spg_quad_inner_consistent().

DatumGetCircleP()

static CIRCLE * DatumGetCircleP ( Datum  X )
inlinestatic

Definition at line 266 of file geo_decls.h.

267{
268 return (CIRCLE *) DatumGetPointer(X);
269}
Definition: geo_decls.h:163

References DatumGetPointer().

Referenced by gist_circle_compress().

DatumGetLineP()

static LINE * DatumGetLineP ( Datum  X )
inlinestatic

Definition at line 221 of file geo_decls.h.

222{
223 return (LINE *) DatumGetPointer(X);
224}
Definition: geo_decls.h:129

References DatumGetPointer().

DatumGetLsegP()

static LSEG * DatumGetLsegP ( Datum  X )
inlinestatic

Definition at line 189 of file geo_decls.h.

190{
191 return (LSEG *) DatumGetPointer(X);
192}
Definition: geo_decls.h:107

References DatumGetPointer().

DatumGetPathP()

static PATH * DatumGetPathP ( Datum  X )
inlinestatic

Definition at line 202 of file geo_decls.h.

203{
204 return (PATH *) PG_DETOAST_DATUM(X);
205}
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:240
Definition: geo_decls.h:116

References PG_DETOAST_DATUM.

DatumGetPathPCopy()

static PATH * DatumGetPathPCopy ( Datum  X )
inlinestatic

Definition at line 207 of file geo_decls.h.

208{
209 return (PATH *) PG_DETOAST_DATUM_COPY(X);
210}
#define PG_DETOAST_DATUM_COPY(datum)
Definition: fmgr.h:242

References PG_DETOAST_DATUM_COPY.

DatumGetPointP()

static Point * DatumGetPointP ( Datum  X )
inlinestatic

Definition at line 176 of file geo_decls.h.

177{
178 return (Point *) DatumGetPointer(X);
179}
Definition: geo_decls.h:97

References DatumGetPointer().

Referenced by gist_bbox_distance(), gist_point_compress(), spg_box_quad_inner_consistent(), spg_kd_choose(), spg_kd_inner_consistent(), spg_kd_picksplit(), spg_key_orderbys_distances(), spg_quad_choose(), spg_quad_inner_consistent(), spg_quad_leaf_consistent(), and spg_quad_picksplit().

DatumGetPolygonP()

static POLYGON * DatumGetPolygonP ( Datum  X )
inlinestatic

Definition at line 247 of file geo_decls.h.

248{
249 return (POLYGON *) PG_DETOAST_DATUM(X);
250}

References PG_DETOAST_DATUM.

Referenced by gist_poly_compress(), and spg_box_quad_get_scankey_bbox().

DatumGetPolygonPCopy()

static POLYGON * DatumGetPolygonPCopy ( Datum  X )
inlinestatic

Definition at line 252 of file geo_decls.h.

253{
254 return (POLYGON *) PG_DETOAST_DATUM_COPY(X);
255}

References PG_DETOAST_DATUM_COPY.

FPeq()

static bool FPeq ( double  A,
double  B 
)
inlinestatic

Definition at line 47 of file geo_decls.h.

48{
49 return A == B || fabs(A - B) <= EPSILON;
50}
#define EPSILON
Definition: geo_decls.h:41

References EPSILON.

Referenced by box_eq(), circle_eq(), circle_same(), gist_point_consistent_internal(), line_eq(), line_interpt_line(), line_perp(), lseg_contain_point(), lseg_horizontal(), lseg_parallel(), lseg_perp(), lseg_vertical(), on_ppath(), point_eq_point(), point_horiz(), point_invsl(), point_sl(), and point_vert().

FPge()

static bool FPge ( double  A,
double  B 
)
inlinestatic

Definition at line 77 of file geo_decls.h.

78{
79 return A + EPSILON >= B;
80}

References EPSILON.

Referenced by box_above_eq(), box_contain_box(), box_ge(), box_overabove(), box_overright(), circle_ge(), circle_overabove(), circle_overright(), contain2D(), contained2D(), gist_point_consistent_internal(), lseg_crossing(), lseg_ge(), overHigher2D(), and overlap2D().

FPgt()

static bool FPgt ( double  A,
double  B 
)
inlinestatic

Definition at line 71 of file geo_decls.h.

72{
73 return A > B + EPSILON;
74}

References EPSILON.

Referenced by box_above(), box_gt(), box_right(), circle_above(), circle_gt(), circle_right(), gist_point_consistent_internal(), higher2D(), lseg_crossing(), lseg_gt(), point_above(), point_right(), and spg_kd_inner_consistent().

FPle()

static bool FPle ( double  A,
double  B 
)
inlinestatic

Definition at line 65 of file geo_decls.h.

66{
67 return A <= B + EPSILON;
68}

References EPSILON.

Referenced by box_below_eq(), box_contain_box(), box_le(), box_ov(), box_overbelow(), box_overleft(), circle_contain(), circle_contained(), circle_le(), circle_overbelow(), circle_overlap(), circle_overleft(), contain2D(), contained2D(), gist_point_consistent_internal(), lseg_crossing(), lseg_le(), overlap2D(), and overLower2D().

FPlt()

static bool FPlt ( double  A,
double  B 
)
inlinestatic

Definition at line 59 of file geo_decls.h.

60{
61 return A + EPSILON < B;
62}

References EPSILON.

Referenced by box_below(), box_left(), box_lt(), circle_below(), circle_left(), circle_lt(), gist_point_consistent_internal(), lower2D(), lseg_crossing(), lseg_lt(), point_below(), point_left(), and spg_kd_inner_consistent().

FPne()

static bool FPne ( double  A,
double  B 
)
inlinestatic

Definition at line 53 of file geo_decls.h.

54{
55 return A != B && fabs(A - B) > EPSILON;
56}

References EPSILON.

Referenced by circle_ne().

LinePGetDatum()

static Datum LinePGetDatum ( const LINEX )
inlinestatic

Definition at line 226 of file geo_decls.h.

227{
228 return PointerGetDatum(X);
229}

References PointerGetDatum().

LsegPGetDatum()

static Datum LsegPGetDatum ( const LSEGX )
inlinestatic

Definition at line 194 of file geo_decls.h.

195{
196 return PointerGetDatum(X);
197}

References PointerGetDatum().

Referenced by interpt_pp().

PathPGetDatum()

static Datum PathPGetDatum ( const PATHX )
inlinestatic

Definition at line 212 of file geo_decls.h.

213{
214 return PointerGetDatum(X);
215}

References PointerGetDatum().

pg_hypot()

float8 pg_hypot ( float8  x,
float8  y 
)

Definition at line 5519 of file geo_ops.c.

5520{
5521 float8 yx,
5522 result;
5523
5524 /* Handle INF and NaN properly */
5525 if (isinf(x) || isinf(y))
5526 return get_float8_infinity();
5527
5528 if (isnan(x) || isnan(y))
5529 return get_float8_nan();
5530
5531 /* Else, drop any minus signs */
5532 x = fabs(x);
5533 y = fabs(y);
5534
5535 /* Swap x and y if needed to make x the larger one */
5536 if (x < y)
5537 {
5538 float8 temp = x;
5539
5540 x = y;
5541 y = temp;
5542 }
5543
5544 /*
5545 * If y is zero, the hypotenuse is x. This test saves a few cycles in
5546 * such cases, but more importantly it also protects against
5547 * divide-by-zero errors, since now x >= y.
5548 */
5549 if (y == 0.0)
5550 return x;
5551
5552 /* Determine the hypotenuse */
5553 yx = y / x;
5554 result = x * sqrt(1.0 + (yx * yx));
5555
5556 if (unlikely(isinf(result)))
5558 if (unlikely(result == 0.0))
5560
5561 return result;
5562}
double float8
Definition: c.h:635
#define unlikely(x)
Definition: c.h:402
pg_noinline void float_overflow_error(void)
Definition: float.c:86
pg_noinline void float_underflow_error(void)
Definition: float.c:94
static float8 get_float8_infinity(void)
Definition: float.h:94
static float8 get_float8_nan(void)
Definition: float.h:123
y
int y
Definition: isn.c:76
x
int x
Definition: isn.c:75

References float_overflow_error(), float_underflow_error(), get_float8_infinity(), get_float8_nan(), unlikely, x, and y.

PointPGetDatum()

static Datum PointPGetDatum ( const PointX )
inlinestatic

Definition at line 181 of file geo_decls.h.

182{
183 return PointerGetDatum(X);
184}

References PointerGetDatum().

Referenced by gist_point_consistent(), pt_in_widget(), spg_kd_choose(), spg_kd_picksplit(), spg_quad_choose(), and spg_quad_picksplit().

PolygonPGetDatum()

static Datum PolygonPGetDatum ( const POLYGONX )
inlinestatic

Definition at line 257 of file geo_decls.h.

258{
259 return PointerGetDatum(X);
260}

References PointerGetDatum().

Referenced by gist_point_consistent().

AltStyle によって変換されたページ (->オリジナル) /