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

Definition at line 698 of file lwgeom_functions_basic.c.

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

Referenced by optimistic_overlap().

699 {
700  double mindist;
701  GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
702  GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
703  LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
704  LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
705 
706  error_if_srid_mismatch(lwgeom1->srid, lwgeom2->srid);
707 
708  mindist = lwgeom_mindistance2d(lwgeom1, lwgeom2);
709 
710  lwgeom_free(lwgeom1);
711  lwgeom_free(lwgeom2);
712 
713  PG_FREE_IF_COPY(geom1, 0);
714  PG_FREE_IF_COPY(geom2, 1);
715 
716  /*if called with empty geometries the ingoing mindistance is untouched, and makes us return NULL*/
717  if (mindist<FLT_MAX)
718  PG_RETURN_FLOAT8(mindist);
719 
720  PG_RETURN_NULL();
721 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1137
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:338
int32_t srid
Definition: liblwgeom.h:398
double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initialazing min distance calculation.
Definition: measures.c:202

Here is the call graph for this function:

Here is the caller graph for this function: