PostGIS  2.2.7dev-r@@SVN_REVISION@@
Datum LWGEOM_same ( PG_FUNCTION_ARGS  )

Definition at line 1961 of file lwgeom_functions_basic.c.

References FALSE, gserialized_get_type(), gserialized_get_zm(), lwgeom_free(), lwgeom_from_gserialized(), and lwgeom_same().

1962 {
1963  GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0);
1964  GSERIALIZED *g2 = PG_GETARG_GSERIALIZED_P(1);
1965  LWGEOM *lwg1, *lwg2;
1966  bool result;
1967 
1968  if ( gserialized_get_type(g1) != gserialized_get_type(g2) )
1969  {
1970  PG_FREE_IF_COPY(g1, 0);
1971  PG_FREE_IF_COPY(g2, 1);
1972  PG_RETURN_BOOL(FALSE); /* different types */
1973  }
1974 
1975  if ( gserialized_get_zm(g1) != gserialized_get_zm(g2) )
1976  {
1977  PG_FREE_IF_COPY(g1, 0);
1978  PG_FREE_IF_COPY(g2, 1);
1979  PG_RETURN_BOOL(FALSE); /* different dimensions */
1980  }
1981 
1982  /* ok, deserialize. */
1983  lwg1 = lwgeom_from_gserialized(g1);
1984  lwg2 = lwgeom_from_gserialized(g2);
1985 
1986  /* invoke appropriate function */
1987  result = lwgeom_same(lwg1, lwg2);
1988 
1989  /* Relase memory */
1990  lwgeom_free(lwg1);
1991  lwgeom_free(lwg2);
1992  PG_FREE_IF_COPY(g1, 0);
1993  PG_FREE_IF_COPY(g2, 1);
1994 
1995  PG_RETURN_BOOL(result);
1996 }
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:55
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
Definition: lwgeom.c:495
int gserialized_get_zm(const GSERIALIZED *gser)
Return a number indicating presence of Z and M coordinates.
Definition: g_serialized.c:34
#define FALSE
Definition: dbfopen.c:168

Here is the call graph for this function: