From e7e1694295e3d867f07afedf6505d0e0436cb67e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 1 Jul 2005 19:19:05 +0000 Subject: Migrate rtree_gist functionality into the core system, and add some basic regression tests for GiST to the standard regression tests. I took the opportunity to add an rtree-equivalent gist opclass for circles; the contrib version only covered boxes and polygons, but indexing circles is very handy for distance searches. --- src/backend/utils/adt/geo_ops.c | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'src/backend/utils/adt/geo_ops.c') diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index e2794482633..1786da6dd1c 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.89 2005/06/24 20:53:31 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.90 2005/07/01 19:19:02 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -4605,8 +4605,7 @@ circle_contain(PG_FUNCTION_ARGS) } -/* circle_positionop - - * is circle1 entirely {above,below} circle2? +/* circle_below - is circle1 strictly below circle2? */ Datum circle_below(PG_FUNCTION_ARGS) @@ -4614,18 +4613,46 @@ circle_below(PG_FUNCTION_ARGS) CIRCLE *circle1 = PG_GETARG_CIRCLE_P(0); CIRCLE *circle2 = PG_GETARG_CIRCLE_P(1); - PG_RETURN_BOOL(FPle(circle1->center.y + circle1->radius, - circle2->center.y - circle2->radius)); + PG_RETURN_BOOL(FPlt((circle1->center.y + circle1->radius), + (circle2->center.y - circle2->radius))); } +/* circle_above - is circle1 strictly above circle2? + */ Datum circle_above(PG_FUNCTION_ARGS) { CIRCLE *circle1 = PG_GETARG_CIRCLE_P(0); CIRCLE *circle2 = PG_GETARG_CIRCLE_P(1); - PG_RETURN_BOOL(FPge(circle1->center.y - circle1->radius, - circle2->center.y + circle2->radius)); + PG_RETURN_BOOL(FPgt((circle1->center.y - circle1->radius), + (circle2->center.y + circle2->radius))); +} + +/* circle_overbelow - is the upper edge of circle1 at or below + * the upper edge of circle2? + */ +Datum +circle_overbelow(PG_FUNCTION_ARGS) +{ + CIRCLE *circle1 = PG_GETARG_CIRCLE_P(0); + CIRCLE *circle2 = PG_GETARG_CIRCLE_P(1); + + PG_RETURN_BOOL(FPle((circle1->center.y + circle1->radius), + (circle2->center.y + circle2->radius))); +} + +/* circle_overabove - is the lower edge of circle1 at or above + * the lower edge of circle2? + */ +Datum +circle_overabove(PG_FUNCTION_ARGS) +{ + CIRCLE *circle1 = PG_GETARG_CIRCLE_P(0); + CIRCLE *circle2 = PG_GETARG_CIRCLE_P(1); + + PG_RETURN_BOOL(FPge((circle1->center.y - circle1->radius), + (circle2->center.y - circle2->radius))); } -- cgit v1.2.3