PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ geometry_project_geometry()

Datum geometry_project_geometry ( PG_FUNCTION_ARGS  )

Definition at line 2622 of file lwgeom_functions_basic.c.

2623 {
2624  GSERIALIZED *geom1, *geom2, *geom3;
2625  LWPOINT *lwpoint1, *lwpoint2, *lwpoint3;
2626  LWGEOM *lwgeom1, *lwgeom2, *lwgeom3;
2627  double distance;
2628 
2629  geom1 = PG_GETARG_GSERIALIZED_P(0);
2630  geom2 = PG_GETARG_GSERIALIZED_P(1);
2631  distance = PG_GETARG_FLOAT8(2);
2632 
2633  lwgeom1 = lwgeom_from_gserialized(geom1);
2634  lwpoint1 = lwgeom_as_lwpoint(lwgeom1);
2635  lwgeom2 = lwgeom_from_gserialized(geom2);
2636  lwpoint2 = lwgeom_as_lwpoint(lwgeom2);
2637 
2638  if (!(lwpoint1 && lwpoint2))
2639  lwpgerror("Arguments must be POINT geometries");
2640 
2641  if (lwgeom_is_empty(lwgeom1) || lwgeom_is_empty(lwgeom2))
2642  PG_RETURN_NULL();
2643 
2644  if (lwpoint_same2d(lwpoint1, lwpoint2))
2645  PG_RETURN_POINTER(geom2);
2646 
2647  lwpoint3 = lwpoint_project_lwpoint(lwpoint1, lwpoint2, distance);
2648  lwgeom3 = lwpoint_as_lwgeom(lwpoint3);
2649  geom3 = geometry_serialize(lwgeom3);
2650 
2651  PG_RETURN_POINTER(geom3);
2652 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
Definition: lwgeom.c:344
LWPOINT * lwpoint_project_lwpoint(const LWPOINT *lwpoint1, const LWPOINT *lwpoint2, double distance)
Definition: lwpoint.c:277
char lwpoint_same2d(const LWPOINT *p1, const LWPOINT *p2)
Definition: lwpoint.c:271
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(), lwpoint_project_lwpoint(), and lwpoint_same2d().

Here is the call graph for this function: