PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ ptarray_locate_along()

static POINTARRAY* ptarray_locate_along ( const POINTARRAY pa,
double  m,
double  offset 
)
static

Definition at line 66 of file lwlinearreferencing.c.

References getPoint4d_p(), LW_FALSE, POINTARRAY::npoints, ptarray_append_point(), ptarray_construct_empty(), ptarray_has_m(), ptarray_has_z(), and segment_locate_along().

Referenced by lwline_locate_along().

67 {
68  int i;
69  POINT4D p1, p2, pn;
70  POINTARRAY *dpa = NULL;
71 
72  /* Can't do anything with degenerate point arrays */
73  if ( ! pa || pa->npoints < 2 ) return NULL;
74 
75  /* Walk through each segment in the point array */
76  for ( i = 1; i < pa->npoints; i++ )
77  {
78  getPoint4d_p(pa, i-1, &p1);
79  getPoint4d_p(pa, i, &p2);
80 
81  /* No derived point? Move to next segment. */
82  if ( segment_locate_along(&p1, &p2, m, offset, &pn) == LW_FALSE )
83  continue;
84 
85  /* No pointarray, make a fresh one */
86  if ( dpa == NULL )
88 
89  /* Add our new point to the array */
90  ptarray_append_point(dpa, &pn, 0);
91  }
92 
93  return dpa;
94 }
int npoints
Definition: liblwgeom.h:355
static int segment_locate_along(const POINT4D *p1, const POINT4D *p2, double m, double offset, POINT4D *pn)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
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: ptarray.c:156
#define LW_FALSE
Definition: liblwgeom.h:62
int ptarray_has_m(const POINTARRAY *pa)
Definition: ptarray.c:43
int ptarray_has_z(const POINTARRAY *pa)
Definition: ptarray.c:36
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: