PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ ST_3DLineInterpolatePoint()

Datum ST_3DLineInterpolatePoint ( PG_FUNCTION_ARGS  )

Definition at line 234 of file lwgeom_functions_analytic.c.

235 {
236  GSERIALIZED *gser = PG_GETARG_GSERIALIZED_P(0);
237  GSERIALIZED *result;
238  double distance = PG_GETARG_FLOAT8(1);
239  LWLINE *line;
240  LWGEOM *geom;
241  LWPOINT *point;
242 
243  if (distance < 0 || distance > 1)
244  {
245  elog(ERROR, "line_interpolate_point: 2nd arg isn't within [0,1]");
246  PG_RETURN_NULL();
247  }
248 
249  if (gserialized_get_type(gser) != LINETYPE)
250  {
251  elog(ERROR, "line_interpolate_point: 1st arg isn't a line");
252  PG_RETURN_NULL();
253  }
254 
255  geom = lwgeom_from_gserialized(gser);
256  line = lwgeom_as_lwline(geom);
257 
258  point = lwline_interpolate_point_3d(line, distance);
259 
260  lwgeom_free(geom);
261  PG_FREE_IF_COPY(gser, 0);
262 
263  result = geometry_serialize(lwpoint_as_lwgeom(point));
264  lwpoint_free(point);
265 
266  PG_RETURN_POINTER(result);
267 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: gserialized.c:89
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:161
LWPOINT * lwline_interpolate_point_3d(const LWLINE *line, double distance)
Interpolate one point along a line in 3D.
Definition: lwline.c:602
void lwpoint_free(LWPOINT *pt)
Definition: lwpoint.c:213
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1138
#define LINETYPE
Definition: liblwgeom.h:117
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
Definition: lwgeom.c:326
static double distance(double x1, double y1, double x2, double y2)
Definition: lwtree.c:1032
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

References distance(), geometry_serialize(), gserialized_get_type(), LINETYPE, lwgeom_as_lwline(), lwgeom_free(), lwgeom_from_gserialized(), lwline_interpolate_point_3d(), lwpoint_as_lwgeom(), and lwpoint_free().

Here is the call graph for this function: