PostgreSQL Source Code  git master
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 DatumGetPointP(X)   ((Point *) DatumGetPointer(X))
 
#define PointPGetDatum(X)   PointerGetDatum(X)
 
#define PG_GETARG_POINT_P(n)   DatumGetPointP(PG_GETARG_DATUM(n))
 
#define PG_RETURN_POINT_P(x)   return PointPGetDatum(x)
 
#define DatumGetLsegP(X)   ((LSEG *) DatumGetPointer(X))
 
#define LsegPGetDatum(X)   PointerGetDatum(X)
 
#define PG_GETARG_LSEG_P(n)   DatumGetLsegP(PG_GETARG_DATUM(n))
 
#define PG_RETURN_LSEG_P(x)   return LsegPGetDatum(x)
 
#define DatumGetPathP(X)   ((PATH *) PG_DETOAST_DATUM(X))
 
#define DatumGetPathPCopy(X)   ((PATH *) PG_DETOAST_DATUM_COPY(X))
 
#define PathPGetDatum(X)   PointerGetDatum(X)
 
#define PG_GETARG_PATH_P(n)   DatumGetPathP(PG_GETARG_DATUM(n))
 
#define PG_GETARG_PATH_P_COPY(n)   DatumGetPathPCopy(PG_GETARG_DATUM(n))
 
#define PG_RETURN_PATH_P(x)   return PathPGetDatum(x)
 
#define DatumGetLineP(X)   ((LINE *) DatumGetPointer(X))
 
#define LinePGetDatum(X)   PointerGetDatum(X)
 
#define PG_GETARG_LINE_P(n)   DatumGetLineP(PG_GETARG_DATUM(n))
 
#define PG_RETURN_LINE_P(x)   return LinePGetDatum(x)
 
#define DatumGetBoxP(X)   ((BOX *) DatumGetPointer(X))
 
#define BoxPGetDatum(X)   PointerGetDatum(X)
 
#define PG_GETARG_BOX_P(n)   DatumGetBoxP(PG_GETARG_DATUM(n))
 
#define PG_RETURN_BOX_P(x)   return BoxPGetDatum(x)
 
#define DatumGetPolygonP(X)   ((POLYGON *) PG_DETOAST_DATUM(X))
 
#define DatumGetPolygonPCopy(X)   ((POLYGON *) PG_DETOAST_DATUM_COPY(X))
 
#define PolygonPGetDatum(X)   PointerGetDatum(X)
 
#define PG_GETARG_POLYGON_P(n)   DatumGetPolygonP(PG_GETARG_DATUM(n))
 
#define PG_GETARG_POLYGON_P_COPY(n)   DatumGetPolygonPCopy(PG_GETARG_DATUM(n))
 
#define PG_RETURN_POLYGON_P(x)   return PolygonPGetDatum(x)
 
#define DatumGetCircleP(X)   ((CIRCLE *) DatumGetPointer(X))
 
#define CirclePGetDatum(X)   PointerGetDatum(X)
 
#define PG_GETARG_CIRCLE_P(n)   DatumGetCircleP(PG_GETARG_DATUM(n))
 
#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)
 
float8 pg_hypot (float8 x, float8 y)
 

Macro Definition Documentation

◆ BoxPGetDatum

◆ CirclePGetDatum

#define CirclePGetDatum (   X)    PointerGetDatum(X)

Definition at line 210 of file geo_decls.h.

Referenced by gist_point_consistent().

◆ DatumGetBoxP

◆ DatumGetCircleP

#define DatumGetCircleP (   X)    ((CIRCLE *) DatumGetPointer(X))

Definition at line 209 of file geo_decls.h.

Referenced by gist_circle_compress().

◆ DatumGetLineP

#define DatumGetLineP (   X)    ((LINE *) DatumGetPointer(X))

Definition at line 192 of file geo_decls.h.

◆ DatumGetLsegP

#define DatumGetLsegP (   X)    ((LSEG *) DatumGetPointer(X))

Definition at line 180 of file geo_decls.h.

◆ DatumGetPathP

#define DatumGetPathP (   X)    ((PATH *) PG_DETOAST_DATUM(X))

Definition at line 185 of file geo_decls.h.

◆ DatumGetPathPCopy

#define DatumGetPathPCopy (   X)    ((PATH *) PG_DETOAST_DATUM_COPY(X))

Definition at line 186 of file geo_decls.h.

◆ DatumGetPointP

◆ DatumGetPolygonP

#define DatumGetPolygonP (   X)    ((POLYGON *) PG_DETOAST_DATUM(X))

Definition at line 202 of file geo_decls.h.

Referenced by gist_poly_compress(), and spg_box_quad_get_scankey_bbox().

◆ DatumGetPolygonPCopy

#define DatumGetPolygonPCopy (   X)    ((POLYGON *) PG_DETOAST_DATUM_COPY(X))

Definition at line 203 of file geo_decls.h.

◆ EPSILON

#define EPSILON   1.0E-06

Definition at line 41 of file geo_decls.h.

Referenced by FPeq(), FPge(), FPgt(), FPle(), FPlt(), and FPne().

◆ FPzero

◆ HYPOT

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

◆ LinePGetDatum

#define LinePGetDatum (   X)    PointerGetDatum(X)

Definition at line 193 of file geo_decls.h.

◆ LsegPGetDatum

#define LsegPGetDatum (   X)    PointerGetDatum(X)

Definition at line 181 of file geo_decls.h.

Referenced by interpt_pp().

◆ PathPGetDatum

#define PathPGetDatum (   X)    PointerGetDatum(X)

Definition at line 187 of file geo_decls.h.

◆ PG_GETARG_BOX_P

◆ PG_GETARG_CIRCLE_P

◆ PG_GETARG_LINE_P

◆ PG_GETARG_LSEG_P

◆ PG_GETARG_PATH_P

◆ PG_GETARG_PATH_P_COPY

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

Definition at line 189 of file geo_decls.h.

Referenced by path_add_pt(), path_close(), path_div_pt(), path_mul_pt(), path_open(), and path_sub_pt().

◆ PG_GETARG_POINT_P

◆ PG_GETARG_POLYGON_P

◆ PG_GETARG_POLYGON_P_COPY

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

Definition at line 206 of file geo_decls.h.

◆ PG_RETURN_BOX_P

#define PG_RETURN_BOX_P (   x)    return BoxPGetDatum(x)

◆ PG_RETURN_CIRCLE_P

#define PG_RETURN_CIRCLE_P (   x)    return CirclePGetDatum(x)

◆ PG_RETURN_LINE_P

#define PG_RETURN_LINE_P (   x)    return LinePGetDatum(x)

Definition at line 195 of file geo_decls.h.

Referenced by line_construct_pp(), line_in(), and line_recv().

◆ PG_RETURN_LSEG_P

#define PG_RETURN_LSEG_P (   x)    return LsegPGetDatum(x)

Definition at line 183 of file geo_decls.h.

Referenced by box_diagonal(), lseg_construct(), lseg_in(), and lseg_recv().

◆ PG_RETURN_PATH_P

#define PG_RETURN_PATH_P (   x)    return PathPGetDatum(x)

◆ PG_RETURN_POINT_P

◆ PG_RETURN_POLYGON_P

#define PG_RETURN_POLYGON_P (   x)    return PolygonPGetDatum(x)

Definition at line 207 of file geo_decls.h.

Referenced by box_poly(), circle_poly(), path_poly(), poly_in(), and poly_recv().

◆ PointPGetDatum

#define PointPGetDatum (   X)    PointerGetDatum(X)

◆ PolygonPGetDatum

#define PolygonPGetDatum (   X)    PointerGetDatum(X)

Definition at line 204 of file geo_decls.h.

Referenced by gist_point_consistent().

Function Documentation

◆ FPeq()

static bool FPeq ( double  A,
double  B 
)
inlinestatic

◆ FPge()

static bool FPge ( double  A,
double  B 
)
inlinestatic

◆ FPgt()

static bool FPgt ( double  A,
double  B 
)
inlinestatic

◆ FPle()

◆ FPlt()

static bool FPlt ( double  A,
double  B 
)
inlinestatic

◆ FPne()

static bool FPne ( double  A,
double  B 
)
inlinestatic

Definition at line 53 of file geo_decls.h.

References EPSILON.

Referenced by circle_ne().

54 {
55  return A != B && fabs(A - B) > EPSILON;
56 }
#define EPSILON
Definition: geo_decls.h:41

◆ pg_hypot()

float8 pg_hypot ( float8  x,
float8  y 
)

Definition at line 5526 of file geo_ops.c.

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

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