Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SP-GiST index on geometry #258

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion libpgcommon/gserialized_gist.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,21 @@ GSERIALIZED* gserialized_set_gidx(GSERIALIZED *g, GIDX *gidx);
/* Remove the box from a disk serialization */
GSERIALIZED* gserialized_drop_gidx(GSERIALIZED *g);

void box2df_set_empty(BOX2DF *a);
void box2df_set_finite(BOX2DF *a);
void box2df_validate(BOX2DF *b);
bool box2df_contains(const BOX2DF *a, const BOX2DF *b);
bool box2df_overlaps(const BOX2DF *a, const BOX2DF *b);
bool box2df_overleft(const BOX2DF *a, const BOX2DF *b);
bool box2df_equals(const BOX2DF *a, const BOX2DF *b);
bool box2df_left(const BOX2DF *a, const BOX2DF *b);
bool box2df_right(const BOX2DF *a, const BOX2DF *b);
bool box2df_overright(const BOX2DF *a, const BOX2DF *b);
bool box2df_overbelow(const BOX2DF *a, const BOX2DF *b);
bool box2df_below(const BOX2DF *a, const BOX2DF *b);
bool box2df_above(const BOX2DF *a, const BOX2DF *b);
bool box2df_overabove(const BOX2DF *a, const BOX2DF *b);

bool gidx_contains(GIDX *a, GIDX *b);
int gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df);


25 changes: 25 additions & 0 deletions libpgcommon/lwgeom_pg.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,33 @@ Datum BOX2D_intersects(PG_FUNCTION_ARGS);
Datum BOX2D_union(PG_FUNCTION_ARGS);

Datum LWGEOM_same(PG_FUNCTION_ARGS);
Datum LWGEOM_to_BOX2DF(PG_FUNCTION_ARGS);
Datum LWGEOM_to_BOX3D(PG_FUNCTION_ARGS);
Datum BOX3D_construct(PG_FUNCTION_ARGS);

Datum BOX3D_contains(PG_FUNCTION_ARGS);
Datum BOX3D_contained(PG_FUNCTION_ARGS);
Datum BOX3D_overlaps(PG_FUNCTION_ARGS);
Datum BOX3D_same(PG_FUNCTION_ARGS);
Datum BOX3D_left(PG_FUNCTION_ARGS);
Datum BOX3D_overleft(PG_FUNCTION_ARGS);
Datum BOX3D_right(PG_FUNCTION_ARGS) ;
Datum BOX3D_overright(PG_FUNCTION_ARGS);
Datum BOX3D_below(PG_FUNCTION_ARGS);
Datum BOX3D_overbelow(PG_FUNCTION_ARGS);
Datum BOX3D_above(PG_FUNCTION_ARGS);
Datum BOX3D_overabove(PG_FUNCTION_ARGS);
Datum BOX3D_front(PG_FUNCTION_ARGS);
Datum BOX3D_overfront(PG_FUNCTION_ARGS);
Datum BOX3D_back(PG_FUNCTION_ARGS);
Datum BOX3D_overback(PG_FUNCTION_ARGS);
Datum BOX3D_distance(PG_FUNCTION_ARGS);

#define DatumGetBox3DP(X) ((BOX3D *) DatumGetPointer(X))
#define Box3DPGetDatum(X) PointerGetDatum(X)
#define PG_GETARG_BOX3D_P(n) DatumGetBox3DP(PG_GETARG_DATUM(n))
#define PG_RETURN_BOX3D_P(x) return Box3DPGetDatum(x)

Datum LWGEOM_force_2d(PG_FUNCTION_ARGS);
Datum LWGEOM_force_3dm(PG_FUNCTION_ARGS);
Datum LWGEOM_force_3dz(PG_FUNCTION_ARGS);
Expand Down
2 changes: 2 additions & 0 deletions postgis/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ PG_OBJS= \
gserialized_typmod.o \
gserialized_gist_2d.o \
gserialized_gist_nd.o \
gserialized_spgist_2d.o \
gserialized_spgist_3d.o \
$(BRIN_OBJ) \
gserialized_estimate.o \
geography_inout.o \
Expand Down
26 changes: 13 additions & 13 deletions postgis/gserialized_gist_2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ inline bool box2df_is_empty(const BOX2DF *a)
return false;
}

static inline void box2df_set_empty(BOX2DF *a)
inline void box2df_set_empty(BOX2DF *a)
{
a->xmin = a->xmax = a->ymin = a->ymax = NAN;
return;
}

static inline void box2df_set_finite(BOX2DF *a)
inline void box2df_set_finite(BOX2DF *a)
{
if ( ! isfinite(a->xmax) )
a->xmax = FLT_MAX;
Expand Down Expand Up @@ -329,7 +329,7 @@ int box2df_to_gbox_p(BOX2DF *a, GBOX *box)
*/

/* Ensure all minimums are below maximums. */
static inline void box2df_validate(BOX2DF *b)
inline void box2df_validate(BOX2DF *b)
{
float tmp;
POSTGIS_DEBUGF(5,"validating box2df (%s)", box2df_to_string(b));
Expand All @@ -352,7 +352,7 @@ static inline void box2df_validate(BOX2DF *b)
return;
}

static bool box2df_overlaps(const BOX2DF *a, const BOX2DF *b)
bool box2df_overlaps(const BOX2DF *a, const BOX2DF *b)
{
if ( !a || !b || box2df_is_empty(a) || box2df_is_empty(b) )
return false;
Expand Down Expand Up @@ -397,7 +397,7 @@ static bool box2df_within(const BOX2DF *a, const BOX2DF *b)
return box2df_contains(b,a);
}

static bool box2df_equals(const BOX2DF *a, const BOX2DF *b)
bool box2df_equals(const BOX2DF *a, const BOX2DF *b)
{
if ( !a && !b )
return true;
Expand All @@ -413,7 +413,7 @@ static bool box2df_equals(const BOX2DF *a, const BOX2DF *b)
return false;
}

static bool box2df_overleft(const BOX2DF *a, const BOX2DF *b)
bool box2df_overleft(const BOX2DF *a, const BOX2DF *b)
{
if ( !a || !b || box2df_is_empty(a) || box2df_is_empty(b) )
return false;
Expand All @@ -422,7 +422,7 @@ static bool box2df_overleft(const BOX2DF *a, const BOX2DF *b)
return a->xmax <= b->xmax;
}

static bool box2df_left(const BOX2DF *a, const BOX2DF *b)
bool box2df_left(const BOX2DF *a, const BOX2DF *b)
{
if ( !a || !b || box2df_is_empty(a) || box2df_is_empty(b) )
return false;
Expand All @@ -431,7 +431,7 @@ static bool box2df_left(const BOX2DF *a, const BOX2DF *b)
return a->xmax < b->xmin;
}

static bool box2df_right(const BOX2DF *a, const BOX2DF *b)
bool box2df_right(const BOX2DF *a, const BOX2DF *b)
{
if ( !a || !b || box2df_is_empty(a) || box2df_is_empty(b) )
return false;
Expand All @@ -440,7 +440,7 @@ static bool box2df_right(const BOX2DF *a, const BOX2DF *b)
return a->xmin > b->xmax;
}

static bool box2df_overright(const BOX2DF *a, const BOX2DF *b)
bool box2df_overright(const BOX2DF *a, const BOX2DF *b)
{
if ( !a || !b || box2df_is_empty(a) || box2df_is_empty(b) )
return false;
Expand All @@ -449,7 +449,7 @@ static bool box2df_overright(const BOX2DF *a, const BOX2DF *b)
return a->xmin >= b->xmin;
}

static bool box2df_overbelow(const BOX2DF *a, const BOX2DF *b)
bool box2df_overbelow(const BOX2DF *a, const BOX2DF *b)
{
if ( !a || !b || box2df_is_empty(a) || box2df_is_empty(b) )
return false;
Expand All @@ -458,7 +458,7 @@ static bool box2df_overbelow(const BOX2DF *a, const BOX2DF *b)
return a->ymax <= b->ymax;
}

static bool box2df_below(const BOX2DF *a, const BOX2DF *b)
bool box2df_below(const BOX2DF *a, const BOX2DF *b)
{
if ( !a || !b || box2df_is_empty(a) || box2df_is_empty(b) )
return false;
Expand All @@ -467,7 +467,7 @@ static bool box2df_below(const BOX2DF *a, const BOX2DF *b)
return a->ymax < b->ymin;
}

static bool box2df_above(const BOX2DF *a, const BOX2DF *b)
bool box2df_above(const BOX2DF *a, const BOX2DF *b)
{
if ( !a || !b || box2df_is_empty(a) || box2df_is_empty(b) )
return false;
Expand All @@ -476,7 +476,7 @@ static bool box2df_above(const BOX2DF *a, const BOX2DF *b)
return a->ymin > b->ymax;
}

static bool box2df_overabove(const BOX2DF *a, const BOX2DF *b)
bool box2df_overabove(const BOX2DF *a, const BOX2DF *b)
{
if ( !a || !b || box2df_is_empty(a) || box2df_is_empty(b) )
return false;
Expand Down
Loading