PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_mindistance2d()

Datum LWGEOM_mindistance2d ( PG_FUNCTION_ARGS  )

Definition at line 697 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().

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