PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_getTYPE()

Datum LWGEOM_getTYPE ( PG_FUNCTION_ARGS  )

Definition at line 116 of file lwgeom_ogc.c.

References CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, geometry_geometrytype(), gserialized_get_type(), gserialized_has_m(), gserialized_has_z(), gserialized_max_header_size(), LINETYPE, MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, PG_FUNCTION_INFO_V1(), POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, TINTYPE, TRIANGLETYPE, and ovdump::type.

Referenced by LWGEOM_set_srid().

117 {
118  GSERIALIZED *gser;
119  text *text_ob;
120  char *result;
121  uint8_t type;
122  static int maxtyplen = 20;
123 
124  gser = PG_GETARG_GSERIALIZED_P_SLICE(0, 0, gserialized_max_header_size());
125  text_ob = palloc0(VARHDRSZ + maxtyplen);
126  result = VARDATA(text_ob);
127 
128  type = gserialized_get_type(gser);
129 
130  if (type == POINTTYPE)
131  strcpy(result,"POINT");
132  else if (type == MULTIPOINTTYPE)
133  strcpy(result,"MULTIPOINT");
134  else if (type == LINETYPE)
135  strcpy(result,"LINESTRING");
136  else if (type == CIRCSTRINGTYPE)
137  strcpy(result,"CIRCULARSTRING");
138  else if (type == COMPOUNDTYPE)
139  strcpy(result, "COMPOUNDCURVE");
140  else if (type == MULTILINETYPE)
141  strcpy(result,"MULTILINESTRING");
142  else if (type == MULTICURVETYPE)
143  strcpy(result, "MULTICURVE");
144  else if (type == POLYGONTYPE)
145  strcpy(result,"POLYGON");
146  else if (type == TRIANGLETYPE)
147  strcpy(result,"TRIANGLE");
148  else if (type == CURVEPOLYTYPE)
149  strcpy(result,"CURVEPOLYGON");
150  else if (type == MULTIPOLYGONTYPE)
151  strcpy(result,"MULTIPOLYGON");
152  else if (type == MULTISURFACETYPE)
153  strcpy(result, "MULTISURFACE");
154  else if (type == COLLECTIONTYPE)
155  strcpy(result,"GEOMETRYCOLLECTION");
156  else if (type == POLYHEDRALSURFACETYPE)
157  strcpy(result,"POLYHEDRALSURFACE");
158  else if (type == TINTYPE)
159  strcpy(result,"TIN");
160  else
161  strcpy(result,"UNKNOWN");
162 
163  if ( gserialized_has_m(gser) && ! gserialized_has_z(gser) )
164  strcat(result, "M");
165 
166  SET_VARSIZE(text_ob, strlen(result) + VARHDRSZ); /* size of string */
167 
168  PG_FREE_IF_COPY(gser, 0);
169 
170  PG_RETURN_TEXT_P(text_ob);
171 }
#define LINETYPE
Definition: liblwgeom.h:86
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
#define MULTICURVETYPE
Definition: liblwgeom.h:95
int gserialized_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
Definition: g_serialized.c:50
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define TRIANGLETYPE
Definition: liblwgeom.h:98
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:45
#define TINTYPE
Definition: liblwgeom.h:99
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
type
Definition: ovdump.py:41
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
#define MULTILINETYPE
Definition: liblwgeom.h:89
unsigned char uint8_t
Definition: uthash.h:79
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
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: