PostGIS  2.5.0beta1dev-r@@SVN_REVISION@@

◆ LWGEOM_getTYPE()

Datum LWGEOM_getTYPE ( PG_FUNCTION_ARGS  )

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

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 }
#define LINETYPE
Definition: liblwgeom.h:85
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:94
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:86
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define COMPOUNDTYPE
Definition: liblwgeom.h:92
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
#define TRIANGLETYPE
Definition: liblwgeom.h:97
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:96
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:98
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:89
#define MULTISURFACETYPE
Definition: liblwgeom.h:95
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
type
Definition: ovdump.py:41
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
#define MULTILINETYPE
Definition: liblwgeom.h:88
unsigned char uint8_t
Definition: uthash.h:79
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
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: