PostGIS  2.5.0dev-r@@SVN_REVISION@@
POINTARRAY* ptarray_from_GEOSCoordSeq ( const GEOSCoordSequence *  cs,
char  want3d 
)

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

References LWDEBUG, LWDEBUGF, lwerror(), ptarray_construct(), ptarray_set_point4d(), POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by GEOS2LWGEOM(), and lwtin_from_geos().

70 {
71  uint32_t dims=2;
72  uint32_t size, i;
73  POINTARRAY *pa;
74  POINT4D point;
75 
76  LWDEBUG(2, "ptarray_fromGEOSCoordSeq called");
77 
78  if ( ! GEOSCoordSeq_getSize(cs, &size) )
79  lwerror("Exception thrown");
80 
81  LWDEBUGF(4, " GEOSCoordSeq size: %d", size);
82 
83  if ( want3d )
84  {
85  if ( ! GEOSCoordSeq_getDimensions(cs, &dims) )
86  lwerror("Exception thrown");
87 
88  LWDEBUGF(4, " GEOSCoordSeq dimensions: %d", dims);
89 
90  /* forget higher dimensions (if any) */
91  if ( dims > 3 ) dims = 3;
92  }
93 
94  LWDEBUGF(4, " output dimensions: %d", dims);
95 
96  pa = ptarray_construct((dims==3), 0, size);
97 
98  for (i=0; i<size; i++)
99  {
100  GEOSCoordSeq_getX(cs, i, &(point.x));
101  GEOSCoordSeq_getY(cs, i, &(point.y));
102  if ( dims >= 3 ) GEOSCoordSeq_getZ(cs, i, &(point.z));
103  ptarray_set_point4d(pa,i,&point);
104  }
105 
106  return pa;
107 }
double x
Definition: liblwgeom.h:351
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
Definition: ptarray.c:62
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
Definition: lwgeom_api.c:425
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
unsigned int uint32_t
Definition: uthash.h:78
double z
Definition: liblwgeom.h:351
double y
Definition: liblwgeom.h:351
#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:190

Here is the call graph for this function:

Here is the caller graph for this function: