PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ postgis_typmod_out()

Datum postgis_typmod_out ( PG_FUNCTION_ARGS  )

Definition at line 62 of file gserialized_typmod.c.

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

63 {
64  char *s = (char*)palloc(64);
65  char *str = s;
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  *str = '\0';
78  PG_RETURN_CSTRING(str);
79  }
80 
81  /* Opening bracket. */
82  str += sprintf(str, "(");
83 
84  /* Has type? */
85  if (type)
86  str += sprintf(str, "%s", lwtype_name(type));
87  else if (srid || hasz || hasm)
88  str += sprintf(str, "Geometry");
89 
90  /* Has Z? */
91  if (hasz) str += sprintf(str, "%s", "Z");
92 
93  /* Has M? */
94  if (hasm) str += sprintf(str, "%s", "M");
95 
96  /* Has SRID? */
97  if (srid) str += sprintf(str, ",%d", srid);
98 
99  /* Closing bracket. */
100  str += sprintf(str, ")");
101 
102  PG_RETURN_CSTRING(s);
103 
104 }
#define TYPMOD_GET_TYPE(typmod)
Definition: liblwgeom.h:166
unsigned int int32
Definition: shpopen.c:273
#define TYPMOD_GET_M(typmod)
Definition: liblwgeom.h:170
#define TYPMOD_GET_SRID(typmod)
Macros for manipulating the &#39;typemod&#39; int.
Definition: liblwgeom.h:164
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
char * s
Definition: cu_in_wkt.c:23
type
Definition: ovdump.py:41
#define TYPMOD_GET_Z(typmod)
Definition: liblwgeom.h:168
Here is the call graph for this function: