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

#define BoxPGetDatum (   X)    PointerGetDatum(X)

Definition at line 198 of file geo_decls.h.

◆ CirclePGetDatum

#define CirclePGetDatum (   X)    PointerGetDatum(X)

Definition at line 210 of file geo_decls.h.

◆ DatumGetBoxP

#define DatumGetBoxP (   X)    ((BOX *) DatumGetPointer(X))

Definition at line 197 of file geo_decls.h.

◆ DatumGetCircleP

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

Definition at line 209 of file geo_decls.h.

◆ 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

#define DatumGetPointP (   X)    ((Point *) DatumGetPointer(X))

Definition at line 175 of file geo_decls.h.

◆ DatumGetPolygonP

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

Definition at line 202 of file geo_decls.h.

◆ 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.

◆ FPzero

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

Definition at line 44 of file geo_decls.h.

◆ HYPOT

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

Definition at line 91 of file geo_decls.h.

◆ 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.

◆ PathPGetDatum

#define PathPGetDatum (   X)    PointerGetDatum(X)

Definition at line 187 of file geo_decls.h.

◆ PG_GETARG_BOX_P

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

Definition at line 199 of file geo_decls.h.

◆ PG_GETARG_CIRCLE_P

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

Definition at line 211 of file geo_decls.h.

◆ PG_GETARG_LINE_P

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

Definition at line 194 of file geo_decls.h.

◆ PG_GETARG_LSEG_P

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

Definition at line 182 of file geo_decls.h.

◆ PG_GETARG_PATH_P

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

Definition at line 188 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 189 of file geo_decls.h.

◆ PG_GETARG_POINT_P

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

Definition at line 177 of file geo_decls.h.

◆ PG_GETARG_POLYGON_P

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

Definition at line 205 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 206 of file geo_decls.h.

◆ PG_RETURN_BOX_P

#define PG_RETURN_BOX_P (   x)    return BoxPGetDatum(x)

Definition at line 200 of file geo_decls.h.

◆ PG_RETURN_CIRCLE_P

#define PG_RETURN_CIRCLE_P (   x)    return CirclePGetDatum(x)

Definition at line 212 of file geo_decls.h.

◆ PG_RETURN_LINE_P

#define PG_RETURN_LINE_P (   x)    return LinePGetDatum(x)

Definition at line 195 of file geo_decls.h.

◆ PG_RETURN_LSEG_P

#define PG_RETURN_LSEG_P (   x)    return LsegPGetDatum(x)

Definition at line 183 of file geo_decls.h.

◆ PG_RETURN_PATH_P

#define PG_RETURN_PATH_P (   x)    return PathPGetDatum(x)

Definition at line 190 of file geo_decls.h.

◆ PG_RETURN_POINT_P

#define PG_RETURN_POINT_P (   x)    return PointPGetDatum(x)

Definition at line 178 of file geo_decls.h.

◆ PG_RETURN_POLYGON_P

#define PG_RETURN_POLYGON_P (   x)    return PolygonPGetDatum(x)

Definition at line 207 of file geo_decls.h.

◆ PointPGetDatum

#define PointPGetDatum (   X)    PointerGetDatum(X)

Definition at line 176 of file geo_decls.h.

◆ PolygonPGetDatum

#define PolygonPGetDatum (   X)    PointerGetDatum(X)

Definition at line 204 of file geo_decls.h.

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.

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

References EPSILON.

Referenced by circle_ne().

◆ pg_hypot()

float8 pg_hypot ( float8  x,
float8  y 
)

Definition at line 5526 of file geo_ops.c.

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 }
double float8
Definition: c.h:565
#define unlikely(x)
Definition: c.h:273
pg_noinline void float_overflow_error(void)
Definition: float.c:85
pg_noinline void float_underflow_error(void)
Definition: float.c:93
static float8 get_float8_infinity(void)
Definition: float.h:93
static float8 get_float8_nan(void)
Definition: float.h:122
int y
Definition: isn.c:72
int x
Definition: isn.c:71

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