PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_mindistance2d()

Datum LWGEOM_mindistance2d ( PG_FUNCTION_ARGS  )

Definition at line 701 of file lwgeom_functions_basic.c.

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

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

Referenced by optimistic_overlap().

Here is the call graph for this function:
Here is the caller graph for this function: