PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ geometry_line_extend()

Datum geometry_line_extend ( PG_FUNCTION_ARGS  )

Definition at line 2663 of file lwgeom_functions_basic.c.

2664 {
2665  GSERIALIZED *geom1, *geom2;
2666  LWLINE *lwline1, *lwline2;
2667  LWGEOM *lwgeom1, *lwgeom2;
2668  double distance_forward, distance_backward;
2669 
2670  geom1 = PG_GETARG_GSERIALIZED_P(0);
2671  distance_forward = PG_GETARG_FLOAT8(1);
2672  distance_backward = PG_GETARG_FLOAT8(2);
2673 
2674  lwgeom1 = lwgeom_from_gserialized(geom1);
2675  lwline1 = lwgeom_as_lwline(lwgeom1);
2676  if (!lwline1)
2677  lwpgerror("Argument must be LINESTRING geometry");
2678 
2679  if (lwline_is_empty(lwline1))
2680  PG_RETURN_NULL();
2681 
2682  if (lwline_length_2d(lwline1) <= 0.0)
2683  PG_RETURN_POINTER(geom1);
2684 
2685  lwline2 = lwline_extend(lwline1, distance_forward, distance_backward);
2686  lwgeom2 = lwline_as_lwgeom(lwline2);
2687  geom2 = geometry_serialize(lwgeom2);
2688 
2689  PG_RETURN_POINTER(geom2);
2690 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
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: