From: Paul Ramsey Date: Fri, 18 Mar 2011 16:16:05 +0000 (+0000) Subject: Add the &&& operator and index binding for 'gist_geometry_ops_nd'. Operator behavior... X-Git-Tag: 2.0.0alpha1~1878 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b9132a5e410c9e943470255bd5662285b257141;p=postgis Add the &&& operator and index binding for 'gist_geometry_ops_nd'. Operator behavior in mixed-dimension query situations still to be determined. git-svn-id: http://svn.osgeo.org/postgis/trunk@6924 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/geography.sql.in.c b/postgis/geography.sql.in.c index ce25393bb..ca08359a8 100644 --- a/postgis/geography.sql.in.c +++ b/postgis/geography.sql.in.c @@ -761,3 +761,99 @@ CREATE OR REPLACE FUNCTION ST_Intersection(text, text) +#ifdef GSERIALIZED_ON +----------------------------------------------------------------------------- +-- GiST ND GEOMETRY-over-GSERIALIZED +----------------------------------------------------------------------------- + + +-- ---------- ---------- ---------- ---------- ---------- ---------- ---------- +-- GiST Support Functions +-- ---------- ---------- ---------- ---------- ---------- ---------- ---------- + +-- Availability: 2.0.0 +CREATE OR REPLACE FUNCTION geometry_gist_consistent_nd(internal,geometry,int4) + RETURNS bool + AS 'MODULE_PATHNAME' ,'gserialized_gist_consistent' + LANGUAGE 'C'; + +-- Availability: 2.0.0 +CREATE OR REPLACE FUNCTION geometry_gist_compress_nd(internal) + RETURNS internal + AS 'MODULE_PATHNAME','gserialized_gist_compress' + LANGUAGE 'C'; + +-- Availability: 2.0.0 +CREATE OR REPLACE FUNCTION geometry_gist_penalty_nd(internal,internal,internal) + RETURNS internal + AS 'MODULE_PATHNAME' ,'gserialized_gist_penalty' + LANGUAGE 'C'; + +-- Availability: 2.0.0 +CREATE OR REPLACE FUNCTION geometry_gist_picksplit_nd(internal, internal) + RETURNS internal + AS 'MODULE_PATHNAME' ,'gserialized_gist_picksplit' + LANGUAGE 'C'; + +-- Availability: 2.0.0 +CREATE OR REPLACE FUNCTION geometry_gist_union_nd(bytea, internal) + RETURNS internal + AS 'MODULE_PATHNAME' ,'gserialized_gist_union' + LANGUAGE 'C'; + +-- Availability: 2.0.0 +CREATE OR REPLACE FUNCTION geometry_gist_same_nd(geometry, geometry, internal) + RETURNS internal + AS 'MODULE_PATHNAME' ,'gserialized_gist_same' + LANGUAGE 'C'; + +-- Availability: 2.0.0 +CREATE OR REPLACE FUNCTION geometry_gist_decompress_nd(internal) + RETURNS internal + AS 'MODULE_PATHNAME' ,'gserialized_gist_decompress' + LANGUAGE 'C'; + +-- Availability: 2.0.0 +--CREATE OR REPLACE FUNCTION geometry_gist_selectivity_nd (internal, oid, internal, int4) +-- RETURNS float8 +-- AS 'MODULE_PATHNAME', 'geometry_gist_selectivity_nd' +-- LANGUAGE 'C'; + +-- Availability: 2.0.0 +--CREATE OR REPLACE FUNCTION geography_gist_join_selectivity_nd(internal, oid, internal, smallint) +-- RETURNS float8 +-- AS 'MODULE_PATHNAME', 'geometry_gist_join_selectivity_nd' +-- LANGUAGE 'C'; + +-- Availability: 2.0.0 +CREATE OR REPLACE FUNCTION geometry_overlaps_nd(geography, geography) + RETURNS boolean + AS 'MODULE_PATHNAME' ,'gserialized_overlaps' + LANGUAGE 'C' IMMUTABLE STRICT; + +-- Availability: 2.0.0 +CREATE OPERATOR &&& ( + LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_overlaps, + COMMUTATOR = '&&&' + ,RESTRICT = contsel, JOIN = contjoinsel +-- ,RESTRICT = geometry_gist_selectivity_nd +-- ,JOIN = geometry_gist_join_selectivity_nd +); + +-- Availability: 2.0.0 +CREATE OPERATOR CLASS gist_geometry_ops_nd + FOR TYPE geometry USING GIST AS + STORAGE gidx, + OPERATOR 3 &&& , +-- OPERATOR 6 ~= , +-- OPERATOR 7 ~ , +-- OPERATOR 8 @ , + FUNCTION 1 geometry_gist_consistent_nd (internal, geometry, int4), + FUNCTION 2 geometry_gist_union_nd (bytea, internal), + FUNCTION 3 geometry_gist_compress_nd (internal), + FUNCTION 4 geometry_gist_decompress_nd (internal), + FUNCTION 5 geometry_gist_penalty_nd (internal, internal, internal), + FUNCTION 6 geometry_gist_picksplit_nd (internal, internal), + FUNCTION 7 geometry_gist_same_nd (geometry, geometry, internal); + +#endif diff --git a/postgis/gserialized.h b/postgis/gserialized.h index d50e3f8b4..24d5b0510 100644 --- a/postgis/gserialized.h +++ b/postgis/gserialized.h @@ -1,3 +1,3 @@ -#undef GSERIALIZED_ON +#define GSERIALIZED_ON diff --git a/postgis/gserialized_gist_nd.c b/postgis/gserialized_gist_nd.c index 91b24d5e9..0d494dd41 100644 --- a/postgis/gserialized_gist_nd.c +++ b/postgis/gserialized_gist_nd.c @@ -206,8 +206,6 @@ static void gidx_dimensionality_check(GIDX **a, GIDX **b) } } - - /* Calculate the volume of the union of the boxes. Avoids creating an intermediate box. */ static float gidx_union_volume(GIDX *a, GIDX *b) { @@ -507,7 +505,7 @@ gserialized_datum_predicate(Datum gs1, Datum gs2, gidx_predicate predicate) POSTGIS_DEBUG(3, "entered function"); /* Must be able to build box for each arguement (ie, not empty geometry) - and overlap boxes to return true. */ + and predicate function to return true. */ if ( (gserialized_datum_get_gidx_p(gs1, gidx1) == LW_SUCCESS) && (gserialized_datum_get_gidx_p(gs2, gidx2) == LW_SUCCESS) && predicate(gidx1, gidx2) ) @@ -518,34 +516,6 @@ gserialized_datum_predicate(Datum gs1, Datum gs2, gidx_predicate predicate) return LW_FALSE; } -/** -* Support function. Based on two datums return true if -* they overlap and false otherwise. Useful for fast exiting -* in functions doing geocalculation. -*/ -int -gserialized_datum_overlaps(Datum gs1, Datum gs2) -{ - /* Put aside some stack memory and use it for GIDX pointers. */ - char boxmem1[GIDX_MAX_SIZE]; - char boxmem2[GIDX_MAX_SIZE]; - GIDX *gidx1 = (GIDX*)boxmem1; - GIDX *gidx2 = (GIDX*)boxmem2; - - /* Must be able to build box for each arguement (ie, not empty geometry) - and overlap boxes to return true. */ - if ( (gserialized_datum_get_gidx_p(gs1, gidx1) == LW_SUCCESS) && - (gserialized_datum_get_gidx_p(gs2, gidx2) == LW_SUCCESS) && - gidx_overlaps(gidx1, gidx2) ) - { - return LW_TRUE; - } - - return LW_FALSE; -} - - - /** * Return a #GSERIALIZED with an expanded bounding box. */ @@ -578,7 +548,6 @@ int gserialized_datum_get_gidx_p(Datum gsdatum, GIDX *gidx) { GSERIALIZED *gpart; - uchar flags; int result = LW_SUCCESS; POSTGIS_DEBUG(4, "entered function"); @@ -589,15 +558,14 @@ gserialized_datum_get_gidx_p(Datum gsdatum, GIDX *gidx) ** bounding box, so 40 bytes. */ gpart = (GSERIALIZED*)PG_DETOAST_DATUM_SLICE(gsdatum, 0, 40); - flags = gpart->flags; POSTGIS_DEBUGF(4, "got flags %d", gpart->flags); /* Do we even have a serialized bounding box? */ - if ( FLAGS_GET_BBOX(flags) ) + if ( FLAGS_GET_BBOX(gpart->flags) ) { /* Yes! Copy it out into the GIDX! */ - const size_t size = gbox_serialized_size(flags); + const size_t size = gbox_serialized_size(gpart->flags); POSTGIS_DEBUG(4, "copying box out of serialization"); memcpy(gidx->c, gpart->data, size); SET_VARSIZE(gidx, VARHDRSZ + size); @@ -713,7 +681,7 @@ Datum gserialized_contains(PG_FUNCTION_ARGS) PG_FUNCTION_INFO_V1(gserialized_overlaps); Datum gserialized_overlaps(PG_FUNCTION_ARGS) { - if ( gserialized_datum_overlaps(PG_GETARG_DATUM(0),PG_GETARG_DATUM(1)) == LW_TRUE ) + if ( gserialized_datum_predicate(PG_GETARG_DATUM(0),PG_GETARG_DATUM(1), gidx_contains) == LW_TRUE ) { PG_RETURN_BOOL(TRUE); } diff --git a/postgis/lwgeom_btree.c b/postgis/lwgeom_btree.c index 583f4d5f7..6256a8b56 100644 --- a/postgis/lwgeom_btree.c +++ b/postgis/lwgeom_btree.c @@ -44,10 +44,8 @@ Datum lwgeom_lt(PG_FUNCTION_ARGS) { elog(BTREE_SRID_MISMATCH_SEVERITY, "Operation on two GEOMETRIES with different SRIDs\n"); - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) - pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) - pfree(geom2); + PG_FREE_IF_COPY(geom1, 0); + PG_FREE_IF_COPY(geom2, 1); PG_RETURN_NULL(); } @@ -56,6 +54,9 @@ Datum lwgeom_lt(PG_FUNCTION_ARGS) pglwgeom_getbox2d_p(geom1, &box1); pglwgeom_getbox2d_p(geom2, &box2); + PG_FREE_IF_COPY(geom1, 0); + PG_FREE_IF_COPY(geom2, 1); + POSTGIS_DEBUG(3, "lwgeom_lt getbox2d_p passed"); if ( ! FPeq(box1.xmin , box2.xmin) ) @@ -99,26 +100,23 @@ Datum lwgeom_le(PG_FUNCTION_ARGS) { elog(BTREE_SRID_MISMATCH_SEVERITY, "Operation on two GEOMETRIES with different SRIDs\n"); - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) - pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) - pfree(geom2); + PG_FREE_IF_COPY(geom1, 0); + PG_FREE_IF_COPY(geom2, 1); PG_RETURN_NULL(); } pglwgeom_getbox2d_p(geom1, &box1); pglwgeom_getbox2d_p(geom2, &box2); + PG_FREE_IF_COPY(geom1, 0); + PG_FREE_IF_COPY(geom2, 1); + if ( ! FPeq(box1.xmin , box2.xmin) ) { if (box1.xmin < box2.xmin) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(TRUE); } - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(FALSE); } @@ -126,12 +124,8 @@ Datum lwgeom_le(PG_FUNCTION_ARGS) { if (box1.ymin < box2.ymin) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(TRUE); } - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(FALSE); } @@ -139,12 +133,8 @@ Datum lwgeom_le(PG_FUNCTION_ARGS) { if (box1.xmax < box2.xmax) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(TRUE); } - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(FALSE); } @@ -152,18 +142,11 @@ Datum lwgeom_le(PG_FUNCTION_ARGS) { if (box1.ymax < box2.ymax) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(TRUE); } - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(FALSE); } - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); - PG_RETURN_BOOL(TRUE); } @@ -174,6 +157,7 @@ Datum lwgeom_eq(PG_FUNCTION_ARGS) PG_LWGEOM *geom2 = (PG_LWGEOM *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1)); BOX2DFLOAT4 box1; BOX2DFLOAT4 box2; + bool result; POSTGIS_DEBUG(2, "lwgeom_eq called"); @@ -181,48 +165,27 @@ Datum lwgeom_eq(PG_FUNCTION_ARGS) { elog(BTREE_SRID_MISMATCH_SEVERITY, "Operation on two GEOMETRIES with different SRIDs\n"); - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) - pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) - pfree(geom2); + PG_FREE_IF_COPY(geom1, 0); + PG_FREE_IF_COPY(geom2, 1); PG_RETURN_NULL(); } pglwgeom_getbox2d_p(geom1, &box1); pglwgeom_getbox2d_p(geom2, &box2); + PG_FREE_IF_COPY(geom1, 0); + PG_FREE_IF_COPY(geom2, 1); - if ( ! FPeq(box1.xmin , box2.xmin) ) - { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); - PG_RETURN_BOOL(FALSE); - } - - if ( ! FPeq(box1.ymin , box2.ymin) ) - { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); - PG_RETURN_BOOL(FALSE); - } - - if ( ! FPeq(box1.xmax , box2.xmax) ) + if ( ! (FPeq(box1.xmin, box2.xmin) && FPeq(box1.ymin, box2.ymin) && + FPeq(box1.xmax, box2.xmax) && FPeq(box1.ymax, box2.ymax)) ) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); - PG_RETURN_BOOL(FALSE); + result = FALSE; } - - if ( ! FPeq(box1.ymax , box2.ymax) ) + else { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); - PG_RETURN_BOOL(FALSE); + result = TRUE; } - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); - - PG_RETURN_BOOL(TRUE); + PG_RETURN_BOOL(result); } PG_FUNCTION_INFO_V1(lwgeom_ge); @@ -239,22 +202,21 @@ Datum lwgeom_ge(PG_FUNCTION_ARGS) { elog(BTREE_SRID_MISMATCH_SEVERITY, "Operation on two GEOMETRIES with different SRIDs\n"); - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) - pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) - pfree(geom2); + PG_FREE_IF_COPY(geom1, 0); + PG_FREE_IF_COPY(geom2, 1); PG_RETURN_NULL(); } pglwgeom_getbox2d_p(geom1, &box1); pglwgeom_getbox2d_p(geom2, &box2); + PG_FREE_IF_COPY(geom1, 0); + PG_FREE_IF_COPY(geom2, 1); + if ( ! FPeq(box1.xmin , box2.xmin) ) { if (box1.xmin > box2.xmin) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(TRUE); } PG_RETURN_BOOL(FALSE); @@ -264,8 +226,6 @@ Datum lwgeom_ge(PG_FUNCTION_ARGS) { if (box1.ymin > box2.ymin) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(TRUE); } PG_RETURN_BOOL(FALSE); @@ -275,8 +235,6 @@ Datum lwgeom_ge(PG_FUNCTION_ARGS) { if (box1.xmax > box2.xmax) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(TRUE); } PG_RETURN_BOOL(FALSE); @@ -286,16 +244,11 @@ Datum lwgeom_ge(PG_FUNCTION_ARGS) { if (box1.ymax > box2.ymax) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(TRUE); } PG_RETURN_BOOL(FALSE); } - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); - PG_RETURN_BOOL(TRUE); } @@ -313,22 +266,21 @@ Datum lwgeom_gt(PG_FUNCTION_ARGS) { elog(BTREE_SRID_MISMATCH_SEVERITY, "Operation on two GEOMETRIES with different SRIDs\n"); - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) - pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) - pfree(geom2); + PG_FREE_IF_COPY(geom1, 0); + PG_FREE_IF_COPY(geom2, 1); PG_RETURN_NULL(); } pglwgeom_getbox2d_p(geom1, &box1); pglwgeom_getbox2d_p(geom2, &box2); + PG_FREE_IF_COPY(geom1, 0); + PG_FREE_IF_COPY(geom2, 1); + if ( ! FPeq(box1.xmin , box2.xmin) ) { if (box1.xmin > box2.xmin) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(TRUE); } } @@ -337,8 +289,6 @@ Datum lwgeom_gt(PG_FUNCTION_ARGS) { if (box1.ymin > box2.ymin) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(TRUE); } } @@ -347,8 +297,6 @@ Datum lwgeom_gt(PG_FUNCTION_ARGS) { if (box1.xmax > box2.xmax) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(TRUE); } } @@ -357,15 +305,10 @@ Datum lwgeom_gt(PG_FUNCTION_ARGS) { if (box1.ymax > box2.ymax) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_BOOL(TRUE); } } - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); - PG_RETURN_BOOL(FALSE); } @@ -383,26 +326,23 @@ Datum lwgeom_cmp(PG_FUNCTION_ARGS) { elog(BTREE_SRID_MISMATCH_SEVERITY, "Operation on two GEOMETRIES with different SRIDs\n"); - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) - pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) - pfree(geom2); + PG_FREE_IF_COPY(geom1, 0); + PG_FREE_IF_COPY(geom2, 1); PG_RETURN_NULL(); } pglwgeom_getbox2d_p(geom1, &box1); pglwgeom_getbox2d_p(geom2, &box2); + PG_FREE_IF_COPY(geom1, 0); + PG_FREE_IF_COPY(geom2, 1); + if ( ! FPeq(box1.xmin , box2.xmin) ) { if (box1.xmin < box2.xmin) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_INT32(-1); } - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_INT32(1); } @@ -410,12 +350,8 @@ Datum lwgeom_cmp(PG_FUNCTION_ARGS) { if (box1.ymin < box2.ymin) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_INT32(-1); } - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_INT32(1); } @@ -423,12 +359,8 @@ Datum lwgeom_cmp(PG_FUNCTION_ARGS) { if (box1.xmax < box2.xmax) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_INT32(-1); } - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_INT32(1); } @@ -436,18 +368,11 @@ Datum lwgeom_cmp(PG_FUNCTION_ARGS) { if (box1.ymax < box2.ymax) { - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_INT32(-1); } - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); PG_RETURN_INT32(1); } - if ( (Pointer *)PG_GETARG_DATUM(0) != (Pointer *)geom1 ) pfree(geom1); - if ( (Pointer *)PG_GETARG_DATUM(1) != (Pointer *)geom2 ) pfree(geom2); - PG_RETURN_INT32(0); } diff --git a/postgis/postgis.sql.in.c b/postgis/postgis.sql.in.c index e7efa4a6e..35e214a62 100644 --- a/postgis/postgis.sql.in.c +++ b/postgis/postgis.sql.in.c @@ -513,25 +513,25 @@ CREATE OPERATOR CLASS btree_geometry_ops #ifdef GSERIALIZED_ON ----------------------------------------------------------------------------- --- GiST GEOMETRY-over-GSERIALIZED +-- GiST 2D GEOMETRY-over-GSERIALIZED ----------------------------------------------------------------------------- -- -- Box2Df type is used by the GiST index bindings. -- In/out functions are stubs, as all access should be internal. --- --- Availability: 1.5.0 +-- Availability: 2.0.0 CREATE OR REPLACE FUNCTION box2df_in(cstring) RETURNS box2df AS 'MODULE_PATHNAME','box2df_in' LANGUAGE 'C' IMMUTABLE STRICT; --- Availability: 1.5.0 +-- Availability: 2.0.0 CREATE OR REPLACE FUNCTION box2df_out(box2df) RETURNS cstring AS 'MODULE_PATHNAME','box2df_out' LANGUAGE 'C' IMMUTABLE STRICT; --- Availability: 1.5.0 +-- Availability: 2.0.0 CREATE TYPE box2df ( internallength = 16, input = box2df_in, @@ -608,9 +608,10 @@ CREATE OPERATOR && ( LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_overlaps, COMMUTATOR = '&&' ,RESTRICT = contsel, JOIN = contjoinsel --- ,RESTRICT = geometry_gist_sel, JOIN = geometry_gist_joinsel +-- ,RESTRICT = geometry_gist_sel_2d, JOIN = geometry_gist_joinsel_2d ); +-- Availability: 2.0.0 CREATE OR REPLACE FUNCTION geometry_same(geometry, geometry) RETURNS boolean AS 'MODULE_PATHNAME' ,'gserialized_same_2d' @@ -621,11 +622,13 @@ CREATE OPERATOR ~= ( RESTRICT = contsel, JOIN = contjoinsel ); +-- Availability: 2.0.0 CREATE OR REPLACE FUNCTION geometry_contains(geometry, geometry) RETURNS bool AS 'MODULE_PATHNAME', 'gserialized_contains_2d' LANGUAGE 'C' IMMUTABLE STRICT; +-- Availability: 2.0.0 CREATE OR REPLACE FUNCTION geometry_within(geometry, geometry) RETURNS bool AS 'MODULE_PATHNAME', 'gserialized_within' @@ -643,6 +646,7 @@ CREATE OPERATOR ~ ( RESTRICT = contsel, JOIN = contjoinsel ); +-- Availability: 2.0.0 CREATE OR REPLACE FUNCTION geometry_left(geometry, geometry) RETURNS bool AS 'MODULE_PATHNAME', 'gserialized_left_2d' @@ -654,6 +658,7 @@ CREATE OPERATOR << ( RESTRICT = positionsel, JOIN = positionjoinsel ); +-- Availability: 2.0.0 CREATE OR REPLACE FUNCTION geometry_overleft(geometry, geometry) RETURNS bool AS 'MODULE_PATHNAME', 'gserialized_overleft_2d' @@ -665,6 +670,7 @@ CREATE OPERATOR &< ( RESTRICT = positionsel, JOIN = positionjoinsel ); +-- Availability: 2.0.0 CREATE OR REPLACE FUNCTION geometry_below(geometry, geometry) RETURNS bool AS 'MODULE_PATHNAME', 'gserialized_below_2d' @@ -676,6 +682,7 @@ CREATE OPERATOR <<| ( RESTRICT = positionsel, JOIN = positionjoinsel ); +-- Availability: 2.0.0 CREATE OR REPLACE FUNCTION geometry_overbelow(geometry, geometry) RETURNS bool AS 'MODULE_PATHNAME', 'gserialized_overbelow_2d' @@ -687,6 +694,7 @@ CREATE OPERATOR &<| ( RESTRICT = positionsel, JOIN = positionjoinsel ); +-- Availability: 2.0.0 CREATE OR REPLACE FUNCTION geometry_overright(geometry, geometry) RETURNS bool AS 'MODULE_PATHNAME', 'gserialized_overright_2d' @@ -698,6 +706,7 @@ CREATE OPERATOR &> ( RESTRICT = positionsel, JOIN = positionjoinsel ); +-- Availability: 2.0.0 CREATE OR REPLACE FUNCTION geometry_right(geometry, geometry) RETURNS bool AS 'MODULE_PATHNAME', 'gserialized_right_2d' @@ -709,6 +718,7 @@ CREATE OPERATOR >> ( RESTRICT = positionsel, JOIN = positionjoinsel ); +-- Availability: 2.0.0 CREATE OR REPLACE FUNCTION geometry_overabove(geometry, geometry) RETURNS bool AS 'MODULE_PATHNAME', 'gserialized_overabove_2d' @@ -720,6 +730,7 @@ CREATE OPERATOR |&> ( RESTRICT = positionsel, JOIN = positionjoinsel ); +-- Availability: 2.0.0 CREATE OR REPLACE FUNCTION geometry_above(geometry, geometry) RETURNS bool AS 'MODULE_PATHNAME', 'gserialized_above_2d' @@ -732,7 +743,7 @@ CREATE OPERATOR |>> ( ); -- Availability: 2.0.0 -CREATE OPERATOR CLASS gist_geometry_ops +CREATE OPERATOR CLASS gist_geometry_ops_2d DEFAULT FOR TYPE geometry USING GIST AS STORAGE box2df, OPERATOR 1 << ,