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

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

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

Here is the call graph for this function:

Here is the caller graph for this function: