PostgreSQL Source Code  git master
geo_decls.h File Reference
#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 FPeq(A, B)   (fabs((A) - (B)) <= EPSILON)
 
#define FPne(A, B)   (fabs((A) - (B)) > EPSILON)
 
#define FPlt(A, B)   ((B) - (A) > EPSILON)
 
#define FPle(A, B)   ((A) - (B) <= EPSILON)
 
#define FPgt(A, B)   ((A) - (B) > EPSILON)
 
#define FPge(A, B)   ((B) - (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

float8 pg_hypot (float8 x, float8 y)
 

Macro Definition Documentation

◆ BoxPGetDatum

◆ CirclePGetDatum

#define CirclePGetDatum (   X)    PointerGetDatum(X)

Definition at line 169 of file geo_decls.h.

Referenced by gist_point_consistent().

◆ DatumGetBoxP

◆ DatumGetCircleP

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

Definition at line 168 of file geo_decls.h.

Referenced by gist_circle_compress().

◆ DatumGetLineP

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

Definition at line 151 of file geo_decls.h.

◆ DatumGetLsegP

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

Definition at line 139 of file geo_decls.h.

◆ DatumGetPathP

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

Definition at line 144 of file geo_decls.h.

◆ DatumGetPathPCopy

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

Definition at line 145 of file geo_decls.h.

◆ DatumGetPointP

◆ DatumGetPolygonP

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

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

◆ EPSILON

#define EPSILON   1.0E-06

Definition at line 30 of file geo_decls.h.

◆ FPeq

◆ FPge

◆ FPgt

◆ FPle

◆ FPlt

◆ FPne

#define FPne (   A,
 
)    (fabs((A) - (B)) > EPSILON)

Definition at line 35 of file geo_decls.h.

Referenced by circle_ne().

◆ FPzero

◆ HYPOT

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

◆ LinePGetDatum

#define LinePGetDatum (   X)    PointerGetDatum(X)

Definition at line 152 of file geo_decls.h.

◆ LsegPGetDatum

#define LsegPGetDatum (   X)    PointerGetDatum(X)

Definition at line 140 of file geo_decls.h.

Referenced by interpt_pp().

◆ PathPGetDatum

#define PathPGetDatum (   X)    PointerGetDatum(X)

Definition at line 146 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 148 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 165 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 154 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 142 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 166 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 163 of file geo_decls.h.

Referenced by gist_point_consistent().

Function Documentation

◆ pg_hypot()

float8 pg_hypot ( float8  x,
float8  y 
)

Definition at line 5511 of file geo_ops.c.

References check_float8_val(), get_float8_infinity(), get_float8_nan(), and isinf().

5512 {
5513  float8 yx,
5514  result;
5515 
5516  /* Handle INF and NaN properly */
5517  if (isinf(x) || isinf(y))
5518  return get_float8_infinity();
5519 
5520  if (isnan(x) || isnan(y))
5521  return get_float8_nan();
5522 
5523  /* Else, drop any minus signs */
5524  x = fabs(x);
5525  y = fabs(y);
5526 
5527  /* Swap x and y if needed to make x the larger one */
5528  if (x < y)
5529  {
5530  float8 temp = x;
5531 
5532  x = y;
5533  y = temp;
5534  }
5535 
5536  /*
5537  * If y is zero, the hypotenuse is x. This test saves a few cycles in
5538  * such cases, but more importantly it also protects against
5539  * divide-by-zero errors, since now x >= y.
5540  */
5541  if (y == 0.0)
5542  return x;
5543 
5544  /* Determine the hypotenuse */
5545  yx = y / x;
5546  result = x * sqrt(1.0 + (yx * yx));
5547 
5548  check_float8_val(result, false, false);
5549 
5550  return result;
5551 }
static float8 get_float8_infinity(void)
Definition: float.h:90
static void check_float8_val(const float8 val, const bool inf_is_valid, const bool zero_is_valid)
Definition: float.h:151
double float8
Definition: c.h:492
static float8 get_float8_nan(void)
Definition: float.h:119
int isinf(double x)