PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ LWGEOM_getTYPE()

Datum LWGEOM_getTYPE ( PG_FUNCTION_ARGS  )

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

103 {
104  GSERIALIZED *gser;
105  text *text_ob;
106  char *result;
107  uint8_t type;
108  static int maxtyplen = 20;
109 
110  gser = PG_GETARG_GSERIALIZED_P_SLICE(0, 0, gserialized_max_header_size());
111  text_ob = palloc0(VARHDRSZ + maxtyplen);
112  result = VARDATA(text_ob);
113 
114  type = gserialized_get_type(gser);
115 
116  if (type == POINTTYPE)
117  strcpy(result,"POINT");
118  else if (type == MULTIPOINTTYPE)
119  strcpy(result,"MULTIPOINT");
120  else if (type == LINETYPE)
121  strcpy(result,"LINESTRING");
122  else if (type == CIRCSTRINGTYPE)
123  strcpy(result,"CIRCULARSTRING");
124  else if (type == COMPOUNDTYPE)
125  strcpy(result, "COMPOUNDCURVE");
126  else if (type == MULTILINETYPE)
127  strcpy(result,"MULTILINESTRING");
128  else if (type == MULTICURVETYPE)
129  strcpy(result, "MULTICURVE");
130  else if (type == POLYGONTYPE)
131  strcpy(result,"POLYGON");
132  else if (type == TRIANGLETYPE)
133  strcpy(result,"TRIANGLE");
134  else if (type == CURVEPOLYTYPE)
135  strcpy(result,"CURVEPOLYGON");
136  else if (type == MULTIPOLYGONTYPE)
137  strcpy(result,"MULTIPOLYGON");
138  else if (type == MULTISURFACETYPE)
139  strcpy(result, "MULTISURFACE");
140  else if (type == COLLECTIONTYPE)
141  strcpy(result,"GEOMETRYCOLLECTION");
142  else if (type == POLYHEDRALSURFACETYPE)
143  strcpy(result,"POLYHEDRALSURFACE");
144  else if (type == TINTYPE)
145  strcpy(result,"TIN");
146  else
147  strcpy(result,"UNKNOWN");
148 
149  if ( gserialized_has_m(gser) && ! gserialized_has_z(gser) )
150  strcat(result, "M");
151 
152  SET_VARSIZE(text_ob, strlen(result) + VARHDRSZ); /* size of string */
153 
154  PG_FREE_IF_COPY(gser, 0);
155 
156  PG_RETURN_TEXT_P(text_ob);
157 }
#define LINETYPE
Definition: liblwgeom.h:71
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:55
#define MULTICURVETYPE
Definition: liblwgeom.h:80
int gserialized_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
Definition: g_serialized.c:29
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define CURVEPOLYTYPE
Definition: liblwgeom.h:79
#define COMPOUNDTYPE
Definition: liblwgeom.h:78
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
#define TRIANGLETYPE
Definition: liblwgeom.h:83
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:82
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:24
#define TINTYPE
Definition: liblwgeom.h:84
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
#define MULTISURFACETYPE
Definition: liblwgeom.h:81
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
type
Definition: ovdump.py:41
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77
#define MULTILINETYPE
Definition: liblwgeom.h:74
#define COLLECTIONTYPE
Definition: liblwgeom.h:76
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:49
Here is the call graph for this function:
Here is the caller graph for this function: