PostGIS  2.2.7dev-r@@SVN_REVISION@@
Datum LWGEOM_shortestline3d ( PG_FUNCTION_ARGS  )

Definition at line 837 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(), and LWGEOM::srid.

838 {
839  GSERIALIZED *result;
840  GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
841  GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
842  LWGEOM *theline;
843  LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
844  LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
845 
846  error_if_srid_mismatch(lwgeom1->srid, lwgeom2->srid);
847 
848  theline = lwgeom_closest_line_3d(lwgeom1, lwgeom2);
849  // theline = lw_dist3d_distanceline(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MIN);
850 
851  if (lwgeom_is_empty(theline))
852  PG_RETURN_NULL();
853 
854  result = geometry_serialize(theline);
855 
856  lwgeom_free(theline);
857  lwgeom_free(lwgeom1);
858  lwgeom_free(lwgeom2);
859 
860  PG_FREE_IF_COPY(geom1, 0);
861  PG_FREE_IF_COPY(geom2, 1);
862  PG_RETURN_POINTER(result);
863 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
LWGEOM * lwgeom_closest_line_3d(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures3d.c:64
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:341
int32_t srid
Definition: liblwgeom.h:383
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:1297

Here is the call graph for this function: