PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ ST_3DLineInterpolatePoint()

Datum ST_3DLineInterpolatePoint ( PG_FUNCTION_ARGS  )

Definition at line 228 of file lwgeom_functions_analytic.c.

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

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

Here is the call graph for this function: