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

◆ lwgeom_reverse_in_place()

void lwgeom_reverse_in_place ( LWGEOM lwgeom)
extern

Reverse vertex order of LWGEOM.

Definition at line 131 of file lwgeom.c.

132{
133 uint32_t i;
134 LWCOLLECTION *col;
135 if (!geom)
136 return;
137
138 switch (geom->type)
139 {
140 case MULTIPOINTTYPE:
141 case POINTTYPE:
142 {
143 return;
144 }
145 case TRIANGLETYPE:
146 case CIRCSTRINGTYPE:
147 case LINETYPE:
148 {
149 LWLINE *line = (LWLINE *)(geom);
151 return;
152 }
153 case POLYGONTYPE:
154 {
155 LWPOLY *poly = (LWPOLY *)(geom);
156 if (!poly->rings)
157 return;
158 uint32_t r;
159 for (r = 0; r < poly->nrings; r++)
161 return;
162 }
163 /* CompoundCurve needs to also reverse the sub-geometries */
164 /* so that the end-points remain coincident */
165 case COMPOUNDTYPE:
166 {
167 uint32_t ngeoms;
168 col = (LWCOLLECTION *)(geom);
169 if (!col->geoms)
170 return;
171 ngeoms = col->ngeoms;
172 for (i=0; i<ngeoms; i++)
174 for (i=0; i<col->ngeoms/2; i++) {
175 LWGEOM* tmp = col->geoms[i];
176 col->geoms[i] = col->geoms[ngeoms-i-1];
177 col->geoms[ngeoms-i-1] = tmp;
178 }
179 return;
180 }
181 case MULTICURVETYPE:
182 case MULTILINETYPE:
183 case MULTIPOLYGONTYPE:
184 case MULTISURFACETYPE:
186 case TINTYPE:
187 case COLLECTIONTYPE:
188 case CURVEPOLYTYPE:
189 {
190 col = (LWCOLLECTION *)(geom);
191 if (!col->geoms)
192 return;
193 for (i=0; i<col->ngeoms; i++)
195 return;
196 }
197 default:
198 {
199 lwerror("%s: Unknown geometry type: %s", __func__, lwtype_name(geom->type));
200 return;
201 }
202
203 }
204}
char * r
Definition cu_in_wkt.c:24
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition lwutil.c:216
#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
void ptarray_reverse_in_place(POINTARRAY *pa)
Definition ptarray.c:339
void lwgeom_reverse_in_place(LWGEOM *geom)
Reverse vertex order of LWGEOM.
Definition lwgeom.c:131
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
uint32_t ngeoms
Definition liblwgeom.h:580
LWGEOM ** geoms
Definition liblwgeom.h:575
POINTARRAY * points
Definition liblwgeom.h:483
POINTARRAY ** rings
Definition liblwgeom.h:519
uint32_t nrings
Definition liblwgeom.h:524

References CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, LWCOLLECTION::geoms, LINETYPE, lwerror(), lwgeom_reverse_in_place(), lwtype_name(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, LWCOLLECTION::ngeoms, LWPOLY::nrings, LWLINE::points, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, ptarray_reverse_in_place(), r, LWPOLY::rings, TINTYPE, TRIANGLETYPE, and LWGEOM::type.

Referenced by lwgeom_reverse(), LWGEOM_reverse(), lwgeom_reverse_in_place(), lwt_GetFaceEdges(), and test_lwcurve_linearize().

Here is the call graph for this function:
Here is the caller graph for this function: