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

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

112 {
113  POINTARRAY *opa = NULL;
114  LWMPOINT *mp = NULL;
115  LWGEOM *lwg = lwline_as_lwgeom(lwline);
116  int hasz, hasm, srid;
117 
118  /* Return degenerates upwards */
119  if ( ! lwline ) return NULL;
120 
121  /* Create empty return shell */
122  srid = lwgeom_get_srid(lwg);
123  hasz = lwgeom_has_z(lwg);
124  hasm = lwgeom_has_m(lwg);
125 
126  if ( hasm )
127  {
128  /* Find points along */
129  opa = ptarray_locate_along(lwline->points, m, offset);
130  }
131  else
132  {
133  LWLINE *lwline_measured = lwline_measured_from_lwline(lwline, 0.0, 1.0);
134  opa = ptarray_locate_along(lwline_measured->points, m, offset);
135  lwline_free(lwline_measured);
136  }
137 
138  /* Return NULL as EMPTY */
139  if ( ! opa )
140  return lwmpoint_construct_empty(srid, hasz, hasm);
141 
142  /* Convert pointarray into a multipoint */
143  mp = lwmpoint_construct(srid, opa);
144  ptarray_free(opa);
145  return mp;
146 }
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:396
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:330
LWMPOINT * lwmpoint_construct(int srid, const POINTARRAY *pa)
Definition: lwmpoint.c:52
void lwline_free(LWLINE *line)
Definition: lwline.c:76
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
Definition: lwgeom.c:835
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:849
static POINTARRAY * ptarray_locate_along(const POINTARRAY *pa, double m, double offset)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:262
LWMPOINT * lwmpoint_construct_empty(int srid, char hasz, char hasm)
Definition: lwmpoint.c:39
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:856
POINTARRAY * points
Definition: liblwgeom.h:421

Here is the call graph for this function:

Here is the caller graph for this function: