PostGIS  2.5.0dev-r@@SVN_REVISION@@
static void test_lwgeom_as_curve ( void  )
static

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

954 {
955  LWGEOM *geom;
956  LWGEOM *geom2;
957  char *in_ewkt, *out_ewkt;
958 
959  geom = lwgeom_from_wkt("LINESTRING(0 0, 10 0)", LW_PARSER_CHECK_NONE);
960  geom2 = lwgeom_as_curve(geom);
961  in_ewkt = "COMPOUNDCURVE((0 0,10 0))";
962  out_ewkt = lwgeom_to_ewkt(geom2);
963  if (strcmp(in_ewkt, out_ewkt))
964  fprintf(stderr, "\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
965  CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
966  lwfree(out_ewkt);
967  lwgeom_free(geom);
968  lwgeom_free(geom2);
969 
970  geom = lwgeom_from_wkt("MULTILINESTRING((0 0, 10 0))", LW_PARSER_CHECK_NONE);
971  geom2 = lwgeom_as_curve(geom);
972  in_ewkt = "MULTICURVE((0 0,10 0))";
973  out_ewkt = lwgeom_to_ewkt(geom2);
974  if (strcmp(in_ewkt, out_ewkt))
975  fprintf(stderr, "\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
976  CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
977  lwfree(out_ewkt);
978  lwgeom_free(geom);
979  lwgeom_free(geom2);
980 
981  geom = lwgeom_from_wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))", LW_PARSER_CHECK_NONE);
982  geom2 = lwgeom_as_curve(geom);
983  in_ewkt = "CURVEPOLYGON((0 0,10 0,10 10,0 10,0 0))";
984  out_ewkt = lwgeom_to_ewkt(geom2);
985  if (strcmp(in_ewkt, out_ewkt))
986  fprintf(stderr, "\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
987  CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
988  lwfree(out_ewkt);
989  lwgeom_free(geom);
990  lwgeom_free(geom2);
991 
992  geom = lwgeom_from_wkt("MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0)))", LW_PARSER_CHECK_NONE);
993  geom2 = lwgeom_as_curve(geom);
994  in_ewkt = "MULTISURFACE(((0 0,10 0,10 10,0 10,0 0)))";
995  out_ewkt = lwgeom_to_ewkt(geom2);
996  if (strcmp(in_ewkt, out_ewkt))
997  fprintf(stderr, "\nExp: %s\nObt: %s\n", in_ewkt, out_ewkt);
998  CU_ASSERT_STRING_EQUAL(in_ewkt, out_ewkt);
999  lwfree(out_ewkt);
1000  lwgeom_free(geom);
1001  lwgeom_free(geom2);
1002 
1003 }
void lwfree(void *mem)
Definition: lwutil.c:244
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:549
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1137
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1998
LWGEOM * lwgeom_as_curve(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate CURVE* type.
Definition: lwgeom.c:404

Here is the call graph for this function:

Here is the caller graph for this function: