PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ geometry_line_extend()

Datum geometry_line_extend ( PG_FUNCTION_ARGS  )

Definition at line 2628 of file lwgeom_functions_basic.c.

2629 {
2630  GSERIALIZED *geom1, *geom2;
2631  LWLINE *lwline1, *lwline2;
2632  LWGEOM *lwgeom1, *lwgeom2;
2633  double distance_forward, distance_backward;
2634 
2635  geom1 = PG_GETARG_GSERIALIZED_P(0);
2636  distance_forward = PG_GETARG_FLOAT8(1);
2637  distance_backward = PG_GETARG_FLOAT8(2);
2638 
2639  lwgeom1 = lwgeom_from_gserialized(geom1);
2640  lwline1 = lwgeom_as_lwline(lwgeom1);
2641  if (!lwline1)
2642  lwpgerror("Argument must be LINESTRING geometry");
2643 
2644  if (lwline_is_empty(lwline1))
2645  PG_RETURN_NULL();
2646 
2647  if (lwline_length_2d(lwline1) <= 0.0)
2648  PG_RETURN_POINTER(geom1);
2649 
2650  lwline2 = lwline_extend(lwline1, distance_forward, distance_backward);
2651  lwgeom2 = lwline_as_lwgeom(lwline2);
2652  geom2 = geometry_serialize(lwgeom2);
2653 
2654  PG_RETURN_POINTER(geom2);
2655 }
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:179
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:339
LWLINE * lwline_extend(const LWLINE *line, double distance_forward, double distance_backward)
Extend the ends of a line.
Definition: lwline.c:672
double lwline_length_2d(const LWLINE *line)
Definition: lwline.c:520
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: