PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ geography_covers()

Datum geography_covers ( PG_FUNCTION_ARGS  )

Definition at line 733 of file geography_measurement.c.

734 {
735  LWGEOM *lwgeom1 = NULL;
736  LWGEOM *lwgeom2 = NULL;
737  GSERIALIZED *g1 = NULL;
738  GSERIALIZED *g2 = NULL;
739  int result = LW_FALSE;
740 
741  /* Get our geometry objects loaded into memory. */
742  g1 = PG_GETARG_GSERIALIZED_P(0);
743  g2 = PG_GETARG_GSERIALIZED_P(1);
744 
745  /* Construct our working geometries */
746  lwgeom1 = lwgeom_from_gserialized(g1);
747  lwgeom2 = lwgeom_from_gserialized(g2);
748 
749  error_if_srid_mismatch(lwgeom1->srid, lwgeom2->srid);
750 
751  /* EMPTY never intersects with another geometry */
752  if ( lwgeom_is_empty(lwgeom1) || lwgeom_is_empty(lwgeom2) )
753  {
754  lwgeom_free(lwgeom1);
755  lwgeom_free(lwgeom2);
756  PG_FREE_IF_COPY(g1, 0);
757  PG_FREE_IF_COPY(g2, 1);
758  PG_RETURN_BOOL(false);
759  }
760 
761  /* Calculate answer */
762  result = lwgeom_covers_lwgeom_sphere(lwgeom1, lwgeom2);
763 
764  /* Clean up */
765  lwgeom_free(lwgeom1);
766  lwgeom_free(lwgeom2);
767  PG_FREE_IF_COPY(g1, 0);
768  PG_FREE_IF_COPY(g2, 1);
769 
770  PG_RETURN_BOOL(result);
771 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define LW_FALSE
Definition: liblwgeom.h:77
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
int lwgeom_covers_lwgeom_sphere(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
Calculate covers predicate for two lwgeoms on the sphere.
Definition: lwgeodetic.c:2413
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
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(), LW_FALSE, lwgeom_covers_lwgeom_sphere(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_is_empty(), and LWGEOM::srid.

Here is the call graph for this function: