PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ test_gserialized_is_empty()

static void test_gserialized_is_empty ( void  )
static

Definition at line 319 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().

320 {
321  int i = 0;
322  struct gserialized_empty_cases {
323  const char* wkt;
324  int isempty;
325  };
326 
327  struct gserialized_empty_cases cases[] = {
328  { "POINT EMPTY", 1 },
329  { "POINT(1 1)", 0 },
330  { "LINESTRING EMPTY", 1 },
331  { "MULTILINESTRING EMPTY", 1 },
332  { "MULTILINESTRING(EMPTY)", 1 },
333  { "MULTILINESTRING(EMPTY,EMPTY)", 1 },
334  { "MULTILINESTRING(EMPTY,(0 0,1 1))", 0 },
335  { "MULTILINESTRING((0 0,1 1),EMPTY)", 0 },
336  { "MULTILINESTRING(EMPTY,(0 0,1 1),EMPTY)", 0 },
337  { "MULTILINESTRING(EMPTY,EMPTY,EMPTY)", 1 },
338  { "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY,EMPTY))", 1 },
339  { "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY),POINT(1 1))", 0 },
340  { "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY, (0 0)),POINT EMPTY)", 0 },
341  { "GEOMETRYCOLLECTION(POLYGON EMPTY,POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 },
342  { "GEOMETRYCOLLECTION(POLYGON EMPTY,GEOMETRYCOLLECTION(POINT EMPTY),MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 },
343  { NULL, 0 }
344  };
345 
346  while( cases[i].wkt )
347  {
348  // i = 11;
349  LWGEOM *lw = lwgeom_from_wkt(cases[i].wkt, LW_PARSER_CHECK_NONE);
350  GSERIALIZED *g = gserialized_from_lwgeom(lw, 0, 0);
351  int ie = gserialized_is_empty(g);
352  // printf("%s: we say %d, they say %d\n", cases[i].wkt, cases[i].isempty, ie);
353  CU_ASSERT_EQUAL(ie, cases[i].isempty);
354  lwgeom_free(lw);
355  lwfree(g);
356  i++;
357  }
358 }
void lwfree(void *mem)
Definition: lwutil.c:214
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:890
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: g_serialized.c:139
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1869
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, int is_geodetic, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
Definition: g_serialized.c:906
Here is the call graph for this function:
Here is the caller graph for this function: