PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum LWGEOM_mindistance3d ( PG_FUNCTION_ARGS  )

Definition at line 905 of file lwgeom_functions_basic.c.

References lwgeom_from_gserialized(), lwgeom_mindistance3d(), MAXFLOAT, and LWGEOM::srid.

906 {
907  double mindist;
908  GSERIALIZED *geom1 = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
909  GSERIALIZED *geom2 = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
910  LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
911  LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
912 
913  if (lwgeom1->srid != lwgeom2->srid)
914  {
915  elog(ERROR,"Operation on two GEOMETRIES with different SRIDs\n");
916  PG_RETURN_NULL();
917  }
918 
919  mindist = lwgeom_mindistance3d(lwgeom1, lwgeom2);
920 
921  PG_FREE_IF_COPY(geom1, 0);
922  PG_FREE_IF_COPY(geom2, 1);
923 
924  /*if called with empty geometries the ingoing mindistance is untouched, and makes us return NULL*/
925  if (mindist<MAXFLOAT)
926  PG_RETURN_FLOAT8(mindist);
927 
928  PG_RETURN_NULL();
929 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
double lwgeom_mindistance3d(LWGEOM *lw1, LWGEOM *lw2)
Function initialazing 3d min distance calculation.
Definition: measures3d.c:153
int32_t srid
Definition: liblwgeom.h:355
#define MAXFLOAT
Largest float value.

Here is the call graph for this function: