PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ geometry_project_direction()

Datum geometry_project_direction ( PG_FUNCTION_ARGS  )

Definition at line 2553 of file lwgeom_functions_basic.c.

2554 {
2555  GSERIALIZED *geom1, *geom2;
2556  LWPOINT *lwpoint1, *lwpoint2;
2557  LWGEOM *lwgeom1, *lwgeom2;
2558  double distance, azimuth;
2559 
2560  geom1 = PG_GETARG_GSERIALIZED_P(0);
2561  distance = PG_GETARG_FLOAT8(1);
2562  azimuth = PG_GETARG_FLOAT8(2);
2563  lwgeom1 = lwgeom_from_gserialized(geom1);
2564  lwpoint1 = lwgeom_as_lwpoint(lwgeom1);
2565 
2566  if (!lwpoint1)
2567  lwpgerror("Argument must be POINT geometry");
2568 
2569  if (lwgeom_is_empty(lwgeom1))
2570  PG_RETURN_NULL();
2571 
2572  lwpoint2 = lwpoint_project(lwpoint1, distance, azimuth);
2573  lwgeom2 = lwpoint_as_lwgeom(lwpoint2);
2574  geom2 = geometry_serialize(lwgeom2);
2575  PG_RETURN_POINTER(geom2);
2576 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:268
LWPOINT * lwpoint_project(const LWPOINT *lwpoint1, double distance, double azimuth)
Definition: lwpoint.c:290
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
Definition: lwgeom.c:344
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwinline.h:199
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwinline.h:127
static double distance(double x1, double y1, double x2, double y2)
Definition: lwtree.c:1032

References distance(), lwgeom_as_lwpoint(), lwgeom_from_gserialized(), lwgeom_is_empty(), lwpoint_as_lwgeom(), and lwpoint_project().

Here is the call graph for this function: