]> granicus.if.org Git - postgis/commitdiff
added full support for fluffType(<geom>)
authorDavid Blasby <dblasby@gmail.com>
Fri, 26 Mar 2004 00:54:09 +0000 (00:54 +0000)
committerDavid Blasby <dblasby@gmail.com>
Fri, 26 Mar 2004 00:54:09 +0000 (00:54 +0000)
postgis09=# select fluffType('POINT(0 0)');
        flufftype
-------------------------
 SRID=-1;MULTIPOINT(0 0)

git-svn-id: http://svn.osgeo.org/postgis/trunk@493 b70326c6-7e19-0410-871a-916f4a2858ee

Attic/postgis_sql_common.sql.in
postgis.h
postgis_fn.c

index 5595ae8373d5f6fdf4b6cd449cb154d89b34cdb3..f6f761d00321a87b7033d9ad28a91ae1e9188beb 100644 (file)
 --  
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -- $Log$
+-- Revision 1.28  2004/03/26 00:54:09  dblasby
+-- added full support for fluffType(<geom>)
+-- postgis09=# select fluffType('POINT(0 0)');
+--         flufftype
+--             -------------------------
+--              SRID=-1;MULTIPOINT(0 0)
+--
 -- Revision 1.27  2004/01/21 19:04:03  strk
 -- Added line_interpolate_point function by jsunday@rochgrp.com
 --
@@ -776,7 +783,12 @@ CREATE FUNCTION distance_spheroid(geometry,geometry,spheroid)
 --
 -- Generic operations
 --
-
+CREATE FUNCTION fluffType(geometry)
+       RETURNS geometry
+       AS '@MODULE_FILENAME@','fluffType'
+       LANGUAGE 'C' WITH (isstrict);
+       
+       
 CREATE FUNCTION length3d(geometry)
        RETURNS FLOAT8
        AS '@MODULE_FILENAME@'
@@ -847,6 +859,7 @@ CREATE FUNCTION pointonsurface(geometry)
        AS '@MODULE_FILENAME@'
        LANGUAGE 'C' WITH (isstrict);
        
+       
 
 --
 -- BBox operations
index 9d3080001b03abc9a7f86144b085bc2c9c4c81a2..a01da06b2d943462ab4d41d4da89d6c25fbdfe85 100644 (file)
--- a/postgis.h
+++ b/postgis.h
  *
  **********************************************************************
  * $Log$
+ * Revision 1.43  2004/03/26 00:54:09  dblasby
+ * added full support for fluffType(<geom>)
+ * postgis09=# select fluffType('POINT(0 0)');
+ *         flufftype
+ *             -------------------------
+ *              SRID=-1;MULTIPOINT(0 0)
+ *
  * Revision 1.42  2004/02/23 12:18:55  strk
  * added skeleton functions for pg75 stats integration
  *
@@ -650,6 +657,8 @@ Datum isempty(PG_FUNCTION_ARGS);
 Datum simplify(PG_FUNCTION_ARGS);
 Datum line_interpolate_point(PG_FUNCTION_ARGS);
 
+Datum fluffType(PG_FUNCTION_ARGS);
+
 /*--------------------------------------------------------------------
  * Useful floating point utilities and constants.
  * from postgres geo_decls.c
index ea50e7396e59be19cd90fdbbbefe7a8064b6862c..703584a77c5bf50208aaf79554fb7316676a396e 100644 (file)
  *
  **********************************************************************
  * $Log$
+ * Revision 1.34  2004/03/26 00:54:09  dblasby
+ * added full support for fluffType(<geom>)
+ * postgis09=# select fluffType('POINT(0 0)');
+ *         flufftype
+ *             -------------------------
+ *              SRID=-1;MULTIPOINT(0 0)
+ *
  * Revision 1.33  2004/03/25 00:43:41  dblasby
  * added function fluffType() that takes POINT LINESTRING or POLYGON
  * type and converts it to a multi*.
@@ -3043,24 +3050,45 @@ void compressType(GEOMETRY *g)
        }
 }
 
+
 // converts single-type (point,linestring,polygon)
 // to multi* types with 1 element
 // ie. POINT(0 0) --> MULTIPOINT(0 0)
-void fluffType(GEOMETRY *g)
+//
+//postgis09=# select fluffType('POINT(0 0)');
+//        flufftype
+//-------------------------
+// SRID=-1;MULTIPOINT(0 0)
+//(1 row)
+//
+//postgis09=# select fluffType('LINESTRING(0 0, 1 1)');
+//             flufftype
+//------------------------------------
+// SRID=-1;MULTILINESTRING((0 0,1 1))
+//(1 row)
+
+PG_FUNCTION_INFO_V1(fluffType);
+Datum fluffType(PG_FUNCTION_ARGS)
 {
-               if (g->type == POINTTYPE)
-               {
-                       g->type = MULTIPOINTTYPE;
-                       return;
-               }
-               if (g->type == LINETYPE)
-               {
-                       g->type = MULTILINETYPE;
-                       return;
-               }
-               if (g->type == POLYGONTYPE)
-               {
-                       g->type = MULTIPOLYGONTYPE;
-                       return;
-               }
+               GEOMETRY                      *geom1= (GEOMETRY *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+               GEOMETRY                          *g;
+
+               g = (GEOMETRY*) palloc( *((int *) geom1) );
+               memcpy(g,geom1, *((int *) geom1));
+
+                       if (g->type == POINTTYPE)
+                       {
+                               g->type = MULTIPOINTTYPE;
+                       }
+                       if (g->type == LINETYPE)
+                       {
+                               g->type = MULTILINETYPE;
+                       }
+                       if (g->type == POLYGONTYPE)
+                       {
+                               g->type = MULTIPOLYGONTYPE;
+                       }
+
+       PG_FREE_IF_COPY(geom1,0);
+       PG_RETURN_POINTER(g);
 }