PostGIS  2.2.7dev-r@@SVN_REVISION@@
Datum postgis_typmod_out ( PG_FUNCTION_ARGS  )

Definition at line 48 of file gserialized_typmod.c.

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

49 {
50  char *s = (char*)palloc(64);
51  char *str = s;
52  uint32 typmod = PG_GETARG_INT32(0);
53  uint32 srid = TYPMOD_GET_SRID(typmod);
54  uint32 type = TYPMOD_GET_TYPE(typmod);
55  uint32 hasz = TYPMOD_GET_Z(typmod);
56  uint32 hasm = TYPMOD_GET_M(typmod);
57 
58  POSTGIS_DEBUGF(3, "Got typmod(srid = %d, type = %d, hasz = %d, hasm = %d)", srid, type, hasz, hasm);
59 
60  /* No SRID or type or dimensionality? Then no typmod at all. Return empty string. */
61  if ( ! ( srid || type || hasz || hasm ) )
62  {
63  *str = '\0';
64  PG_RETURN_CSTRING(str);
65  }
66 
67  /* Opening bracket. */
68  str += sprintf(str, "(");
69 
70  /* Has type? */
71  if ( type )
72  str += sprintf(str, "%s", lwtype_name(type));
73  else if ( (!type) && ( srid || hasz || hasm ) )
74  str += sprintf(str, "Geometry");
75 
76  /* Has Z? */
77  if ( hasz )
78  str += sprintf(str, "%s", "Z");
79 
80  /* Has M? */
81  if ( hasm )
82  str += sprintf(str, "%s", "M");
83 
84  /* Comma? */
85  if ( srid )
86  str += sprintf(str, ",");
87 
88  /* Has SRID? */
89  if ( srid )
90  str += sprintf(str, "%d", srid);
91 
92  /* Closing bracket. */
93  str += sprintf(str, ")");
94 
95  PG_RETURN_CSTRING(s);
96 
97 }
#define TYPMOD_GET_TYPE(typmod)
Definition: liblwgeom.h:151
#define TYPMOD_GET_M(typmod)
Definition: liblwgeom.h:155
#define TYPMOD_GET_SRID(typmod)
Macros for manipulating the 'typemod' int.
Definition: liblwgeom.h:149
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
char * s
Definition: cu_in_wkt.c:23
#define TYPMOD_GET_Z(typmod)
Definition: liblwgeom.h:153

Here is the call graph for this function: