]> granicus.if.org Git - postgis/commitdiff
added expand_bbox(bbox,double) for easier searching.
authorDavid Blasby <dblasby@gmail.com>
Tue, 24 Jul 2001 20:37:29 +0000 (20:37 +0000)
committerDavid Blasby <dblasby@gmail.com>
Tue, 24 Jul 2001 20:37:29 +0000 (20:37 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@38 b70326c6-7e19-0410-871a-916f4a2858ee

postgis.h
postgis.sql.in
postgis_fn.c

index 6ba767aeffd5d50d7c1ef70fad92ffa8ff95708d..3be7aaa4012cc219dac1c9b0dda33625477b9149 100644 (file)
--- 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*);
index 41821646eab7b5543ffd247a2c8f6eb4ef9e8994..f92f6004967d2724edc7f2e7886012530452b279 100644 (file)
@@ -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)
index 1687633c6d3a2bcd2c5a7ecd32a82e36682c4430..746ad1576649c0eac36cb01db9c93480b672fed0 100644 (file)
@@ -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);
+}
+
+