PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ ptarray_force_dims()

POINTARRAY* ptarray_force_dims ( const POINTARRAY pa,
int  hasz,
int  hasm 

Definition at line 1035 of file ptarray.c.

References POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, getPoint4d_p(), LW_TRUE, POINT4D::m, POINTARRAY::npoints, ptarray_append_point(), ptarray_construct_empty(), and POINT4D::z.

Referenced by lwline_force_dims(), lwpoint_force_dims(), and lwpoly_force_dims().

1036 {
1037  /* TODO handle zero-length point arrays */
1038  int i;
1039  int in_hasz = FLAGS_GET_Z(pa->flags);
1040  int in_hasm = FLAGS_GET_M(pa->flags);
1041  POINT4D pt;
1042  POINTARRAY *pa_out = ptarray_construct_empty(hasz, hasm, pa->npoints);
1044  for( i = 0; i < pa->npoints; i++ )
1045  {
1046  getPoint4d_p(pa, i, &pt);
1047  if( hasz && ! in_hasz )
1048  pt.z = 0.0;
1049  if( hasm && ! in_hasm )
1050  pt.m = 0.0;
1051  ptarray_append_point(pa_out, &pt, LW_TRUE);
1052  }
1054  return pa_out;
1055 }
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
uint8_t flags
Definition: liblwgeom.h:353
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
#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
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: