PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches
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#include "../lwgeom_geos.h"
19
20static void test_lwgeom_node(void)
21{
22 LWGEOM *in, *out;
23 const char *wkt;
24 char *tmp;
25
26 /* Because i don't trust that much prior tests... ;) */
28
29 wkt = "LINESTRING(0 0,5 5, 10 0)";
31 out = lwgeom_node(in);
32 /* printf("%s\n", lwgeom_to_ewkt(out)); */
33 CU_ASSERT_FATAL(out != NULL);
34 CU_ASSERT(lwgeom_same(in, out));
35 lwgeom_free(out); lwgeom_free(in);
36
37 wkt = "MULTILINESTRING((0 0,0 5),(10 0, -10 5))";
39 out = lwgeom_node(in);
40 CU_ASSERT_FATAL(out != NULL);
41 tmp = lwgeom_to_ewkt(out);
42 ASSERT_STRING_EQUAL(tmp, "MULTILINESTRING((0 2.5,-10 5),(0 0,0 2.5),(0 2.5,0 5),(10 0,0 2.5))");
43 lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
44
45 wkt = "MULTILINESTRING((0 0,5 5,10 0, 11 0, 20 0),(10 0, 12 0, 22 0))";
47 out = lwgeom_node(in);
48 CU_ASSERT_FATAL(out != NULL);
49 tmp = lwgeom_to_ewkt(out);
50 /* printf("%s\n", tmp); */
51 ASSERT_STRING_EQUAL(tmp, "MULTILINESTRING((0 0,5 5,10 0),(10 0,11 0,12 0,20 0),(20 0,22 0))");
52 lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
53
54 wkt = "MULTILINESTRING((0 0,5 5,10 0, 11 0, 20 0),(22 0, 12 0, 10 0),(0 5, 5 0))";
56 out = lwgeom_node(in);
57 CU_ASSERT_FATAL(out != NULL);
58 tmp = lwgeom_to_ewkt(out);
59 /* printf("%s\n", tmp); */
61 "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))"
62 );
63 lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
64
65 /* See https://trac.osgeo.org/postgis/ticket/5685 */
66 wkt = "LINESTRING(0 0,0 0)";
68 out = lwgeom_node(in);
69 /* printf("%s\n", lwgeom_to_ewkt(out)); */
70 CU_ASSERT_FATAL(out != NULL);
71 ASSERT_LWGEOM_EQUAL(in, out);
72 lwgeom_free(out); lwgeom_free(in);
73}
74
75static int
77{
78 finishGEOS();
79 return 0;
80}
81
82/*
83** Used by test harness to register the tests in this file.
84*/
85void node_suite_setup(void);
87{
88 CU_pSuite suite = CU_add_suite("noding", NULL, clean_geos_node_suite);
90}
static void test_lwgeom_node(void)
Definition cu_node.c:20
void node_suite_setup(void)
Definition cu_node.c:86
static int clean_geos_node_suite(void)
Definition cu_node.c:76
void cu_error_msg_reset()
#define PG_ADD_TEST(suite, testfunc)
#define ASSERT_STRING_EQUAL(o, e)
#define ASSERT_LWGEOM_EQUAL(o, e)
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
Definition lwgeom.c:619
LWGEOM * lwgeom_node(const LWGEOM *lwgeom_in)
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
#define LW_PARSER_CHECK_NONE
Definition liblwgeom.h:2149
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an allocated string.
Definition lwgeom.c:593
void lwfree(void *mem)
Definition lwutil.c:248
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition lwin_wkt.c:940
This library is the generic geometry handling section of PostGIS.