PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_same()

Datum LWGEOM_same ( PG_FUNCTION_ARGS  )

Definition at line 2021 of file lwgeom_functions_basic.c.

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

Referenced by LWGEOM_ndims().

2022 {
2023  GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0);
2024  GSERIALIZED *g2 = PG_GETARG_GSERIALIZED_P(1);
2025  LWGEOM *lwg1, *lwg2;
2026  bool result;
2027 
2028  if ( gserialized_get_type(g1) != gserialized_get_type(g2) )
2029  {
2030  PG_FREE_IF_COPY(g1, 0);
2031  PG_FREE_IF_COPY(g2, 1);
2032  PG_RETURN_BOOL(FALSE); /* different types */
2033  }
2034 
2035  if ( gserialized_get_zm(g1) != gserialized_get_zm(g2) )
2036  {
2037  PG_FREE_IF_COPY(g1, 0);
2038  PG_FREE_IF_COPY(g2, 1);
2039  PG_RETURN_BOOL(FALSE); /* different dimensions */
2040  }
2041 
2042  /* ok, deserialize. */
2043  lwg1 = lwgeom_from_gserialized(g1);
2044  lwg2 = lwgeom_from_gserialized(g2);
2045 
2046  /* invoke appropriate function */
2047  result = lwgeom_same(lwg1, lwg2);
2048 
2049  /* Relase memory */
2050  lwgeom_free(lwg1);
2051  lwgeom_free(lwg2);
2052  PG_FREE_IF_COPY(g1, 0);
2053  PG_FREE_IF_COPY(g2, 1);
2054 
2055  PG_RETURN_BOOL(result);
2056 }
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:1099
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
Definition: lwgeom.c:544
int gserialized_get_zm(const GSERIALIZED *gser)
Return a number indicating presence of Z and M coordinates.
Definition: g_serialized.c:55
#define FALSE
Definition: dbfopen.c:168
Here is the call graph for this function:
Here is the caller graph for this function: