PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_lwgeom_as_curve()

static void test_lwgeom_as_curve ( void  )
static

Definition at line 973 of file cu_libgeom.c.

References LW_PARSER_CHECK_NONE, lwfree(), lwgeom_as_curve(), lwgeom_free(), lwgeom_from_wkt(), and lwgeom_to_ewkt().

Referenced by libgeom_suite_setup().

974 {
975  LWGEOM *geom;
976  LWGEOM *geom2;
977  char *in_ewkt, *out_ewkt;
978 
979  geom = lwgeom_from_wkt("LINESTRING(0 0, 10 0)", LW_PARSER_CHECK_NONE);
980  geom2 = lwgeom_as_curve(geom);
981  in_ewkt = "COMPOUNDCURVE((0 0,10 0))";
982  out_ewkt = lwgeom_to_ewkt(geom2);
983  if (strcmp(in_ewkt, out_ewkt))
984  fprintf(stderr, "\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
985  CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
986  lwfree(out_ewkt);
987  lwgeom_free(geom);
988  lwgeom_free(geom2);
989 
990  geom = lwgeom_from_wkt("MULTILINESTRING((0 0, 10 0))", LW_PARSER_CHECK_NONE);
991  geom2 = lwgeom_as_curve(geom);
992  in_ewkt = "MULTICURVE((0 0,10 0))";
993  out_ewkt = lwgeom_to_ewkt(geom2);
994  if (strcmp(in_ewkt, out_ewkt))
995  fprintf(stderr, "\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
996  CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
997  lwfree(out_ewkt);
998  lwgeom_free(geom);
999  lwgeom_free(geom2);
1000 
1001  geom = lwgeom_from_wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))", LW_PARSER_CHECK_NONE);
1002  geom2 = lwgeom_as_curve(geom);
1003  in_ewkt = "CURVEPOLYGON((0 0,10 0,10 10,0 10,0 0))";
1004  out_ewkt = lwgeom_to_ewkt(geom2);
1005  if (strcmp(in_ewkt, out_ewkt))
1006  fprintf(stderr, "\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
1007  CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
1008  lwfree(out_ewkt);
1009  lwgeom_free(geom);
1010  lwgeom_free(geom2);
1011 
1012  geom = lwgeom_from_wkt("MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0)))", LW_PARSER_CHECK_NONE);
1013  geom2 = lwgeom_as_curve(geom);
1014  in_ewkt = "MULTISURFACE(((0 0,10 0,10 10,0 10,0 0)))";
1015  out_ewkt = lwgeom_to_ewkt(geom2);
1016  if (strcmp(in_ewkt, out_ewkt))
1017  fprintf(stderr, "\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
1018  CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
1019  lwfree(out_ewkt);
1020  lwgeom_free(geom);
1021  lwgeom_free(geom2);
1022 
1023 }
void lwfree(void *mem)
Definition: lwutil.c:244
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:518
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
LWGEOM * lwgeom_as_curve(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate CURVE* type.
Definition: lwgeom.c:373
Here is the call graph for this function:
Here is the caller graph for this function: