PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_getTYPE()

Datum LWGEOM_getTYPE ( PG_FUNCTION_ARGS  )

Definition at line 117 of file lwgeom_ogc.c.

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

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

Here is the call graph for this function: