PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ lwgeom_reverse_in_place()

void lwgeom_reverse_in_place ( LWGEOM geom)

Reverse vertex order of LWGEOM.

Definition at line 103 of file lwgeom.c.

104 {
105  uint32_t i;
106  LWCOLLECTION *col;
107  if (!geom)
108  return;
109 
110  switch (geom->type)
111  {
112  case MULTIPOINTTYPE:
113  case POINTTYPE:
114  {
115  return;
116  }
117  case TRIANGLETYPE:
118  case CIRCSTRINGTYPE:
119  case LINETYPE:
120  {
121  LWLINE *line = (LWLINE *)(geom);
123  return;
124  }
125  case POLYGONTYPE:
126  {
127  LWPOLY *poly = (LWPOLY *)(geom);
128  if (!poly->rings)
129  return;
130  uint32_t r;
131  for (r = 0; r < poly->nrings; r++)
133  return;
134  }
135  /* CompoundCurve needs to also reverse the sub-geometries */
136  /* so that the end-points remain coincident */
137  case COMPOUNDTYPE:
138  {
139  uint32_t ngeoms;
140  col = (LWCOLLECTION *)(geom);
141  if (!col->geoms)
142  return;
143  ngeoms = col->ngeoms;
144  for (i=0; i<ngeoms; i++)
146  for (i=0; i<col->ngeoms/2; i++) {
147  LWGEOM* tmp = col->geoms[i];
148  col->geoms[i] = col->geoms[ngeoms-i-1];
149  col->geoms[ngeoms-i-1] = tmp;
150  }
151  return;
152  }
153  case MULTICURVETYPE:
154  case MULTILINETYPE:
155  case MULTIPOLYGONTYPE:
156  case MULTISURFACETYPE:
158  case TINTYPE:
159  case COLLECTIONTYPE:
160  case CURVEPOLYTYPE:
161  {
162  col = (LWCOLLECTION *)(geom);
163  if (!col->geoms)
164  return;
165  for (i=0; i<col->ngeoms; i++)
167  return;
168  }
169  default:
170  {
171  lwerror("%s: Unknown geometry type: %s", __func__, lwtype_name(geom->type));
172  return;
173  }
174 
175  }
176 }
char * r
Definition: cu_in_wkt.c:24
#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
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
#define MULTICURVETYPE
Definition: liblwgeom.h:112
#define TRIANGLETYPE
Definition: liblwgeom.h:115
void ptarray_reverse_in_place(POINTARRAY *pa)
Definition: ptarray.c:331
void lwgeom_reverse_in_place(LWGEOM *geom)
Reverse vertex order of LWGEOM.
Definition: lwgeom.c:103
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
uint32_t ngeoms
Definition: liblwgeom.h:580
LWGEOM ** geoms
Definition: liblwgeom.h:575
uint8_t type
Definition: liblwgeom.h:462
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(), ST_IsPolygonCCW(), and test_lwcurve_linearize().

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