PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ LWGEOM_getTYPE()

Datum LWGEOM_getTYPE ( PG_FUNCTION_ARGS  )

Definition at line 121 of file lwgeom_ogc.c.

122{
123 GSERIALIZED *gser;
124 text *text_ob;
125 char *result;
126 uint8_t type;
127 static int maxtyplen = 20;
128
129 gser = PG_GETARG_GSERIALIZED_HEADER(0);
130 text_ob = palloc0(VARHDRSZ + maxtyplen);
131 result = VARDATA(text_ob);
132
134
135 if (type == POINTTYPE)
136 strcpy(result,"POINT");
137 else if (type == MULTIPOINTTYPE)
138 strcpy(result,"MULTIPOINT");
139 else if (type == LINETYPE)
140 strcpy(result,"LINESTRING");
141 else if (type == CIRCSTRINGTYPE)
142 strcpy(result,"CIRCULARSTRING");
143 else if (type == COMPOUNDTYPE)
144 strcpy(result, "COMPOUNDCURVE");
145 else if (type == MULTILINETYPE)
146 strcpy(result,"MULTILINESTRING");
147 else if (type == MULTICURVETYPE)
148 strcpy(result, "MULTICURVE");
149 else if (type == POLYGONTYPE)
150 strcpy(result,"POLYGON");
151 else if (type == TRIANGLETYPE)
152 strcpy(result,"TRIANGLE");
153 else if (type == CURVEPOLYTYPE)
154 strcpy(result,"CURVEPOLYGON");
155 else if (type == MULTIPOLYGONTYPE)
156 strcpy(result,"MULTIPOLYGON");
157 else if (type == MULTISURFACETYPE)
158 strcpy(result, "MULTISURFACE");
159 else if (type == COLLECTIONTYPE)
160 strcpy(result,"GEOMETRYCOLLECTION");
161 else if (type == POLYHEDRALSURFACETYPE)
162 strcpy(result,"POLYHEDRALSURFACE");
163 else if (type == TINTYPE)
164 strcpy(result,"TIN");
165 else
166 strcpy(result,"UNKNOWN");
167
168 if ( gserialized_has_m(gser) && ! gserialized_has_z(gser) )
169 strcat(result, "M");
170
171 SET_VARSIZE(text_ob, strlen(result) + VARHDRSZ); /* size of string */
172
173 PG_FREE_IF_COPY(gser, 0);
174
175 PG_RETURN_TEXT_P(text_ob);
176}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
int gserialized_has_m(const GSERIALIZED *g)
Check if a GSERIALIZED has an M ordinate.
int gserialized_has_z(const GSERIALIZED *g)
Check if a GSERIALIZED has a Z ordinate.
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
#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

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

Here is the call graph for this function: