PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ LWGEOM_mindistance2d()

Datum LWGEOM_mindistance2d ( PG_FUNCTION_ARGS  )

Definition at line 700 of file lwgeom_functions_basic.c.

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

Referenced by LWGEOM_longestline2d(), and optimistic_overlap().

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