]> granicus.if.org Git - postgis/commitdiff
- changed add_to_geometry() and collector() so that the sql collect() aggregate retur...
authorChris Hodgson <chodgson@refractions.net>
Mon, 6 May 2002 17:35:30 +0000 (17:35 +0000)
committerChris Hodgson <chodgson@refractions.net>
Mon, 6 May 2002 17:35:30 +0000 (17:35 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@158 b70326c6-7e19-0410-871a-916f4a2858ee

Makefile
postgis_fn.c
postgis_inout.c

index bc2e9911bfe91de88117e2a469f815c2923c4749..8b4fae8e982b5723a4234e01e7cfb83d4cbf06f0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Configuration Directives
 #---------------------------------------------------------------
-# Set USE_PG72 to 1 for PostgreSQL version >= 7.3
+# Set USE_PG72 to 1 for PostgreSQL version >= 7.2
 USE_PG72=0
 #---------------------------------------------------------------
 # Set USE_PROJ to 1 for Proj4 reprojection support
index 33239eb8f019be9e968f3abda356eac85f59a419..513e7c9183a048635f607a3efddd6e2ed2f16f59 100644 (file)
@@ -2488,7 +2488,9 @@ Datum segmentize(PG_FUNCTION_ARGS)
 // collector( geom, geom ) returns a geometry which contains
 // all the sub_objects from both of the argument geometries
 
-// returned geometry is always a geomtry collection
+// returned geometry is the simplest possible, based on the types
+// of the colelct objects 
+// ie. if all are of either X or multiX, then a multiX is returned
 // bboxonly types are treated as null geometries (no sub_objects)
 PG_FUNCTION_INFO_V1( collector );
 Datum collector( PG_FUNCTION_ARGS )
@@ -2511,7 +2513,6 @@ Datum collector( PG_FUNCTION_ARGS )
                geom2 = (GEOMETRY *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
                result = (GEOMETRY *)palloc( geom2->size );
                memcpy( result, geom2, geom2->size );
-               result->type = COLLECTIONTYPE;
                PG_RETURN_POINTER(result);
        }
 
@@ -2521,7 +2522,6 @@ Datum collector( PG_FUNCTION_ARGS )
                geom1 = (GEOMETRY *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
                result = (GEOMETRY *)palloc( geom1->size );
                memcpy( result, geom1, geom1->size );
-               result->type = COLLECTIONTYPE;
                PG_RETURN_POINTER(result);
        }
 
@@ -2534,8 +2534,7 @@ Datum collector( PG_FUNCTION_ARGS )
        }
        result = (GEOMETRY *)palloc( geom1->size );
        memcpy( result, geom1, geom1->size );
-       result->type = COLLECTIONTYPE;
-
+               
        offsets2 = (int32 *)( ((char *)&(geom2->objType[0])) + sizeof( int32 ) * geom2->nobjs ) ;
 
        for (i=0; i<geom2->nobjs; i++)
index f59fd357e4a727515be26e951697c161932f932e..fd5d84eb316bd83a04303edee0346e492f214a7b 100644 (file)
@@ -2979,22 +2979,22 @@ GEOMETRY        *add_to_geometry(GEOMETRY *geom,int sub_obj_size, char *sub_obj, int ty
                type = POLYGONTYPE;
 
 
-       //simple conversion
-       if  (geom->type == POINTTYPE)
+       // change to the simplest possible type that supports the type being added
+       if  (geom->type == POINTTYPE || geom->type == MULTIPOINTTYPE)
        {
                if (type == POINTTYPE)
                        result->type  = MULTIPOINTTYPE;
                else
                        result->type  = COLLECTIONTYPE;
        }
-       if  (geom->type == LINETYPE)
+       if  (geom->type == LINETYPE || geom->type == MULTILINETYPE)
        {
                if (type == LINETYPE)
                        result->type  = MULTILINETYPE;
                else
                        result->type  = COLLECTIONTYPE;
        }
-       if  (geom->type == POLYGONTYPE)
+       if  (geom->type == POLYGONTYPE || geom->type == MULTIPOLYGONTYPE)
        {
                if (type == POLYGONTYPE)
                        result->type  = MULTIPOLYGONTYPE;