PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ getPoint4d_p()

int getPoint4d_p ( const POINTARRAY pa,
int  n,
POINT4D point 
)

Definition at line 122 of file lwgeom_api.c.

References POINTARRAY::flags, FLAGS_GET_ZM, getPoint_internal(), LWDEBUG, LWDEBUGF, lwerror(), lwnotice(), POINT4D::m, NO_M_VALUE, NO_Z_VALUE, POINTARRAY::npoints, and POINT4D::z.

Referenced by _lwt_AddLineEdge(), _lwt_EdgeMotionArea(), analyze_pa(), circstring_from_pa(), encode_coords(), encode_mpoint(), getPoint4d(), linestring_from_pa(), lwarc_linearize(), lwcircstring_calculate_gbox_cartesian(), lwcircstring_linearize(), lwcompound_add_lwgeom(), lwcompound_linearize(), LWGEOM_dumppoints(), LWGEOM_line_interpolate_point(), LWGEOM_setpoint_linestring(), LWGEOM_snaptogrid_pointoff(), lwgeom_wrapx(), lwline_add_lwpoint(), lwline_clip_to_ordinate_range(), lwline_from_lwmpoint(), lwline_simplify(), lwline_split_by_point_to(), lwmpoint_construct(), lwpoint_get_m(), lwpoint_get_x(), lwpoint_get_y(), lwpoint_get_z(), lwpoint_getPoint4d_p(), lwpointiterator_peek(), lwpoly_from_twkb_state(), lwpoly_pt_outside_hack(), lwpsurface_is_closed(), lwt_AddPoint(), lwtin_is_closed(), parse_kml_polygon(), pointArray_toX3D3(), printPA(), pta_unstroke(), ptarray_affine(), ptarray_append_point(), ptarray_calculate_gbox_cartesian(), ptarray_collect_mvals(), ptarray_flip_coordinates(), ptarray_force_dims(), ptarray_force_geodetic(), ptarray_grid(), ptarray_length_spheroid(), ptarray_locate_along(), ptarray_locate_along_linear(), ptarray_locate_between_m(), ptarray_locate_point(), ptarray_nudge_geodetic(), ptarray_scale(), ptarray_segmentize2d(), ptarray_segmentize_sphere(), ptarray_simplify(), ptarray_startpoint(), ptarray_substring(), ptarray_swap_ordinates(), ptarray_to_kml2_sb(), ptarray_transform(), RTreeCreateLeafNode(), ST_Scale(), test_raster_convex_hull(), and test_raster_envelope_geom().

123 {
124  uint8_t *ptr;
125  int zmflag;
126 
127  if ( ! pa )
128  {
129  lwerror("%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
130  return 0;
131  }
132 
133  if ( (n<0) || (n>=pa->npoints))
134  {
135  lwnotice("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
136  return 0;
137  }
138 
139  LWDEBUG(4, "getPoint4d_p called.");
140 
141  /* Get a pointer to nth point offset and zmflag */
142  ptr=getPoint_internal(pa, n);
143  zmflag=FLAGS_GET_ZM(pa->flags);
144 
145  LWDEBUGF(4, "ptr %p, zmflag %d", ptr, zmflag);
146 
147  switch (zmflag)
148  {
149  case 0: /* 2d */
150  memcpy(op, ptr, sizeof(POINT2D));
151  op->m=NO_M_VALUE;
152  op->z=NO_Z_VALUE;
153  break;
154 
155  case 3: /* ZM */
156  memcpy(op, ptr, sizeof(POINT4D));
157  break;
158 
159  case 2: /* Z */
160  memcpy(op, ptr, sizeof(POINT3DZ));
161  op->m=NO_M_VALUE;
162  break;
163 
164  case 1: /* M */
165  memcpy(op, ptr, sizeof(POINT3DM));
166  op->m=op->z; /* we use Z as temporary storage */
167  op->z=NO_Z_VALUE;
168  break;
169 
170  default:
171  lwerror("Unknown ZM flag ??");
172  return 0;
173  }
174  return 1;
175 
176 }
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:177
int npoints
Definition: liblwgeom.h:371
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:153
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
uint8_t flags
Definition: liblwgeom.h:369
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1753
#define NO_Z_VALUE
#define NO_M_VALUE
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
unsigned char uint8_t
Definition: uthash.h:79
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: