PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ptarray_append_point()

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_FALSE, then a duplicate point will not be added.

Definition at line 156 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 _lwt_EdgeMotionArea(), BOX2D_to_LWGEOM(), BOX3D_to_LWGEOM(), encode_mpoint(), gbox_to_gml2(), gbox_to_gml3(), GenerateLineStringGeometry(), GeneratePointGeometry(), GeneratePolygonGeometry(), lwarc_linearize(), lwcircstring_get_lwpoint(), lwcircstring_linearize(), lwcompound_linearize(), LWGEOM_envelope(), lwgeom_from_encoded_polyline(), lwline_clip_to_ordinate_range(), lwline_from_lwgeom_array(), lwline_from_ptarray(), lwline_get_lwpoint(), lwline_simplify(), lwline_split_by_point_to(), lwpoint_make(), lwpoint_make2d(), lwpoint_make3dm(), lwpoint_make3dz(), lwpoint_make4d(), lwpoly_construct_circle(), lwpoly_construct_rectangle(), lwpoly_from_twkb_state(), parse_geojson_coord(), parse_gml_coord(), parse_gml_coordinates(), parse_gml_pos(), parse_gml_poslist(), parse_kml_coordinates(), parse_kml_polygon(), path_to_geometry(), polygon_to_geometry(), ptarray_force_dims(), ptarray_grid(), ptarray_locate_along(), ptarray_locate_between_m(), ptarray_segmentize2d(), ptarray_segmentize_sphere(), ptarray_segmentize_sphere_edge_recursive(), ptarray_set_effective_area(), ptarray_simplify(), ptarray_substring(), rt_raster_get_convex_hull(), rt_raster_get_envelope_geom(), RTreeCreateLeafNode(), ST_BoundingDiagonal(), test_ptarray_append_point(), and wkt_parser_ptarray_add_coord().

157 {
158 
159  /* Check for pathology */
160  if( ! pa || ! pt )
161  {
162  lwerror("ptarray_append_point: null input");
163  return LW_FAILURE;
164  }
165 
166  /* Check for duplicate end point */
167  if ( repeated_points == LW_FALSE && pa->npoints > 0 )
168  {
169  POINT4D tmp;
170  getPoint4d_p(pa, pa->npoints-1, &tmp);
171  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);
172 
173  /* Return LW_SUCCESS and do nothing else if previous point in list is equal to this one */
174  if ( (pt->x == tmp.x) && (pt->y == tmp.y) &&
175  (FLAGS_GET_Z(pa->flags) ? pt->z == tmp.z : 1) &&
176  (FLAGS_GET_M(pa->flags) ? pt->m == tmp.m : 1) )
177  {
178  return LW_SUCCESS;
179  }
180  }
181 
182  /* Append is just a special case of insert */
183  return ptarray_insert_point(pa, pt, pa->npoints);
184 }
double x
Definition: liblwgeom.h:352
double m
Definition: liblwgeom.h:352
int npoints
Definition: liblwgeom.h:371
#define LW_SUCCESS
Definition: liblwgeom.h:80
#define LW_FAILURE
Definition: liblwgeom.h:79
#define LW_FALSE
Definition: liblwgeom.h:77
uint8_t flags
Definition: liblwgeom.h:369
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, int where)
Insert a point into an existing POINTARRAY.
Definition: ptarray.c:96
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
double z
Definition: liblwgeom.h:352
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
double y
Definition: liblwgeom.h:352
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:122
Here is the call graph for this function: