PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ geography_covers()

Datum geography_covers ( PG_FUNCTION_ARGS  )

Definition at line 733 of file geography_measurement.c.

References error_if_srid_mismatch(), geography_bestsrid(), gserialized_get_type(), 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().

734 {
735  LWGEOM *lwgeom1 = NULL;
736  LWGEOM *lwgeom2 = NULL;
737  GSERIALIZED *g1 = NULL;
738  GSERIALIZED *g2 = NULL;
739  int type1, type2;
740  int result = LW_FALSE;
741 
742  /* Get our geometry objects loaded into memory. */
743  g1 = PG_GETARG_GSERIALIZED_P(0);
744  g2 = PG_GETARG_GSERIALIZED_P(1);
745 
746  type1 = gserialized_get_type(g1);
747  type2 = gserialized_get_type(g2);
748 
749  /* Construct our working geometries */
750  lwgeom1 = lwgeom_from_gserialized(g1);
751  lwgeom2 = lwgeom_from_gserialized(g2);
752 
753  error_if_srid_mismatch(lwgeom1->srid, lwgeom2->srid);
754 
755  /* EMPTY never intersects with another geometry */
756  if ( lwgeom_is_empty(lwgeom1) || lwgeom_is_empty(lwgeom2) )
757  {
758  lwgeom_free(lwgeom1);
759  lwgeom_free(lwgeom2);
760  PG_FREE_IF_COPY(g1, 0);
761  PG_FREE_IF_COPY(g2, 1);
762  PG_RETURN_BOOL(false);
763  }
764 
765  /* Calculate answer */
766  result = lwgeom_covers_lwgeom_sphere(lwgeom1, lwgeom2);
767 
768  /* Clean up */
769  lwgeom_free(lwgeom1);
770  lwgeom_free(lwgeom2);
771  PG_FREE_IF_COPY(g1, 0);
772  PG_FREE_IF_COPY(g2, 1);
773 
774  PG_RETURN_BOOL(result);
775 }
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
Definition: g_serialized.c:86
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:2405
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
#define LW_FALSE
Definition: liblwgeom.h:77
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:1346
Here is the call graph for this function:
Here is the caller graph for this function: