PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ geometry_line_extend()

Datum geometry_line_extend ( PG_FUNCTION_ARGS  )

Definition at line 2655 of file lwgeom_functions_basic.c.

2656 {
2657  GSERIALIZED *geom1, *geom2;
2658  LWLINE *lwline1, *lwline2;
2659  LWGEOM *lwgeom1, *lwgeom2;
2660  double distance_forward, distance_backward;
2661 
2662  geom1 = PG_GETARG_GSERIALIZED_P(0);
2663  distance_forward = PG_GETARG_FLOAT8(1);
2664  distance_backward = PG_GETARG_FLOAT8(2);
2665 
2666  lwgeom1 = lwgeom_from_gserialized(geom1);
2667  lwline1 = lwgeom_as_lwline(lwgeom1);
2668  if (!lwline1)
2669  lwpgerror("Argument must be LINESTRING geometry");
2670 
2671  if (lwline_is_empty(lwline1))
2672  PG_RETURN_NULL();
2673 
2674  if (lwline_length_2d(lwline1) <= 0.0)
2675  PG_RETURN_POINTER(geom1);
2676 
2677  lwline2 = lwline_extend(lwline1, distance_forward, distance_backward);
2678  lwgeom2 = lwline_as_lwgeom(lwline2);
2679  geom2 = geometry_serialize(lwgeom2);
2680 
2681  PG_RETURN_POINTER(geom2);
2682 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:268
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:207
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:367
LWLINE * lwline_extend(const LWLINE *line, double distance_forward, double distance_backward)
Extend the ends of a line.
Definition: lwline.c:682
double lwline_length_2d(const LWLINE *line)
Definition: lwline.c:530
int lwline_is_empty(const LWLINE *line)

References lwgeom_as_lwline(), lwgeom_from_gserialized(), lwline_as_lwgeom(), lwline_extend(), lwline_is_empty(), and lwline_length_2d().

Here is the call graph for this function: