PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ postgis_typmod_out()

Datum postgis_typmod_out ( PG_FUNCTION_ARGS  )

Definition at line 62 of file gserialized_typmod.c.

63 {
64  StringInfoData si;
65  // char *s = (char*)palloc(64);
66  int32 typmod = PG_GETARG_INT32(0);
67  int32 srid = TYPMOD_GET_SRID(typmod);
68  int32 type = TYPMOD_GET_TYPE(typmod);
69  int32 hasz = TYPMOD_GET_Z(typmod);
70  int32 hasm = TYPMOD_GET_M(typmod);
71 
72  POSTGIS_DEBUGF(3, "Got typmod(srid = %d, type = %d, hasz = %d, hasm = %d)", srid, type, hasz, hasm);
73 
74  /* No SRID or type or dimensionality? Then no typmod at all. Return empty string. */
75  if (!(srid || type || hasz || hasm) || typmod < 0)
76  {
77  PG_RETURN_CSTRING(pstrdup(""));
78  }
79 
80  /* Opening bracket. */
81  initStringInfo(&si);
82  appendStringInfoChar(&si, '(');
83 
84  /* Has type? */
85  if (type)
86  appendStringInfo(&si, "%s", lwtype_name(type));
87  else if (srid || hasz || hasm)
88  appendStringInfoString(&si, "Geometry");
89 
90  /* Has Z? */
91  if (hasz) appendStringInfoString(&si, "Z");
92 
93  /* Has M? */
94  if (hasm) appendStringInfoString(&si, "M");
95 
96  /* Has SRID? */
97  if (srid) appendStringInfo(&si, ",%d", srid);
98 
99  /* Closing bracket. */
100  appendStringInfoChar(&si, ')');
101 
102  PG_RETURN_CSTRING(si.data);
103 }
#define TYPMOD_GET_SRID(typmod)
Macros for manipulating the 'typemod' int.
Definition: liblwgeom.h:206
#define TYPMOD_GET_M(typmod)
Definition: liblwgeom.h:212
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
#define TYPMOD_GET_TYPE(typmod)
Definition: liblwgeom.h:208
#define TYPMOD_GET_Z(typmod)
Definition: liblwgeom.h:210
type
Definition: ovdump.py:42
unsigned int int32
Definition: shpopen.c:273

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

Here is the call graph for this function: