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

Definition at line 697 of file lwgeom_functions_basic.c.

References lwgeom_from_gserialized(), lwgeom_mindistance2d_tolerance(), and LWGEOM::srid.

698 {
699  double mindist;
700  GSERIALIZED *geom1 = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
701  GSERIALIZED *geom2 = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
702  double tolerance = PG_GETARG_FLOAT8(2);
703  LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
704  LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
705 
706  if ( tolerance < 0 )
707  {
708  elog(ERROR,"Tolerance cannot be less than zero\n");
709  PG_RETURN_NULL();
710  }
711 
712  if (lwgeom1->srid != lwgeom2->srid)
713  {
714  elog(ERROR,"Operation on two GEOMETRIES with different SRIDs\n");
715  PG_RETURN_NULL();
716  }
717 
718  mindist = lwgeom_mindistance2d_tolerance(lwgeom1,lwgeom2,tolerance);
719 
720  PG_FREE_IF_COPY(geom1, 0);
721  PG_FREE_IF_COPY(geom2, 1);
722  /*empty geometries cases should be right handled since return from underlying
723  functions should be MAXFLOAT which causes false as answer*/
724  PG_RETURN_BOOL(tolerance >= mindist);
725 }
double lwgeom_mindistance2d_tolerance(LWGEOM *lw1, LWGEOM *lw2, double tolerance)
Function handling min distance calculations and dwithin calculations.
Definition: measures.c:173
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int32_t srid
Definition: liblwgeom.h:355

Here is the call graph for this function: