PostGIS  3.0.6dev-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)
119  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 }
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:321
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
Definition: lwgeom.c:909
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:916
LWMPOINT * lwmpoint_construct_empty(int32_t srid, char hasz, char hasm)
Definition: lwmpoint.c:39
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:319
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:379
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:923
LWMPOINT * lwmpoint_construct(int32_t srid, const POINTARRAY *pa)
Definition: lwmpoint.c:52
void lwline_free(LWLINE *line)
Definition: lwline.c:67
static POINTARRAY * ptarray_locate_along(const POINTARRAY *pa, double m, double offset)
POINTARRAY * points
Definition: liblwgeom.h:469

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: