PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_same()

Datum LWGEOM_same ( PG_FUNCTION_ARGS  )

Definition at line 2028 of file lwgeom_functions_basic.c.

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

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

Here is the call graph for this function: