diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-24 20:53:34 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-24 20:53:34 +0000 |
commit | b90f8f20f035c3313f8a284346b5a1d155cfd2f0 (patch) | |
tree | 68ea92accca0015cc6d16c22f860c6c8167a82b6 /contrib/rtree_gist/rtree_gist.c | |
parent | 39f3c5d3850f7c50d363e8984280784251317e8b (diff) | |
download | postgresql-b90f8f20f035c3313f8a284346b5a1d155cfd2f0.tar.gz postgresql-b90f8f20f035c3313f8a284346b5a1d155cfd2f0.zip |
Extend r-tree operator classes to handle Y-direction tests equivalent
to the existing X-direction tests. An rtree class now includes 4 actual
2-D tests, 4 1-D X-direction tests, and 4 1-D Y-direction tests.
This involved adding four new Y-direction test operators for each of
box and polygon; I followed the PostGIS project's lead as to the names
of these operators.
NON BACKWARDS COMPATIBLE CHANGE: the poly_overleft (&<) and poly_overright
(&>) operators now have semantics comparable to box_overleft and box_overright.
This is necessary to make r-tree indexes work correctly on polygons.
Also, I changed circle_left and circle_right to agree with box_left and
box_right --- formerly they allowed the boundaries to touch. This isn't
actually essential given the lack of any r-tree opclass for circles, but
it seems best to sync all the definitions while we are at it.
Diffstat (limited to 'contrib/rtree_gist/rtree_gist.c')
-rw-r--r-- | contrib/rtree_gist/rtree_gist.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/contrib/rtree_gist/rtree_gist.c b/contrib/rtree_gist/rtree_gist.c index f4ce58460fb..d6292b803e8 100644 --- a/contrib/rtree_gist/rtree_gist.c +++ b/contrib/rtree_gist/rtree_gist.c @@ -1,13 +1,13 @@ /*------------------------------------------------------------------------- * * rtree_gist.c - * pg_amproc entries for GiSTs over 2-D boxes. + * pg_amproc entries for GiSTs over 2-D boxes and polygons. * * This gives R-tree behavior, with Guttman's poly-time split algorithm. * * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/rtree_gist/rtree_gist.c,v 1.13 2005/06/24 00:18:52 tgl Exp $ + * $PostgreSQL: pgsql/contrib/rtree_gist/rtree_gist.c,v 1.14 2005/06/24 20:53:29 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -23,8 +23,8 @@ typedef Datum (*BINARY_UNION) (Datum, Datum, int *); typedef float (*SIZE_BOX) (Datum); /* -** box ops -*/ + * box ops + */ PG_FUNCTION_INFO_V1(gbox_compress); PG_FUNCTION_INFO_V1(gbox_union); PG_FUNCTION_INFO_V1(gbox_picksplit); @@ -43,8 +43,8 @@ static bool gbox_leaf_consistent(BOX *key, BOX *query, StrategyNumber strategy); static float size_box(Datum box); /* -** Polygon ops -*/ + * Polygon ops + */ PG_FUNCTION_INFO_V1(gpoly_compress); PG_FUNCTION_INFO_V1(gpoly_consistent); @@ -52,8 +52,8 @@ Datum gpoly_compress(PG_FUNCTION_ARGS); Datum gpoly_consistent(PG_FUNCTION_ARGS); /* -** Common rtree-function (for all ops) -*/ + * Common rtree-function (for all ops) + */ static bool rtree_internal_consistent(BOX *key, BOX *query, StrategyNumber strategy); PG_FUNCTION_INFO_V1(rtree_decompress); @@ -441,6 +441,18 @@ gbox_leaf_consistent(BOX *key, case RTContainedByStrategyNumber: retval = DatumGetBool(DirectFunctionCall2(box_contained, PointerGetDatum(key), PointerGetDatum(query))); break; + case RTOverBelowStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_overbelow, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTBelowStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_below, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTAboveStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_above, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTOverAboveStrategyNumber: + retval = DatumGetBool(DirectFunctionCall2(box_overabove, PointerGetDatum(key), PointerGetDatum(query))); + break; default: retval = FALSE; } @@ -558,6 +570,18 @@ rtree_internal_consistent(BOX *key, case RTContainedByStrategyNumber: retval = DatumGetBool(DirectFunctionCall2(box_overlap, PointerGetDatum(key), PointerGetDatum(query))); break; + case RTOverBelowStrategyNumber: + retval = !DatumGetBool(DirectFunctionCall2(box_above, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTBelowStrategyNumber: + retval = !DatumGetBool(DirectFunctionCall2(box_overabove, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTAboveStrategyNumber: + retval = !DatumGetBool(DirectFunctionCall2(box_overbelow, PointerGetDatum(key), PointerGetDatum(query))); + break; + case RTOverAboveStrategyNumber: + retval = !DatumGetBool(DirectFunctionCall2(box_below, PointerGetDatum(key), PointerGetDatum(query))); + break; default: retval = FALSE; } |