PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_gserialized_is_empty ( void  )
static

Definition at line 311 of file cu_libgeom.c.

References gserialized_from_lwgeom(), gserialized_is_empty(), LW_PARSER_CHECK_NONE, lwfree(), lwgeom_free(), and lwgeom_from_wkt().

Referenced by libgeom_suite_setup().

312 {
313  int i = 0;
314  struct gserialized_empty_cases {
315  const char* wkt;
316  int isempty;
317  };
318 
319  struct gserialized_empty_cases cases[] = {
320  { "POINT EMPTY", 1 },
321  { "POINT(1 1)", 0 },
322  { "LINESTRING EMPTY", 1 },
323  { "MULTILINESTRING EMPTY", 1 },
324  { "MULTILINESTRING(EMPTY)", 1 },
325  { "MULTILINESTRING(EMPTY,EMPTY)", 1 },
326  { "MULTILINESTRING(EMPTY,(0 0,1 1))", 0 },
327  { "MULTILINESTRING((0 0,1 1),EMPTY)", 0 },
328  { "MULTILINESTRING(EMPTY,(0 0,1 1),EMPTY)", 0 },
329  { "MULTILINESTRING(EMPTY,EMPTY,EMPTY)", 1 },
330  { "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY,EMPTY))", 1 },
331  { "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY),POINT(1 1))", 0 },
332  { "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY, (0 0)),POINT EMPTY)", 0 },
333  { "GEOMETRYCOLLECTION(POLYGON EMPTY,POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 },
334  { "GEOMETRYCOLLECTION(POLYGON EMPTY,GEOMETRYCOLLECTION(POINT EMPTY),MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 },
335  { NULL, 0 }
336  };
337 
338  while( cases[i].wkt )
339  {
340  // i = 11;
341  LWGEOM *lw = lwgeom_from_wkt(cases[i].wkt, LW_PARSER_CHECK_NONE);
342  GSERIALIZED *g = gserialized_from_lwgeom(lw, 0, 0);
343  int ie = gserialized_is_empty(g);
344  // printf("%s: we say %d, they say %d\n", cases[i].wkt, cases[i].isempty, ie);
345  CU_ASSERT_EQUAL(ie, cases[i].isempty);
346  lwgeom_free(lw);
347  lwfree(g);
348  i++;
349  }
350 }
void lwfree(void *mem)
Definition: lwutil.c:190
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:844
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: g_serialized.c:140
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1706
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, int is_geodetic, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
Definition: g_serialized.c:908

Here is the call graph for this function:

Here is the caller graph for this function: