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

Definition at line 2026 of file lwgeom_functions_basic.c.

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

2027 {
2028  GSERIALIZED *g1 = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
2029  GSERIALIZED *g2 = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
2030  LWGEOM *lwg1, *lwg2;
2031  bool result;
2032 
2033  if ( gserialized_get_type(g1) != gserialized_get_type(g2) )
2034  {
2035  PG_FREE_IF_COPY(g1, 0);
2036  PG_FREE_IF_COPY(g2, 1);
2037  PG_RETURN_BOOL(FALSE); /* different types */
2038  }
2039 
2040  if ( gserialized_get_zm(g1) != gserialized_get_zm(g2) )
2041  {
2042  PG_FREE_IF_COPY(g1, 0);
2043  PG_FREE_IF_COPY(g2, 1);
2044  PG_RETURN_BOOL(FALSE); /* different dimensions */
2045  }
2046 
2047  /* ok, deserialize. */
2048  lwg1 = lwgeom_from_gserialized(g1);
2049  lwg2 = lwgeom_from_gserialized(g2);
2050 
2051  /* invoke appropriate function */
2052  result = lwgeom_same(lwg1, lwg2);
2053 
2054  /* Relase memory */
2055  lwgeom_free(lwg1);
2056  lwgeom_free(lwg2);
2057  PG_FREE_IF_COPY(g1, 0);
2058  PG_FREE_IF_COPY(g2, 1);
2059 
2060  PG_RETURN_BOOL(result);
2061 }
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:56
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
char ** result
Definition: liblwgeom.h:218
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
Definition: lwgeom.c:451
int gserialized_get_zm(const GSERIALIZED *gser)
Return a number indicating presence of Z and M coordinates.
Definition: g_serialized.c:35
#define FALSE
Definition: dbfopen.c:169

Here is the call graph for this function: