PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum LWGEOM_getTYPE ( PG_FUNCTION_ARGS  )

Definition at line 108 of file lwgeom_ogc.c.

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, result, TINTYPE, and TRIANGLETYPE.

109 {
110  GSERIALIZED *gser;
111  text *text_ob;
112  char *result;
113  uint8_t type;
114  static int maxtyplen = 20;
115 
116  gser = (GSERIALIZED*)PG_DETOAST_DATUM_SLICE(PG_GETARG_DATUM(0), 0, gserialized_max_header_size());
117  text_ob = palloc0(VARHDRSZ + maxtyplen);
118  result = VARDATA(text_ob);
119 
120  type = gserialized_get_type(gser);
121 
122  if (type == POINTTYPE)
123  strcpy(result,"POINT");
124  else if (type == MULTIPOINTTYPE)
125  strcpy(result,"MULTIPOINT");
126  else if (type == LINETYPE)
127  strcpy(result,"LINESTRING");
128  else if (type == CIRCSTRINGTYPE)
129  strcpy(result,"CIRCULARSTRING");
130  else if (type == COMPOUNDTYPE)
131  strcpy(result, "COMPOUNDCURVE");
132  else if (type == MULTILINETYPE)
133  strcpy(result,"MULTILINESTRING");
134  else if (type == MULTICURVETYPE)
135  strcpy(result, "MULTICURVE");
136  else if (type == POLYGONTYPE)
137  strcpy(result,"POLYGON");
138  else if (type == TRIANGLETYPE)
139  strcpy(result,"TRIANGLE");
140  else if (type == CURVEPOLYTYPE)
141  strcpy(result,"CURVEPOLYGON");
142  else if (type == MULTIPOLYGONTYPE)
143  strcpy(result,"MULTIPOLYGON");
144  else if (type == MULTISURFACETYPE)
145  strcpy(result, "MULTISURFACE");
146  else if (type == COLLECTIONTYPE)
147  strcpy(result,"GEOMETRYCOLLECTION");
148  else if (type == POLYHEDRALSURFACETYPE)
149  strcpy(result,"POLYHEDRALSURFACE");
150  else if (type == TINTYPE)
151  strcpy(result,"TIN");
152  else
153  strcpy(result,"UNKNOWN");
154 
155  if ( gserialized_has_m(gser) && ! gserialized_has_z(gser) )
156  strcat(result, "M");
157 
158  SET_VARSIZE(text_ob, strlen(result) + VARHDRSZ); /* size of string */
159 
160  PG_FREE_IF_COPY(gser, 0);
161 
162  PG_RETURN_TEXT_P(text_ob);
163 }
#define LINETYPE
Definition: liblwgeom.h:61
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:56
#define MULTICURVETYPE
Definition: liblwgeom.h:70
int gserialized_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
Definition: g_serialized.c:30
#define POLYGONTYPE
Definition: liblwgeom.h:62
#define CURVEPOLYTYPE
Definition: liblwgeom.h:69
#define COMPOUNDTYPE
Definition: liblwgeom.h:68
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
#define TRIANGLETYPE
Definition: liblwgeom.h:73
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:72
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:25
char ** result
Definition: liblwgeom.h:218
#define TINTYPE
Definition: liblwgeom.h:74
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
#define MULTISURFACETYPE
Definition: liblwgeom.h:71
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
#define MULTILINETYPE
Definition: liblwgeom.h:64
#define COLLECTIONTYPE
Definition: liblwgeom.h:66
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:50

Here is the call graph for this function: