PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ geometry_geometrytype()

Datum geometry_geometrytype ( PG_FUNCTION_ARGS  )

Definition at line 176 of file lwgeom_ogc.c.

References gserialized_get_type(), gserialized_max_header_size(), LWGEOM_numpoints_linestring(), lwtype_name(), PG_FUNCTION_INFO_V1(), and type_str_len.

Referenced by LWGEOM_getTYPE().

177 {
178  GSERIALIZED *gser;
179  text *type_text;
180 # define type_str_len 31
181  char type_str[type_str_len + 1];
182 
183  /* Read just the header from the toasted tuple */
184  gser = PG_GETARG_GSERIALIZED_P_SLICE(0, 0, gserialized_max_header_size());
185 
186  /* Make it empty string to start */
187  type_str[0] = 0;
188 
189  /* Build up the output string */
190  strncat(type_str, "ST_", type_str_len);
191  strncat(type_str, lwtype_name(gserialized_get_type(gser)), type_str_len - 3);
192 
193  /* Build a text type to store things in */
194  type_text = cstring2text(type_str);
195 
196  PG_FREE_IF_COPY(gser, 0);
197  PG_RETURN_TEXT_P(type_text);
198 }
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:86
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define type_str_len
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:70
Here is the call graph for this function:
Here is the caller graph for this function: