PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ postgis_typmod_out()

Datum postgis_typmod_out ( PG_FUNCTION_ARGS  )

Definition at line 63 of file gserialized_typmod.c.

64 {
65  char *s = (char*)palloc(64);
66  char *str = s;
67  int32 typmod = PG_GETARG_INT32(0);
68  int32 srid = TYPMOD_GET_SRID(typmod);
69  int32 type = TYPMOD_GET_TYPE(typmod);
70  int32 hasz = TYPMOD_GET_Z(typmod);
71  int32 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) || typmod < 0)
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 (srid || hasz || hasm)
89  str += sprintf(str, "Geometry");
90 
91  /* Has Z? */
92  if (hasz) str += sprintf(str, "%s", "Z");
93 
94  /* Has M? */
95  if (hasm) str += sprintf(str, "%s", "M");
96 
97  /* Has SRID? */
98  if (srid) str += sprintf(str, ",%d", srid);
99 
100  /* Closing bracket. */
101  str += sprintf(str, ")");
102 
103  PG_RETURN_CSTRING(s);
104 
105 }
char * s
Definition: cu_in_wkt.c:23
#define TYPMOD_GET_SRID(typmod)
Macros for manipulating the 'typemod' int.
Definition: liblwgeom.h:165
#define TYPMOD_GET_M(typmod)
Definition: liblwgeom.h:171
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define TYPMOD_GET_TYPE(typmod)
Definition: liblwgeom.h:167
#define TYPMOD_GET_Z(typmod)
Definition: liblwgeom.h:169
type
Definition: ovdump.py:41
unsigned int int32
Definition: shpopen.c:273

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

Here is the call graph for this function: