39 #define SPTEST(f, x, y) \ 40 DatumGetBool(DirectFunctionCall2(f, PointPGetDatum(x), PointPGetDatum(y))) 77 elog(
ERROR,
"getQuadrant: impossible case");
91 result->
low = *centroid;
95 result->
high.
y = centroid->
y;
96 result->
low.
x = centroid->
x;
100 result->
high = *centroid;
104 result->
high.
x = centroid->
x;
107 result->
low.
y = centroid->
y;
146 x_cmp(
const void *a,
const void *b,
void *
arg)
153 return (pa->
x > pb->
x) ? 1 : -1;
157 y_cmp(
const void *a,
const void *b,
void *
arg)
164 return (pa->
y > pb->
y) ? 1 : -1;
181 for (i = 0; i < in->
nTuples; i++)
184 centroid =
palloc(
sizeof(*centroid));
187 centroid->
x = sorted[in->
nTuples >> 1]->
x;
189 centroid->
y = sorted[in->
nTuples >> 1]->
y;
192 centroid =
palloc0(
sizeof(*centroid));
194 for (i = 0; i < in->
nTuples; i++)
213 for (i = 0; i < in->
nTuples; i++)
256 infbbox.
high.
x = inf;
257 infbbox.
high.
y = inf;
258 infbbox.
low.
x = -inf;
259 infbbox.
low.
y = -inf;
274 for (i = 0; i < in->
nNodes; i++)
298 which = (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4);
300 for (i = 0; i < in->
nkeys; i++)
309 which &= (1 << 3) | (1 << 4);
313 which &= (1 << 1) | (1 << 2);
321 which &= (1 << 2) | (1 << 3);
326 which &= (1 << 1) | (1 << 4);
355 p.
x = boxQuery->
low.
x;
362 elog(
ERROR,
"unrecognized strategy number: %d",
372 for (i = 0; i < 4; ++
i)
379 for (i = 1; i <= 4; i++)
381 if (which & (1 << i))
423 for (i = 0; i < in->
nkeys; i++)
456 elog(
ERROR,
"unrecognized strategy number: %d",
#define RTOldAboveStrategyNumber
Datum spg_quad_picksplit(PG_FUNCTION_ARGS)
static BOX * getQuadrantArea(BOX *bbox, Point *centroid, int quadrant)
static float8 get_float8_infinity(void)
#define RTLeftStrategyNumber
#define PointerGetDatum(X)
Datum box_contain_pt(PG_FUNCTION_ARGS)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define RTContainedByStrategyNumber
#define PG_GETARG_POINTER(n)
#define RTOldBelowStrategyNumber
#define RTBelowStrategyNumber
union spgChooseOut::@45 result
Datum spg_quad_leaf_consistent(PG_FUNCTION_ARGS)
Datum point_below(PG_FUNCTION_ARGS)
Datum point_right(PG_FUNCTION_ARGS)
struct spgChooseOut::@45::@46 matchNode
MemoryContext traversalMemoryContext
StrategyNumber sk_strategy
Datum point_left(PG_FUNCTION_ARGS)
#define RTSameStrategyNumber
static int16 getQuadrant(Point *centroid, Point *tst)
static int x_cmp(const void *a, const void *b)
Datum spg_quad_inner_consistent(PG_FUNCTION_ARGS)
void * palloc0(Size size)
#define PG_RETURN_BOOL(x)
Datum point_vert(PG_FUNCTION_ARGS)
spgChooseResultType resultType
BOX * box_copy(BOX *orig)
Datum spg_quad_choose(PG_FUNCTION_ARGS)
#define RTAboveStrategyNumber
#define Assert(condition)
#define RTRightStrategyNumber
#define DatumGetPointP(X)
Datum point_horiz(PG_FUNCTION_ARGS)
double * spg_key_orderbys_distances(Datum key, bool isLeaf, ScanKey orderbys, int norderbys)
Datum point_eq(PG_FUNCTION_ARGS)
Datum point_above(PG_FUNCTION_ARGS)
Datum spg_quad_config(PG_FUNCTION_ARGS)
#define qsort(a, b, c, d)
#define DirectFunctionCall2(func, arg1, arg2)
#define PointPGetDatum(X)
static int y_cmp(const void *a, const void *b)