PostGIS 3.6.2dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ geometry_project_geometry()

Datum geometry_project_geometry ( PG_FUNCTION_ARGS  )

Definition at line 2587 of file lwgeom_functions_basic.c.

2588{
2589 GSERIALIZED *geom1, *geom2, *geom3;
2590 LWPOINT *lwpoint1, *lwpoint2, *lwpoint3;
2591 LWGEOM *lwgeom1, *lwgeom2, *lwgeom3;
2592 double distance;
2593
2594 geom1 = PG_GETARG_GSERIALIZED_P(0);
2595 geom2 = PG_GETARG_GSERIALIZED_P(1);
2596 distance = PG_GETARG_FLOAT8(2);
2597
2598 lwgeom1 = lwgeom_from_gserialized(geom1);
2599 lwpoint1 = lwgeom_as_lwpoint(lwgeom1);
2600 lwgeom2 = lwgeom_from_gserialized(geom2);
2601 lwpoint2 = lwgeom_as_lwpoint(lwgeom2);
2602
2603 if (!(lwpoint1 && lwpoint2))
2604 lwpgerror("Arguments must be POINT geometries");
2605
2606 if (lwgeom_is_empty(lwgeom1) || lwgeom_is_empty(lwgeom2))
2607 PG_RETURN_NULL();
2608
2609 if (lwpoint_same2d(lwpoint1, lwpoint2))
2610 PG_RETURN_POINTER(geom2);
2611
2612 lwpoint3 = lwpoint_project_lwpoint(lwpoint1, lwpoint2, distance);
2613 lwgeom3 = lwpoint_as_lwgeom(lwpoint3);
2614 geom3 = geometry_serialize(lwgeom3);
2615
2616 PG_RETURN_POINTER(geom3);
2617}
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
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 LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition lwinline.h:127
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 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: