PostGIS  3.4.0dev-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_HEADER(0);
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 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:262
int gserialized_has_m(const GSERIALIZED *g)
Check if a GSERIALIZED has an M ordinate.
Definition: gserialized.c:185
int gserialized_has_z(const GSERIALIZED *g)
Check if a GSERIALIZED has a Z ordinate.
Definition: gserialized.c:174
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: gserialized.c:89
#define COLLECTIONTYPE
Definition: liblwgeom.h:108
#define COMPOUNDTYPE
Definition: liblwgeom.h:110
#define CURVEPOLYTYPE
Definition: liblwgeom.h:111
#define MULTILINETYPE
Definition: liblwgeom.h:106
#define MULTISURFACETYPE
Definition: liblwgeom.h:113
#define LINETYPE
Definition: liblwgeom.h:103
#define MULTIPOINTTYPE
Definition: liblwgeom.h:105
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:102
#define TINTYPE
Definition: liblwgeom.h:116
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:107
#define POLYGONTYPE
Definition: liblwgeom.h:104
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:114
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:109
#define MULTICURVETYPE
Definition: liblwgeom.h:112
#define TRIANGLETYPE
Definition: liblwgeom.h:115
type
Definition: ovdump.py:42

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

Here is the call graph for this function: