PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwline_locate_along()

static LWMPOINT* lwline_locate_along ( const LWLINE lwline,
double  m,
double  offset 
)
static

Definition at line 110 of file lwlinearreferencing.c.

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

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().

Here is the call graph for this function:
Here is the caller graph for this function: