PostGIS  2.1.10dev-r@@SVN_REVISION@@
static POINTARRAY* ptarray_locate_along ( const POINTARRAY pa,
double  m,
double  offset 
)
static

Definition at line 58 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().

59 {
60  int i;
61  POINT4D p1, p2, pn;
62  POINTARRAY *dpa = NULL;
63 
64  /* Can't do anything with degenerate point arrays */
65  if ( ! pa || pa->npoints < 2 ) return NULL;
66 
67  /* Walk through each segment in the point array */
68  for ( i = 1; i < pa->npoints; i++ )
69  {
70  getPoint4d_p(pa, i-1, &p1);
71  getPoint4d_p(pa, i, &p2);
72 
73  /* No derived point? Move to next segment. */
74  if ( segment_locate_along(&p1, &p2, m, offset, &pn) == LW_FALSE )
75  continue;
76 
77  /* No pointarray, make a fresh one */
78  if ( dpa == NULL )
80 
81  /* Add our new point to the array */
82  ptarray_append_point(dpa, &pn, 0);
83  }
84 
85  return dpa;
86 }
int npoints
Definition: liblwgeom.h:327
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:57
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:141
#define LW_FALSE
Definition: liblwgeom.h:52
int ptarray_has_m(const POINTARRAY *pa)
Definition: ptarray.c:30
int ptarray_has_z(const POINTARRAY *pa)
Definition: ptarray.c:23
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: