PostGIS  2.2.7dev-r@@SVN_REVISION@@
static LWMPOINT* lwline_locate_along ( const LWLINE lwline,
double  m,
double  offset 
)
static

Definition at line 97 of file lwlinearreferencing.c.

References lwgeom_get_srid(), lwgeom_has_m(), lwgeom_has_z(), lwline_as_lwgeom(), lwline_free(), lwline_measured_from_lwline(), lwmpoint_construct(), lwmpoint_construct_empty(), LWLINE::points, ptarray_free(), and ptarray_locate_along().

Referenced by lwgeom_locate_along(), and lwmline_locate_along().

98 {
99  POINTARRAY *opa = NULL;
100  LWMPOINT *mp = NULL;
101  LWGEOM *lwg = lwline_as_lwgeom(lwline);
102  int hasz, hasm, srid;
103 
104  /* Return degenerates upwards */
105  if ( ! lwline ) return NULL;
106 
107  /* Create empty return shell */
108  srid = lwgeom_get_srid(lwg);
109  hasz = lwgeom_has_z(lwg);
110  hasm = lwgeom_has_m(lwg);
111 
112  if ( hasm )
113  {
114  /* Find points along */
115  opa = ptarray_locate_along(lwline->points, m, offset);
116  }
117  else
118  {
119  LWLINE *lwline_measured = lwline_measured_from_lwline(lwline, 0.0, 1.0);
120  opa = ptarray_locate_along(lwline_measured->points, m, offset);
121  lwline_free(lwline_measured);
122  }
123 
124  /* Return NULL as EMPTY */
125  if ( ! opa )
126  return lwmpoint_construct_empty(srid, hasz, hasm);
127 
128  /* Convert pointarray into a multipoint */
129  mp = lwmpoint_construct(srid, opa);
130  ptarray_free(opa);
131  return mp;
132 }
LWLINE * lwline_measured_from_lwline(const LWLINE *lwline, double m_start, double m_end)
Add a measure dimension to a line, interpolating linearly from the start to the end value...
Definition: lwline.c:367
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:330
LWMPOINT * lwmpoint_construct(int srid, const POINTARRAY *pa)
Definition: lwmpoint.c:39
void lwline_free(LWLINE *line)
Definition: lwline.c:63
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
Definition: lwgeom.c:822
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:836
static POINTARRAY * ptarray_locate_along(const POINTARRAY *pa, double m, double offset)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:249
LWMPOINT * lwmpoint_construct_empty(int srid, char hasz, char hasm)
Definition: lwmpoint.c:26
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:843
POINTARRAY * points
Definition: liblwgeom.h:406

Here is the call graph for this function:

Here is the caller graph for this function: