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

◆ LWGEOM_shortestline2d()

Datum LWGEOM_shortestline2d ( PG_FUNCTION_ARGS  )

Definition at line 644 of file lwgeom_functions_basic.c.

645{
647 GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
648 GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
649 LWGEOM *theline;
650 LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
651 LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
652 gserialized_error_if_srid_mismatch(geom1, geom2, __func__);
653
654 theline = lwgeom_closest_line(lwgeom1, lwgeom2);
655
656 if (lwgeom_is_empty(theline))
657 PG_RETURN_NULL();
658
659 result = geometry_serialize(theline);
660 lwgeom_free(theline);
661 lwgeom_free(lwgeom1);
662 lwgeom_free(lwgeom2);
663
664 PG_FREE_IF_COPY(geom1, 0);
665 PG_FREE_IF_COPY(geom2, 1);
666 PG_RETURN_POINTER(result);
667}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
void gserialized_error_if_srid_mismatch(const GSERIALIZED *g1, const GSERIALIZED *g2, const char *funcname)
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
LWGEOM * lwgeom_closest_line(const LWGEOM *lw1, const LWGEOM *lw2)
Definition measures.c:43
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

References gserialized_error_if_srid_mismatch(), lwgeom_closest_line(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_is_empty(), and result.

Here is the call graph for this function: