PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ LWGEOM_mindistance2d()

Datum LWGEOM_mindistance2d ( PG_FUNCTION_ARGS  )

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

683 {
684  double mindist;
685  GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
686  GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
687  LWGEOM *lwgeom1 = lwgeom_from_gserialized(geom1);
688  LWGEOM *lwgeom2 = lwgeom_from_gserialized(geom2);
689 
690  error_if_srid_mismatch(lwgeom1->srid, lwgeom2->srid);
691 
692  mindist = lwgeom_mindistance2d(lwgeom1, lwgeom2);
693 
694  lwgeom_free(lwgeom1);
695  lwgeom_free(lwgeom2);
696 
697  PG_FREE_IF_COPY(geom1, 0);
698  PG_FREE_IF_COPY(geom2, 1);
699 
700  /*if called with empty geometries the ingoing mindistance is untouched, and makes us return NULL*/
701  if (mindist<FLT_MAX)
702  PG_RETURN_FLOAT8(mindist);
703 
704  PG_RETURN_NULL();
705 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:341
int32_t srid
Definition: liblwgeom.h:383
double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initialazing min distance calculation.
Definition: measures.c:188
Here is the call graph for this function:
Here is the caller graph for this function: