PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ geography_covers()

Datum geography_covers ( PG_FUNCTION_ARGS  )

Definition at line 729 of file geography_measurement.c.

References error_if_srid_mismatch(), geography_bestsrid(), LW_FALSE, lwgeom_covers_lwgeom_sphere(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_is_empty(), PG_FUNCTION_INFO_V1(), and LWGEOM::srid.

Referenced by geography_point_outside().

730 {
731  LWGEOM *lwgeom1 = NULL;
732  LWGEOM *lwgeom2 = NULL;
733  GSERIALIZED *g1 = NULL;
734  GSERIALIZED *g2 = NULL;
735  int result = LW_FALSE;
736 
737  /* Get our geometry objects loaded into memory. */
738  g1 = PG_GETARG_GSERIALIZED_P(0);
739  g2 = PG_GETARG_GSERIALIZED_P(1);
740 
741  /* Construct our working geometries */
742  lwgeom1 = lwgeom_from_gserialized(g1);
743  lwgeom2 = lwgeom_from_gserialized(g2);
744 
745  error_if_srid_mismatch(lwgeom1->srid, lwgeom2->srid);
746 
747  /* EMPTY never intersects with another geometry */
748  if ( lwgeom_is_empty(lwgeom1) || lwgeom_is_empty(lwgeom2) )
749  {
750  lwgeom_free(lwgeom1);
751  lwgeom_free(lwgeom2);
752  PG_FREE_IF_COPY(g1, 0);
753  PG_FREE_IF_COPY(g2, 1);
754  PG_RETURN_BOOL(false);
755  }
756 
757  /* Calculate answer */
758  result = lwgeom_covers_lwgeom_sphere(lwgeom1, lwgeom2);
759 
760  /* Clean up */
761  lwgeom_free(lwgeom1);
762  lwgeom_free(lwgeom2);
763  PG_FREE_IF_COPY(g1, 0);
764  PG_FREE_IF_COPY(g2, 1);
765 
766  PG_RETURN_BOOL(result);
767 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int lwgeom_covers_lwgeom_sphere(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
Calculate covers predicate for two lwgeoms on the sphere.
Definition: lwgeodetic.c:2326
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:338
int32_t srid
Definition: liblwgeom.h:401
#define LW_FALSE
Definition: liblwgeom.h:76
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1393
Here is the call graph for this function:
Here is the caller graph for this function: