PostGIS  2.5.0beta1dev-r@@SVN_REVISION@@

◆ geometry_geometrytype()

Datum geometry_geometrytype ( PG_FUNCTION_ARGS  )

Definition at line 177 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().

178 {
179  GSERIALIZED *gser;
180  text *type_text;
181 # define type_str_len 31
182  char type_str[type_str_len + 1];
183 
184  /* Read just the header from the toasted tuple */
185  gser = PG_GETARG_GSERIALIZED_P_SLICE(0, 0, gserialized_max_header_size());
186 
187  /* Make it empty string to start */
188  type_str[0] = 0;
189 
190  /* Build up the output string */
191  strncat(type_str, "ST_", type_str_len);
192  strncat(type_str, lwtype_name(gserialized_get_type(gser)), type_str_len - 3);
193 
194  /* Build a text type to store things in */
195  type_text = cstring_to_text(type_str);
196 
197  PG_FREE_IF_COPY(gser, 0);
198  PG_RETURN_TEXT_P(type_text);
199 }
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: