PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ LWGEOM_closestpoint3d()

Datum LWGEOM_closestpoint3d ( PG_FUNCTION_ARGS  )

Definition at line 823 of file lwgeom_functions_basic.c.

References error_if_srid_mismatch(), geometry_serialize(), lwgeom_closest_point_3d(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_is_empty(), LWGEOM_shortestline3d(), PG_FUNCTION_INFO_V1(), and LWGEOM::srid.

Referenced by LWGEOM_maxdistance2d_linestring().

824 {
825  GSERIALIZED *result;
826  GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
827  GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
828  LWGEOM *point;
829  LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
830  LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
831 
832  error_if_srid_mismatch(lwgeom1->srid, lwgeom2->srid);
833 
834  point = lwgeom_closest_point_3d(lwgeom1, lwgeom2);
835  // point = lw_dist3d_distancepoint(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MIN);
836 
837  if (lwgeom_is_empty(point))
838  PG_RETURN_NULL();
839 
840  result = geometry_serialize(point);
841 
842  lwgeom_free(point);
843  lwgeom_free(lwgeom1);
844  lwgeom_free(lwgeom2);
845 
846  PG_FREE_IF_COPY(geom1, 0);
847  PG_FREE_IF_COPY(geom2, 1);
848  PG_RETURN_POINTER(result);
849 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1128
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:336
int32_t srid
Definition: liblwgeom.h:401
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:172
LWGEOM * lwgeom_closest_point_3d(const LWGEOM *lw1, const LWGEOM *lw2)
Definition: measures3d.c:100
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
Here is the call graph for this function:
Here is the caller graph for this function: