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 PG_GETARG_POINT_P(n)   DatumGetPointP(PG_GETARG_DATUM(n))
 
#define PG_RETURN_POINT_P(x)   return PointPGetDatum(x)
 
#define PG_GETARG_LSEG_P(n)   DatumGetLsegP(PG_GETARG_DATUM(n))
 
#define PG_RETURN_LSEG_P(x)   return LsegPGetDatum(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 PG_GETARG_LINE_P(n)   DatumGetLineP(PG_GETARG_DATUM(n))
 
#define PG_RETURN_LINE_P(x)   return LinePGetDatum(x)
 
#define PG_GETARG_BOX_P(n)   DatumGetBoxP(PG_GETARG_DATUM(n))
 
#define PG_RETURN_BOX_P(x)   return BoxPGetDatum(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 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)
 
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 POLYGONDatumGetPolygonP (Datum X)
 
static POLYGONDatumGetPolygonPCopy (Datum X)
 
static Datum PolygonPGetDatum (const POLYGON *X)
 
static CIRCLEDatumGetCircleP (Datum X)
 
static Datum CirclePGetDatum (const CIRCLE *X)
 
float8 pg_hypot (float8 x, float8 y)
 

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,
 
)    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 BOX X)
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:322

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 CIRCLE X)
inlinestatic

Definition at line 271 of file geo_decls.h.

272 {
273  return PointerGetDatum(X);
274 }

References PointerGetDatum().

Referenced by gist_point_consistent().

◆ DatumGetBoxP()

◆ DatumGetCircleP()

static CIRCLE* DatumGetCircleP ( Datum  X)
inlinestatic

Definition at line 266 of file geo_decls.h.

267 {
268  return (CIRCLE *) DatumGetPointer(X);
269 }

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 }

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 }

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

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()

◆ 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

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

◆ LinePGetDatum()

static Datum LinePGetDatum ( const LINE X)
inlinestatic

Definition at line 226 of file geo_decls.h.

227 {
228  return PointerGetDatum(X);
229 }

References PointerGetDatum().

◆ LsegPGetDatum()

static Datum LsegPGetDatum ( const LSEG X)
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 PATH X)
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:630
#define unlikely(x)
Definition: c.h:311
pg_noinline void float_overflow_error(void)
Definition: float.c:79
pg_noinline void float_underflow_error(void)
Definition: float.c:87
static float8 get_float8_infinity(void)
Definition: float.h:94
static float8 get_float8_nan(void)
Definition: float.h:123
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.

◆ PointPGetDatum()

static Datum PointPGetDatum ( const Point X)
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 POLYGON X)
inlinestatic

Definition at line 257 of file geo_decls.h.

258 {
259  return PointerGetDatum(X);
260 }

References PointerGetDatum().

Referenced by gist_point_consistent().