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

Definition at line 733 of file lwgeom_functions_basic.c.

References LW_FALSE, lwgeom_from_gserialized(), lwgeom_maxdistance2d_tolerance(), and LWGEOM::srid.

734 {
735  double maxdist;
736  GSERIALIZED *geom1 = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
737  GSERIALIZED *geom2 = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
738  double tolerance = PG_GETARG_FLOAT8(2);
739  LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
740  LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
741 
742  if ( tolerance < 0 )
743  {
744  elog(ERROR,"Tolerance cannot be less than zero\n");
745  PG_RETURN_NULL();
746  }
747 
748  if (lwgeom1->srid != lwgeom2->srid)
749  {
750  elog(ERROR,"Operation on two GEOMETRIES with different SRIDs\n");
751  PG_RETURN_NULL();
752  }
753 
754  maxdist = lwgeom_maxdistance2d_tolerance(lwgeom1, lwgeom2, tolerance);
755 
756  PG_FREE_IF_COPY(geom1, 0);
757  PG_FREE_IF_COPY(geom2, 1);
758 
759  /*If function is feed with empty geometries we should return false*/
760  if (maxdist>-1)
761  PG_RETURN_BOOL(tolerance >= maxdist);
762 
763  PG_RETURN_BOOL(LW_FALSE);
764 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
double lwgeom_maxdistance2d_tolerance(LWGEOM *lw1, LWGEOM *lw2, double tolerance)
Function handling max distance calculations and dfyllywithin calculations.
Definition: measures.c:141
int32_t srid
Definition: liblwgeom.h:355
#define LW_FALSE
Definition: liblwgeom.h:52

Here is the call graph for this function: