PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ geometry_project_geometry()

Datum geometry_project_geometry ( PG_FUNCTION_ARGS  )

Definition at line 2614 of file lwgeom_functions_basic.c.

2615 {
2616  GSERIALIZED *geom1, *geom2, *geom3;
2617  LWPOINT *lwpoint1, *lwpoint2, *lwpoint3;
2618  LWGEOM *lwgeom1, *lwgeom2, *lwgeom3;
2619  double distance;
2620 
2621  geom1 = PG_GETARG_GSERIALIZED_P(0);
2622  geom2 = PG_GETARG_GSERIALIZED_P(1);
2623  distance = PG_GETARG_FLOAT8(2);
2624 
2625  lwgeom1 = lwgeom_from_gserialized(geom1);
2626  lwpoint1 = lwgeom_as_lwpoint(lwgeom1);
2627  lwgeom2 = lwgeom_from_gserialized(geom2);
2628  lwpoint2 = lwgeom_as_lwpoint(lwgeom2);
2629 
2630  if (!(lwpoint1 && lwpoint2))
2631  lwpgerror("Arguments must be POINT geometries");
2632 
2633  if (lwgeom_is_empty(lwgeom1) || lwgeom_is_empty(lwgeom2))
2634  PG_RETURN_NULL();
2635 
2636  if (lwpoint_same2d(lwpoint1, lwpoint2))
2637  PG_RETURN_POINTER(geom2);
2638 
2639  lwpoint3 = lwpoint_project_lwpoint(lwpoint1, lwpoint2, distance);
2640  lwgeom3 = lwpoint_as_lwgeom(lwpoint3);
2641  geom3 = geometry_serialize(lwgeom3);
2642 
2643  PG_RETURN_POINTER(geom3);
2644 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:268
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
Definition: lwgeom.c:372
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: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(), lwpoint_project_lwpoint(), and lwpoint_same2d().

Here is the call graph for this function: