From 75beff5557fb157d3c388e8d9fec4298923b5456 Mon Sep 17 00:00:00 2001 From: Chris Hodgson Date: Mon, 6 May 2002 17:35:30 +0000 Subject: [PATCH] - changed add_to_geometry() and collector() so that the sql collect() aggregate returns the simplest possible geometric type, ie. a MULTIPOINT instead of a GEOMETRYCOLLECTIONwhen all of the geometries being collected are of either POINT or MULTIPOINT type git-svn-id: http://svn.osgeo.org/postgis/trunk@158 b70326c6-7e19-0410-871a-916f4a2858ee --- Makefile | 2 +- postgis_fn.c | 9 ++++----- postgis_inout.c | 8 ++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index bc2e9911b..8b4fae8e9 100644 --- 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 diff --git a/postgis_fn.c b/postgis_fn.c index 33239eb8f..513e7c918 100644 --- a/postgis_fn.c +++ b/postgis_fn.c @@ -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; inobjs; i++) diff --git a/postgis_inout.c b/postgis_inout.c index f59fd357e..fd5d84eb3 100644 --- a/postgis_inout.c +++ b/postgis_inout.c @@ -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; -- 2.40.0