PostGIS  2.1.10dev-r@@SVN_REVISION@@
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 at line 141 of file ptarray.c.

References POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, getPoint4d_p(), LW_FAILURE, LW_FALSE, LW_SUCCESS, LWDEBUGF, lwerror(), POINT4D::m, POINTARRAY::npoints, ptarray_insert_point(), POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by BOX2D_to_LWGEOM(), BOX3D_to_LWGEOM(), gbox_to_gml2(), gbox_to_gml3(), GenerateLineStringGeometry(), GeneratePointGeometry(), GeneratePolygonGeometry(), lwcircle_segmentize(), lwcircstring_get_lwpoint(), lwcircstring_segmentize(), lwcompound_segmentize(), LWGEOM_envelope(), LWGEOM_expand(), lwline_clip_to_ordinate_range(), lwline_from_lwgeom_array(), lwline_from_ptarray(), lwline_get_lwpoint(), lwpoint_make(), lwpoint_make2d(), lwpoint_make3dm(), lwpoint_make3dz(), lwpoint_make4d(), parse_geojson_coord(), parse_gml_coord(), parse_gml_coordinates(), parse_gml_pos(), parse_gml_poslist(), parse_kml_coordinates(), path_to_geometry(), polygon_to_geometry(), ptarray_force_dims(), ptarray_grid(), ptarray_locate_along(), ptarray_locate_between_m(), ptarray_segmentize2d(), ptarray_segmentize_sphere(), ptarray_simplify(), ptarray_substring(), rt_raster_get_convex_hull(), RTreeCreateLeafNode(), ST_MakeEnvelope(), test_ptarray_append_point(), and wkt_parser_ptarray_add_coord().

142 {
143 
144  /* Check for pathology */
145  if( ! pa || ! pt )
146  {
147  lwerror("ptarray_append_point: null input");
148  return LW_FAILURE;
149  }
150 
151  /* Check for duplicate end point */
152  if ( repeated_points == LW_FALSE && pa->npoints > 0 )
153  {
154  POINT4D tmp;
155  getPoint4d_p(pa, pa->npoints-1, &tmp);
156  LWDEBUGF(4,"checking for duplicate end point (pt = POINT(%g %g) pa->npoints-q = POINT(%g %g))",pt->x,pt->y,tmp.x,tmp.y);
157 
158  /* Return LW_SUCCESS and do nothing else if previous point in list is equal to this one */
159  if ( (pt->x == tmp.x) && (pt->y == tmp.y) &&
160  (FLAGS_GET_Z(pa->flags) ? pt->z == tmp.z : 1) &&
161  (FLAGS_GET_M(pa->flags) ? pt->m == tmp.m : 1) )
162  {
163  return LW_SUCCESS;
164  }
165  }
166 
167  /* Append is just a special case of insert */
168  return ptarray_insert_point(pa, pt, pa->npoints);
169 }
double x
Definition: liblwgeom.h:308
double m
Definition: liblwgeom.h:308
int npoints
Definition: liblwgeom.h:327
#define LW_SUCCESS
Definition: liblwgeom.h:55
#define LW_FAILURE
Definition: liblwgeom.h:54
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
#define LW_FALSE
Definition: liblwgeom.h:52
uint8_t flags
Definition: liblwgeom.h:325
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, int where)
Insert a point into an existing POINTARRAY.
Definition: ptarray.c:84
#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
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
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: