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

Definition at line 2025 of file lwgeom_functions_basic.c.

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

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

Here is the call graph for this function: