PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ptarray_grid()

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

Definition at line 1890 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().

1891 {
1892  POINT4D pt;
1893  int ipn; /* input point numbers */
1894  POINTARRAY *dpa;
1895 
1896  LWDEBUGF(2, "ptarray_grid called on %p", pa);
1897 
1899 
1900  for (ipn=0; ipn<pa->npoints; ++ipn)
1901  {
1902 
1903  getPoint4d_p(pa, ipn, &pt);
1904 
1905  if ( grid->xsize )
1906  pt.x = rint((pt.x - grid->ipx)/grid->xsize) *
1907  grid->xsize + grid->ipx;
1908 
1909  if ( grid->ysize )
1910  pt.y = rint((pt.y - grid->ipy)/grid->ysize) *
1911  grid->ysize + grid->ipy;
1912 
1913  if ( FLAGS_GET_Z(pa->flags) && grid->zsize )
1914  pt.z = rint((pt.z - grid->ipz)/grid->zsize) *
1915  grid->zsize + grid->ipz;
1916 
1917  if ( FLAGS_GET_M(pa->flags) && grid->msize )
1918  pt.m = rint((pt.m - grid->ipm)/grid->msize) *
1919  grid->msize + grid->ipm;
1920 
1921  ptarray_append_point(dpa, &pt, LW_FALSE);
1922 
1923  }
1924 
1925  return dpa;
1926 }
double x
Definition: liblwgeom.h:352
double m
Definition: liblwgeom.h:352
int npoints
Definition: liblwgeom.h:371
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_FALSE, then a duplicate point will not be added.
Definition: ptarray.c:156
#define LW_FALSE
Definition: liblwgeom.h:77
uint8_t flags
Definition: liblwgeom.h:369
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:140
double z
Definition: liblwgeom.h:352
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:141
double y
Definition: liblwgeom.h:352
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:122
Here is the call graph for this function:
Here is the caller graph for this function: