PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ postgis_typmod_out()

Datum postgis_typmod_out ( PG_FUNCTION_ARGS  )

Definition at line 63 of file gserialized_typmod.c.

References lwtype_name(), s, ovdump::type, TYPMOD_GET_M, TYPMOD_GET_SRID, TYPMOD_GET_TYPE, and TYPMOD_GET_Z.

64 {
65  char *s = (char*)palloc(64);
66  char *str = s;
67  uint32 typmod = PG_GETARG_INT32(0);
68  uint32 srid = TYPMOD_GET_SRID(typmod);
69  uint32 type = TYPMOD_GET_TYPE(typmod);
70  uint32 hasz = TYPMOD_GET_Z(typmod);
71  uint32 hasm = TYPMOD_GET_M(typmod);
72 
73  POSTGIS_DEBUGF(3, "Got typmod(srid = %d, type = %d, hasz = %d, hasm = %d)", srid, type, hasz, hasm);
74 
75  /* No SRID or type or dimensionality? Then no typmod at all. Return empty string. */
76  if ( ! ( srid || type || hasz || hasm ) )
77  {
78  *str = '\0';
79  PG_RETURN_CSTRING(str);
80  }
81 
82  /* Opening bracket. */
83  str += sprintf(str, "(");
84 
85  /* Has type? */
86  if ( type )
87  str += sprintf(str, "%s", lwtype_name(type));
88  else if ( (!type) && ( srid || hasz || hasm ) )
89  str += sprintf(str, "Geometry");
90 
91  /* Has Z? */
92  if ( hasz )
93  str += sprintf(str, "%s", "Z");
94 
95  /* Has M? */
96  if ( hasm )
97  str += sprintf(str, "%s", "M");
98 
99  /* Comma? */
100  if ( srid )
101  str += sprintf(str, ",");
102 
103  /* Has SRID? */
104  if ( srid )
105  str += sprintf(str, "%d", srid);
106 
107  /* Closing bracket. */
108  str += sprintf(str, ")");
109 
110  PG_RETURN_CSTRING(s);
111 
112 }
#define TYPMOD_GET_TYPE(typmod)
Definition: liblwgeom.h:167
#define TYPMOD_GET_M(typmod)
Definition: liblwgeom.h:171
#define TYPMOD_GET_SRID(typmod)
Macros for manipulating the 'typemod' int.
Definition: liblwgeom.h:165
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
char * s
Definition: cu_in_wkt.c:23
type
Definition: ovdump.py:41
#define TYPMOD_GET_Z(typmod)
Definition: liblwgeom.h:169
Here is the call graph for this function: