PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ geometry_project_direction()

Datum geometry_project_direction ( PG_FUNCTION_ARGS  )

Definition at line 2588 of file lwgeom_functions_basic.c.

2589 {
2590  GSERIALIZED *geom1, *geom2;
2591  LWPOINT *lwpoint1, *lwpoint2;
2592  LWGEOM *lwgeom1, *lwgeom2;
2593  double distance, azimuth;
2594 
2595  geom1 = PG_GETARG_GSERIALIZED_P(0);
2596  distance = PG_GETARG_FLOAT8(1);
2597  azimuth = PG_GETARG_FLOAT8(2);
2598  lwgeom1 = lwgeom_from_gserialized(geom1);
2599  lwpoint1 = lwgeom_as_lwpoint(lwgeom1);
2600 
2601  if (!lwpoint1)
2602  lwpgerror("Argument must be POINT geometry");
2603 
2604  if (lwgeom_is_empty(lwgeom1))
2605  PG_RETURN_NULL();
2606 
2607  lwpoint2 = lwpoint_project(lwpoint1, distance, azimuth);
2608  lwgeom2 = lwpoint_as_lwgeom(lwpoint2);
2609  geom2 = geometry_serialize(lwgeom2);
2610  PG_RETURN_POINTER(geom2);
2611 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
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:203
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwinline.h:131
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: