PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ ptarray_to_GEOSCoordSeq()

GEOSCoordSeq ptarray_to_GEOSCoordSeq ( const POINTARRAY pa)

Definition at line 216 of file liblwgeom/lwgeom_geos.c.

References POINTARRAY::flags, FLAGS_GET_Z, getPoint2d_cp(), getPoint3dz_cp(), LWDEBUGF, lwerror(), POINTARRAY::npoints, POINT2D::x, POINT3DZ::x, POINT2D::y, POINT3DZ::y, and POINT3DZ::z.

Referenced by GEOS2LWGEOM(), LWGEOM2GEOS(), and ptarray_to_GEOSLinearRing().

217 {
218  uint32_t dims = 2;
219  uint32_t i;
220  const POINT3DZ *p3d;
221  const POINT2D *p2d;
222  GEOSCoordSeq sq;
223 
224  if ( FLAGS_GET_Z(pa->flags) )
225  dims = 3;
226 
227  if ( ! (sq = GEOSCoordSeq_create(pa->npoints, dims)) )
228  lwerror("Error creating GEOS Coordinate Sequence");
229 
230  for ( i=0; i < pa->npoints; i++ )
231  {
232  if ( dims == 3 )
233  {
234  p3d = getPoint3dz_cp(pa, i);
235  p2d = (const POINT2D *)p3d;
236  LWDEBUGF(4, "Point: %g,%g,%g", p3d->x, p3d->y, p3d->z);
237  }
238  else
239  {
240  p2d = getPoint2d_cp(pa, i);
241  LWDEBUGF(4, "Point: %g,%g", p2d->x, p2d->y);
242  }
243 
244  GEOSCoordSeq_setX(sq, i, p2d->x);
245  GEOSCoordSeq_setY(sq, i, p2d->y);
246 
247  if ( dims == 3 )
248  GEOSCoordSeq_setZ(sq, i, p3d->z);
249  }
250  return sq;
251 }
double z
Definition: liblwgeom.h:333
double y
Definition: liblwgeom.h:333
double x
Definition: liblwgeom.h:333
int npoints
Definition: liblwgeom.h:370
double x
Definition: liblwgeom.h:327
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, int n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
Definition: lwgeom_api.c:485
uint8_t flags
Definition: liblwgeom.h:368
double y
Definition: liblwgeom.h:327
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:139
const POINT3DZ * getPoint3dz_cp(const POINTARRAY *pa, int n)
Returns a POINT3DZ pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
Definition: lwgeom_api.c:499
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102
Here is the call graph for this function:
Here is the caller graph for this function: