23 #include "utils/fmgrprotos.h"
43 double tstcoord = (isX) ? tst->
x : tst->
y;
45 if (coord == tstcoord)
47 else if (coord > tstcoord)
62 elog(
ERROR,
"allTheSame should not occur for k-d trees");
90 if (pa->
p->
x == pb->
p->
x)
92 return (pa->
p->
x > pb->
p->
x) ? 1 : -1;
101 if (pa->
p->
y == pb->
p->
y)
103 return (pa->
p->
y > pb->
p->
y) ? 1 : -1;
127 coord = (in->
level % 2) ? sorted[middle].p->x : sorted[middle].
p->
y;
173 elog(
ERROR,
"allTheSame should not occur for k-d trees");
178 which = (1 << 1) | (1 << 2);
188 if ((in->
level % 2) != 0 &&
FPlt(query->
x, coord))
192 if ((in->
level % 2) != 0 &&
FPgt(query->
x, coord))
196 if ((in->
level % 2) != 0)
198 if (
FPlt(query->
x, coord))
200 else if (
FPgt(query->
x, coord))
205 if (
FPlt(query->
y, coord))
207 else if (
FPgt(query->
y, coord))
213 if ((in->
level % 2) == 0 &&
FPlt(query->
y, coord))
218 if ((in->
level % 2) == 0 &&
FPgt(query->
y, coord))
230 if ((in->
level % 2) != 0)
234 else if (
FPgt(boxQuery->
low.
x, coord))
241 else if (
FPgt(boxQuery->
low.
y, coord))
246 elog(
ERROR,
"unrecognized strategy number: %d",
283 infArea.
high.
x = inf;
284 infArea.
high.
y = inf;
285 infArea.
low.
x = -inf;
286 infArea.
low.
y = -inf;
295 bboxes[0].
low = area->
low;
301 bboxes[0].
high.
x = bboxes[1].
low.
x = coord;
308 bboxes[0].
high.
y = bboxes[1].
low.
y = coord;
314 for (
i = 1;
i <= 2;
i++)
316 if (which & (1 <<
i))
#define Assert(condition)
static float8 get_float8_infinity(void)
Datum Float8GetDatum(float8 X)
#define PG_GETARG_POINTER(n)
static bool FPlt(double A, double B)
static Point * DatumGetPointP(Datum X)
static BOX * DatumGetBoxP(Datum X)
static Datum PointPGetDatum(const Point *X)
static bool FPgt(double A, double B)
static Datum BoxPGetDatum(const BOX *X)
if(TABLE==NULL||TABLE_index==NULL)
#define qsort(a, b, c, d)
static float8 DatumGetFloat8(Datum X)
MemoryContextSwitchTo(old_ctx)
Datum spg_kd_inner_consistent(PG_FUNCTION_ARGS)
static int x_cmp(const void *a, const void *b)
Datum spg_kd_config(PG_FUNCTION_ARGS)
Datum spg_kd_choose(PG_FUNCTION_ARGS)
struct SortedPoint SortedPoint
static int y_cmp(const void *a, const void *b)
static int getSide(double coord, bool isX, Point *tst)
Datum spg_kd_picksplit(PG_FUNCTION_ARGS)
BOX * box_copy(BOX *orig)
double * spg_key_orderbys_distances(Datum key, bool isLeaf, ScanKey orderbys, int norderbys)
#define RTLeftStrategyNumber
#define RTRightStrategyNumber
#define RTSameStrategyNumber
#define RTOldBelowStrategyNumber
#define RTBelowStrategyNumber
#define RTOldAboveStrategyNumber
#define RTAboveStrategyNumber
#define RTContainedByStrategyNumber
StrategyNumber sk_strategy
spgChooseResultType resultType
union spgChooseOut::@50 result
struct spgChooseOut::@50::@51 matchNode
MemoryContext traversalMemoryContext