PostGIS  2.1.10dev-r@@SVN_REVISION@@
POINTARRAY * ptarray_grid ( POINTARRAY pa,
gridspec grid 
)

Definition at line 304 of file lwgeom_functions_analytic.c.

References POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, getPoint4d_p(), gridspec_t::ipm, gridspec_t::ipx, gridspec_t::ipy, gridspec_t::ipz, LW_FALSE, POINT4D::m, gridspec_t::msize, POINTARRAY::npoints, ptarray_append_point(), ptarray_construct_empty(), POINT4D::x, gridspec_t::xsize, POINT4D::y, gridspec_t::ysize, POINT4D::z, and gridspec_t::zsize.

Referenced by lwcirc_grid(), lwline_grid(), lwpoint_grid(), and lwpoly_grid().

305 {
306  POINT4D pbuf;
307  int ipn; /* input point numbers */
308  POINTARRAY *dpa;
309 
310  POSTGIS_DEBUGF(2, "ptarray_grid called on %p", pa);
311 
313 
314  for (ipn=0; ipn<pa->npoints; ++ipn)
315  {
316 
317  getPoint4d_p(pa, ipn, &pbuf);
318 
319  if ( grid->xsize )
320  pbuf.x = rint((pbuf.x - grid->ipx)/grid->xsize) *
321  grid->xsize + grid->ipx;
322 
323  if ( grid->ysize )
324  pbuf.y = rint((pbuf.y - grid->ipy)/grid->ysize) *
325  grid->ysize + grid->ipy;
326 
327  if ( FLAGS_GET_Z(pa->flags) && grid->zsize )
328  pbuf.z = rint((pbuf.z - grid->ipz)/grid->zsize) *
329  grid->zsize + grid->ipz;
330 
331  if ( FLAGS_GET_M(pa->flags) && grid->msize )
332  pbuf.m = rint((pbuf.m - grid->ipm)/grid->msize) *
333  grid->msize + grid->ipm;
334 
335  ptarray_append_point(dpa, &pbuf, LW_FALSE);
336 
337  }
338 
339  return dpa;
340 }
double x
Definition: liblwgeom.h:308
double m
Definition: liblwgeom.h:308
int npoints
Definition: liblwgeom.h:327
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:57
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_TRUE, then a duplicate point will not be added.
Definition: ptarray.c:141
#define LW_FALSE
Definition: liblwgeom.h:52
uint8_t flags
Definition: liblwgeom.h:325
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
double z
Definition: liblwgeom.h:308
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
double y
Definition: liblwgeom.h:308
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:217

Here is the call graph for this function:

Here is the caller graph for this function: