mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-26 01:52:37 +00:00
added full support for fluffType(<geom>)
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
This commit is contained in:
parent
ec09eba92d
commit
5512d40413
|
@ -12,6 +12,13 @@
|
|||
--
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- $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,6 +783,11 @@ 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
|
||||
|
@ -848,6 +860,7 @@ CREATE FUNCTION pointonsurface(geometry)
|
|||
LANGUAGE 'C' WITH (isstrict);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- BBox operations
|
||||
--
|
||||
|
|
|
@ -11,6 +11,13 @@
|
|||
*
|
||||
**********************************************************************
|
||||
* $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
|
||||
|
|
36
postgis_fn.c
36
postgis_fn.c
|
@ -11,6 +11,13 @@
|
|||
*
|
||||
**********************************************************************
|
||||
* $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)
|
||||
{
|
||||
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;
|
||||
return;
|
||||
}
|
||||
if (g->type == LINETYPE)
|
||||
{
|
||||
g->type = MULTILINETYPE;
|
||||
return;
|
||||
}
|
||||
if (g->type == POLYGONTYPE)
|
||||
{
|
||||
g->type = MULTIPOLYGONTYPE;
|
||||
return;
|
||||
}
|
||||
|
||||
PG_FREE_IF_COPY(geom1,0);
|
||||
PG_RETURN_POINTER(g);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue