From: Sandro Santilli Date: Wed, 6 Oct 2004 08:53:24 +0000 (+0000) Subject: Added zmflag(geom) function. X-Git-Tag: pgis_1_0_0RC1~331 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e00abe63fba6be06d8dc60cd333fc7d58a18151e;p=postgis Added zmflag(geom) function. git-svn-id: http://svn.osgeo.org/postgis/trunk@943 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/lwgeom/lwgeom_functions_basic.c b/lwgeom/lwgeom_functions_basic.c index ae5edb7dd..0678752df 100644 --- a/lwgeom/lwgeom_functions_basic.c +++ b/lwgeom/lwgeom_functions_basic.c @@ -49,6 +49,7 @@ Datum LWGEOM_segmentize2d(PG_FUNCTION_ARGS); Datum LWGEOM_reverse(PG_FUNCTION_ARGS); Datum LWGEOM_forceRHR_poly(PG_FUNCTION_ARGS); Datum LWGEOM_noop(PG_FUNCTION_ARGS); +Datum LWGEOM_zmflag(PG_FUNCTION_ARGS); // internal int32 lwgeom_nrings_recursive(char *serialized); @@ -3007,3 +3008,22 @@ Datum LWGEOM_noop(PG_FUNCTION_ARGS) PG_RETURN_POINTER(out); } + +// Return: +// 0==2d +// 1==3dm +// 2==3dz +// 3==4d +PG_FUNCTION_INFO_V1(LWGEOM_zmflag); +Datum LWGEOM_zmflag(PG_FUNCTION_ARGS) +{ + PG_LWGEOM *in; + unsigned char type; + int ret = 0; + + in = (PG_LWGEOM *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0)); + type = in->type; + if ( TYPE_HASZ(type) ) ret += 2; + if ( TYPE_HASM(type) ) ret += 1; + PG_RETURN_INT16(ret); +} diff --git a/lwgeom/lwpostgis.sql.in b/lwgeom/lwpostgis.sql.in index 9fc57c89b..3fd0e9dc0 100644 --- a/lwgeom/lwpostgis.sql.in +++ b/lwgeom/lwpostgis.sql.in @@ -1633,6 +1633,11 @@ CREATEFUNCTION noop(geometry) AS '@MODULE_FILENAME@', 'LWGEOM_noop' LANGUAGE 'C' WITH (iscachable,isstrict); +CREATEFUNCTION zmflag(geometry) + RETURNS smallint + AS '@MODULE_FILENAME@', 'LWGEOM_zmflag' + LANGUAGE 'C' WITH (iscachable,isstrict); + ------------------------------------------------------------------------ --