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

Definition at line 662 of file lwgeom_functions_basic.c.

References lwgeom_free(), lwgeom_from_gserialized(), lwgeom_mindistance2d(), MAXFLOAT, and LWGEOM::srid.

Referenced by optimistic_overlap().

663 {
664  double mindist;
665  GSERIALIZED *geom1 = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
666  GSERIALIZED *geom2 = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
667  LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
668  LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
669 
670  if (lwgeom1->srid != lwgeom2->srid)
671  {
672  elog(ERROR,"Operation on two GEOMETRIES with different SRIDs\n");
673  PG_RETURN_NULL();
674  }
675 
676  mindist = lwgeom_mindistance2d(lwgeom1, lwgeom2);
677 
678  lwgeom_free(lwgeom1);
679  lwgeom_free(lwgeom2);
680 
681  PG_FREE_IF_COPY(geom1, 0);
682  PG_FREE_IF_COPY(geom2, 1);
683 
684  /*if called with empty geometries the ingoing mindistance is untouched, and makes us return NULL*/
685  if (mindist<MAXFLOAT)
686  PG_RETURN_FLOAT8(mindist);
687 
688  PG_RETURN_NULL();
689 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
int32_t srid
Definition: liblwgeom.h:355
double lwgeom_mindistance2d(LWGEOM *lw1, LWGEOM *lw2)
Function initialazing min distance calculation.
Definition: measures.c:162
#define MAXFLOAT
Largest float value.

Here is the call graph for this function:

Here is the caller graph for this function: