PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum geometry_geometrytype ( PG_FUNCTION_ARGS  )

Definition at line 168 of file lwgeom_ogc.c.

References gserialized_get_type(), gserialized_max_header_size(), and lwtype_name().

169 {
170  GSERIALIZED *gser;
171  text *type_text;
172  char *type_str = palloc(32);
173 
174  /* Read just the header from the toasted tuple */
175  gser = (GSERIALIZED*)PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(0), 0, gserialized_max_header_size());
176 
177  /* Make it empty string to start */
178  *type_str = 0;
179 
180  /* Build up the output string */
181  strncat(type_str, "ST_", 32);
182  strncat(type_str, lwtype_name(gserialized_get_type(gser)), 32);
183 
184  /* Build a text type to store things in */
185  type_text = cstring2text(type_str);
186  pfree(type_str);
187 
188  PG_FREE_IF_COPY(gser, 0);
189  PG_RETURN_TEXT_P(type_text);
190 }
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
Definition: g_serialized.c:56
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:164
uint32_t gserialized_max_header_size(void)
Returns the size in bytes to read from toast to get the basic information from a geometry: GSERIALIZE...
Definition: g_serialized.c:50

Here is the call graph for this function: