PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_shortestline3d()

Datum LWGEOM_shortestline3d ( PG_FUNCTION_ARGS  )

Definition at line 852 of file lwgeom_functions_basic.c.

References error_if_srid_mismatch(), geometry_serialize(), lwgeom_closest_line_3d(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_is_empty(), LWGEOM_longestline3d(), PG_FUNCTION_INFO_V1(), and LWGEOM::srid.

Referenced by LWGEOM_closestpoint3d().

853 {
854  GSERIALIZED *result;
855  GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
856  GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
857  LWGEOM *theline;
858  LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
859  LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
860 
861  error_if_srid_mismatch(lwgeom1->srid, lwgeom2->srid);
862 
863  theline = lwgeom_closest_line_3d(lwgeom1, lwgeom2);
864  // theline = lw_dist3d_distanceline(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MIN);
865 
866  if (lwgeom_is_empty(theline))
867  PG_RETURN_NULL();
868 
869  result = geometry_serialize(theline);
870 
871  lwgeom_free(theline);
872  lwgeom_free(lwgeom1);
873  lwgeom_free(lwgeom2);
874 
875  PG_FREE_IF_COPY(geom1, 0);
876  PG_FREE_IF_COPY(geom2, 1);
877  PG_RETURN_POINTER(result);
878 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
LWGEOM * lwgeom_closest_line_3d(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures3d.c:88
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:371
int32_t srid
Definition: liblwgeom.h:399
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1346
Here is the call graph for this function:
Here is the caller graph for this function: