PostGIS  2.5.7dev-r@@SVN_REVISION@@
cu_node.c
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * http://postgis.net
5  *
6  * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU General Public Licence. See the COPYING file.
10  *
11  **********************************************************************/
12 
13 #include "CUnit/Basic.h"
14 #include "cu_tester.h"
15 
16 #include "liblwgeom.h"
17 #include "liblwgeom_internal.h"
18 
19 static void test_lwgeom_node(void)
20 {
21  LWGEOM *in, *out;
22  const char *wkt;
23  char *tmp;
24 
25  /* Because i don't trust that much prior tests... ;) */
27 
28  wkt = "LINESTRING(0 0,5 5, 10 0)";
30  out = lwgeom_node(in);
31  /* printf("%s\n", lwgeom_to_ewkt(out)); */
32  CU_ASSERT(lwgeom_same(in, out));
33  lwgeom_free(out); lwgeom_free(in);
34 
35  wkt = "MULTILINESTRING((0 0,0 5),(10 0, -10 5))";
37  out = lwgeom_node(in);
38  tmp = lwgeom_to_ewkt(out);
39  CU_ASSERT_STRING_EQUAL("MULTILINESTRING((0 2.5,-10 5),(0 0,0 2.5),(0 2.5,0 5),(10 0,0 2.5))", tmp)
40  lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
41 
42  wkt = "MULTILINESTRING((0 0,5 5,10 0, 11 0, 20 0),(10 0, 12 0, 22 0))";
44  out = lwgeom_node(in);
45  tmp = lwgeom_to_ewkt(out);
46  /* printf("%s\n", tmp); */
47  CU_ASSERT_STRING_EQUAL("MULTILINESTRING((0 0,5 5,10 0),(10 0,11 0,12 0,20 0),(20 0,22 0))", tmp);
48  lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
49 
50  wkt = "MULTILINESTRING((0 0,5 5,10 0, 11 0, 20 0),(22 0, 12 0, 10 0),(0 5, 5 0))";
52  out = lwgeom_node(in);
53  tmp = lwgeom_to_ewkt(out);
54  /* printf("%s\n", tmp); */
55  CU_ASSERT_STRING_EQUAL(
56 "MULTILINESTRING((0 0,2.5 2.5),(0 5,2.5 2.5),(2.5 2.5,5 5,10 0),(10 0,11 0,12 0,20 0),(20 0,22 0),(2.5 2.5,5 0))",
57  tmp);
58  lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
59 }
60 
61 /*
62 ** Used by test harness to register the tests in this file.
63 */
64 void node_suite_setup(void);
65 void node_suite_setup(void)
66 {
67  CU_pSuite suite = CU_add_suite("noding", NULL, NULL);
69 }
static void test_lwgeom_node(void)
Definition: cu_node.c:19
void node_suite_setup(void)
Definition: cu_node.c:65
void cu_error_msg_reset()
#define PG_ADD_TEST(suite, testfunc)
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
Definition: lwgeom.c:582
LWGEOM * lwgeom_node(const LWGEOM *lwgeom_in)
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2005
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:556
void lwfree(void *mem)
Definition: lwutil.c:244
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
This library is the generic geometry handling section of PostGIS.