PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ ptarray_grid()

POINTARRAY* ptarray_grid ( const POINTARRAY pa,
const gridspec grid 
)

Definition at line 1843 of file ptarray.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, LWDEBUGF, 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 lwcircstring_grid(), lwline_grid(), lwpoint_grid(), and lwpoly_grid().

1844 {
1845  POINT4D pt;
1846  int ipn; /* input point numbers */
1847  POINTARRAY *dpa;
1848 
1849  LWDEBUGF(2, "ptarray_grid called on %p", pa);
1850 
1852 
1853  for (ipn=0; ipn<pa->npoints; ++ipn)
1854  {
1855 
1856  getPoint4d_p(pa, ipn, &pt);
1857 
1858  if ( grid->xsize )
1859  pt.x = rint((pt.x - grid->ipx)/grid->xsize) *
1860  grid->xsize + grid->ipx;
1861 
1862  if ( grid->ysize )
1863  pt.y = rint((pt.y - grid->ipy)/grid->ysize) *
1864  grid->ysize + grid->ipy;
1865 
1866  if ( FLAGS_GET_Z(pa->flags) && grid->zsize )
1867  pt.z = rint((pt.z - grid->ipz)/grid->zsize) *
1868  grid->zsize + grid->ipz;
1869 
1870  if ( FLAGS_GET_M(pa->flags) && grid->msize )
1871  pt.m = rint((pt.m - grid->ipm)/grid->msize) *
1872  grid->msize + grid->ipm;
1873 
1874  ptarray_append_point(dpa, &pt, LW_FALSE);
1875 
1876  }
1877 
1878  return dpa;
1879 }
double x
Definition: liblwgeom.h:336
double m
Definition: liblwgeom.h:336
int npoints
Definition: liblwgeom.h:355
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int repeated_points)
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:156
#define LW_FALSE
Definition: liblwgeom.h:62
uint8_t flags
Definition: liblwgeom.h:353
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:124
double z
Definition: liblwgeom.h:336
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
double y
Definition: liblwgeom.h:336
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:231
Here is the call graph for this function:
Here is the caller graph for this function: