PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ geometry_project_direction()

Datum geometry_project_direction ( PG_FUNCTION_ARGS  )

Definition at line 2580 of file lwgeom_functions_basic.c.

2581 {
2582  GSERIALIZED *geom1, *geom2;
2583  LWPOINT *lwpoint1, *lwpoint2;
2584  LWGEOM *lwgeom1, *lwgeom2;
2585  double distance, azimuth;
2586 
2587  geom1 = PG_GETARG_GSERIALIZED_P(0);
2588  distance = PG_GETARG_FLOAT8(1);
2589  azimuth = PG_GETARG_FLOAT8(2);
2590  lwgeom1 = lwgeom_from_gserialized(geom1);
2591  lwpoint1 = lwgeom_as_lwpoint(lwgeom1);
2592 
2593  if (!lwpoint1)
2594  lwpgerror("Argument must be POINT geometry");
2595 
2596  if (lwgeom_is_empty(lwgeom1))
2597  PG_RETURN_NULL();
2598 
2599  lwpoint2 = lwpoint_project(lwpoint1, distance, azimuth);
2600  lwgeom2 = lwpoint_as_lwgeom(lwpoint2);
2601  geom2 = geometry_serialize(lwgeom2);
2602  PG_RETURN_POINTER(geom2);
2603 }
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:372
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: