From e21afcb263e93b577c494edc0bcc20932a533a27 Mon Sep 17 00:00:00 2001 From: David Blasby Date: Tue, 24 Jul 2001 20:37:29 +0000 Subject: [PATCH] added expand_bbox(bbox,double) for easier searching. git-svn-id: http://svn.osgeo.org/postgis/trunk@38 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis.h | 1 + postgis.sql.in | 6 ++++++ postgis_fn.c | 28 +++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/postgis.h b/postgis.h index 6ba767aef..3be7aaa40 100644 --- a/postgis.h +++ b/postgis.h @@ -385,6 +385,7 @@ Datum length3d_ellipsoid(PG_FUNCTION_ARGS); Datum point_inside_circle(PG_FUNCTION_ARGS); Datum distance(PG_FUNCTION_ARGS); +Datum expand_bbox(PG_FUNCTION_ARGS); //for GIST index typedef char* (*BINARY_UNION)(char*, char*, int*); diff --git a/postgis.sql.in b/postgis.sql.in index 41821646e..f92f60049 100644 --- a/postgis.sql.in +++ b/postgis.sql.in @@ -74,6 +74,12 @@ CREATE FUNCTION geometry(BOX3D) AS '@MODULE_FILENAME@','get_geometry_of_bbox' LANGUAGE 'c' WITH (iscachable,isstrict); +CREATE FUNCTION expand(BOX3D,float8) + RETURNS BOX3D + AS '@MODULE_FILENAME@','expand_bbox' + LANGUAGE 'c' WITH (iscachable,isstrict); + + --------- functions for converting to wkb CREATE FUNCTION asbinary(GEOMETRY) diff --git a/postgis_fn.c b/postgis_fn.c index 1687633c6..746ad1576 100644 --- a/postgis_fn.c +++ b/postgis_fn.c @@ -2000,4 +2000,30 @@ Datum distance(PG_FUNCTION_ARGS) if (dist <0) dist = 0; //computational error, may get -0.00000000001 PG_RETURN_FLOAT8(dist); -} \ No newline at end of file +} + + +//expand_bbox(bbox3d, d) +// returns a new bbox which is exanded d unit in all directions +PG_FUNCTION_INFO_V1(expand_bbox); +Datum expand_bbox(PG_FUNCTION_ARGS) +{ + BOX3D *bbox = (BOX3D *) PG_GETARG_POINTER(0); + double d = PG_GETARG_FLOAT8(1); + BOX3D *result = (BOX3D *) palloc(sizeof(BOX3D)); + + + result->LLB.x = bbox->LLB.x - d; + result->LLB.y = bbox->LLB.y - d; + result->LLB.z = bbox->LLB.z - d; + + + result->URT.x = bbox->URT.x + d; + result->URT.y = bbox->URT.y + d; + result->URT.z = bbox->URT.z + d; + + + PG_RETURN_POINTER(result); +} + + -- 2.40.0