From: Paul Ramsey Date: Wed, 15 Jun 2011 23:59:40 +0000 (+0000) Subject: Fix up selectivity and operators a little X-Git-Tag: 2.0.0alpha1~1421 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=70f2e449a074749e27e809c1486d7d142cbab5f0;p=postgis Fix up selectivity and operators a little git-svn-id: http://svn.osgeo.org/postgis/trunk@7402 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/g_box.c b/liblwgeom/g_box.c index fe9440a43..a8aea301c 100644 --- a/liblwgeom/g_box.c +++ b/liblwgeom/g_box.c @@ -88,6 +88,23 @@ BOX3D* box3d_from_gbox(const GBOX *gbox) return b; } +/* TODO to be removed */ +GBOX* box3d_to_gbox(const BOX3D *b3d) +{ + GBOX *b; + assert(b3d); + + b = lwalloc(sizeof(GBOX)); + + b->xmin = b3d->xmin; + b->xmax = b3d->xmax; + b->ymin = b3d->ymin; + b->ymax = b3d->ymax; + b->zmin = b3d->zmin; + b->zmax = b3d->zmax; + + return b; +} void gbox_expand(GBOX *g, double d) { diff --git a/liblwgeom/liblwgeom.h b/liblwgeom/liblwgeom.h index 33c38fd21..212fb4740 100644 --- a/liblwgeom/liblwgeom.h +++ b/liblwgeom/liblwgeom.h @@ -1415,6 +1415,7 @@ extern int box3d_union_p(BOX3D *b1, BOX3D *b2, BOX3D *ubox); extern BOX3D* box3d_from_gbox(const GBOX *gbox); +extern GBOX* box3d_to_gbox(const BOX3D *b3d); /* * Returns a pointer to the BBOX internal to the serialized form. diff --git a/postgis/geography.sql.in.c b/postgis/geography.sql.in.c index d5cd5484a..29c6a4caa 100644 --- a/postgis/geography.sql.in.c +++ b/postgis/geography.sql.in.c @@ -819,14 +819,14 @@ CREATE OR REPLACE FUNCTION geometry_gist_decompress_nd(internal) -- LANGUAGE 'C'; -- Availability: 2.0.0 -CREATE OR REPLACE FUNCTION geometry_overlaps_nd(geography, geography) +CREATE OR REPLACE FUNCTION geometry_overlaps_nd(geometry, geometry) RETURNS boolean AS 'MODULE_PATHNAME' ,'gserialized_overlaps' LANGUAGE 'C' IMMUTABLE STRICT; -- Availability: 2.0.0 CREATE OPERATOR &&& ( - LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_overlaps, + LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_overlaps_nd, COMMUTATOR = '&&&' ,RESTRICT = contsel, JOIN = contjoinsel -- ,RESTRICT = geometry_gist_selectivity_nd diff --git a/postgis/geometry_gist_selectivity.c b/postgis/geometry_gist_selectivity.c index 1c991e844..10711b865 100644 --- a/postgis/geometry_gist_selectivity.c +++ b/postgis/geometry_gist_selectivity.c @@ -110,9 +110,9 @@ static float8 estimate_selectivity(GBOX *box, GEOM_STATS *geomstats); */ #define REALLY_DO_JOINSEL 1 -Datum geometry_gist_sel(PG_FUNCTION_ARGS); -Datum geometry_gist_joinsel(PG_FUNCTION_ARGS); -Datum geometry_analyze(PG_FUNCTION_ARGS); +Datum geometry_gist_sel_2d(PG_FUNCTION_ARGS); +Datum geometry_gist_joinsel_2d(PG_FUNCTION_ARGS); +Datum geometry_analyze_2d(PG_FUNCTION_ARGS); Datum geometry_estimated_extent(PG_FUNCTION_ARGS); @@ -164,8 +164,8 @@ calculate_column_intersection(GBOX *search_box, GEOM_STATS *geomstats1, GEOM_STA * JOIN selectivity in the GiST && operator * for all PG versions */ -PG_FUNCTION_INFO_V1(geometry_gist_joinsel); -Datum geometry_gist_joinsel(PG_FUNCTION_ARGS) +PG_FUNCTION_INFO_V1(geometry_gist_joinsel_2d); +Datum geometry_gist_joinsel_2d(PG_FUNCTION_ARGS) { PlannerInfo *root = (PlannerInfo *) PG_GETARG_POINTER(0); @@ -626,8 +626,8 @@ estimate_selectivity(GBOX *box, GEOM_STATS *geomstats) * This is the one used for PG version >= 7.5 * */ -PG_FUNCTION_INFO_V1(geometry_gist_sel); -Datum geometry_gist_sel(PG_FUNCTION_ARGS) +PG_FUNCTION_INFO_V1(geometry_gist_sel_2d); +Datum geometry_gist_sel_2d(PG_FUNCTION_ARGS) { PlannerInfo *root = (PlannerInfo *) PG_GETARG_POINTER(0); @@ -1289,8 +1289,8 @@ compute_geometry_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, * value for now. * */ -PG_FUNCTION_INFO_V1(geometry_analyze); -Datum geometry_analyze(PG_FUNCTION_ARGS) +PG_FUNCTION_INFO_V1(geometry_analyze_2d); +Datum geometry_analyze_2d(PG_FUNCTION_ARGS) { VacAttrStats *stats = (VacAttrStats *)PG_GETARG_POINTER(0); Form_pg_attribute attr = stats->attr; diff --git a/postgis/lwgeom_box3d.c b/postgis/lwgeom_box3d.c index c9a300cf7..4dd77316a 100644 --- a/postgis/lwgeom_box3d.c +++ b/postgis/lwgeom_box3d.c @@ -192,7 +192,11 @@ PG_FUNCTION_INFO_V1(BOX3D_to_BOX2DFLOAT4); Datum BOX3D_to_BOX2DFLOAT4(PG_FUNCTION_ARGS) { BOX3D *in = (BOX3D *)PG_GETARG_POINTER(0); +#ifdef GSERIALIZED_ON + BOX2DFLOAT4 *out = box3d_to_gbox(in); +#else BOX2DFLOAT4 *out = box3d_to_box2df(in); +#endif PG_RETURN_POINTER(out); } diff --git a/postgis/postgis.sql.in.c b/postgis/postgis.sql.in.c index a4e0d5117..1431224c2 100644 --- a/postgis/postgis.sql.in.c +++ b/postgis/postgis.sql.in.c @@ -64,7 +64,7 @@ CREATE OR REPLACE FUNCTION geometry_out(geometry) CREATE OR REPLACE FUNCTION geometry_analyze(internal) RETURNS bool #ifdef GSERIALIZED_ON - AS 'MODULE_PATHNAME', 'geometry_analyze' + AS 'MODULE_PATHNAME', 'geometry_analyze_2d' #else AS 'MODULE_PATHNAME', 'LWGEOM_analyze' #endif @@ -526,16 +526,16 @@ CREATE OR REPLACE FUNCTION geometry_gist_decompress_2d(internal) LANGUAGE 'C'; -- Availability: 2.0.0 ---CREATE OR REPLACE FUNCTION geometry_gist_sel_2d (internal, oid, internal, int4) --- RETURNS float8 --- AS 'MODULE_PATHNAME', 'gserialized_gist_sel_2d' --- LANGUAGE 'C'; +CREATE OR REPLACE FUNCTION geometry_gist_sel_2d (internal, oid, internal, int4) + RETURNS float8 + AS 'MODULE_PATHNAME', 'geometry_gist_sel_2d' + LANGUAGE 'C'; -- Availability: 2.0.0 ---CREATE OR REPLACE FUNCTION geometry_gist_joinsel_2d(internal, oid, internal, smallint) --- RETURNS float8 --- AS 'MODULE_PATHNAME', 'gserialized_gist_joinsel_2d' --- LANGUAGE 'C'; +CREATE OR REPLACE FUNCTION geometry_gist_joinsel_2d(internal, oid, internal, smallint) + RETURNS float8 + AS 'MODULE_PATHNAME', 'geometry_gist_joinsel_2d' + LANGUAGE 'C'; ----------------------------------------------------------------------------- -- GEOMETRY Operators @@ -550,8 +550,8 @@ CREATE OR REPLACE FUNCTION geometry_overlaps(geometry, geometry) CREATE OPERATOR && ( LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_overlaps, COMMUTATOR = '&&' - ,RESTRICT = contsel, JOIN = contjoinsel --- ,RESTRICT = geometry_gist_sel_2d, JOIN = geometry_gist_joinsel_2d +-- ,RESTRICT = contsel, JOIN = contjoinsel + ,RESTRICT = geometry_gist_sel_2d, JOIN = geometry_gist_joinsel_2d ); -- Availability: 2.0.0