PostGIS  2.2.8dev-r@@SVN_REVISION@@
cu_triangulate.c
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * http://postgis.net
5  *
6  * Copyright (C) 2012 Sandro Santilli <strk@keybit.net>
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 
20 {
21 #if POSTGIS_GEOS_VERSION >= 34
22  LWGEOM *in, *tmp, *out;
23  char *wkt, *exp_wkt;
24 
25  /* Because i don't trust that much prior tests... ;) */
27 
28  in = lwgeom_from_wkt("MULTIPOINT(10 0, 20 0, 5 5)", LW_PARSER_CHECK_NONE);
29 
30  tmp = lwgeom_delaunay_triangulation(in, 0, 0);
31  lwgeom_free(in);
32  out = lwgeom_normalize(tmp);
33  lwgeom_free(tmp);
34 
35  wkt = lwgeom_to_ewkt(out);
36  lwgeom_free(out);
37 
38  exp_wkt = "GEOMETRYCOLLECTION(POLYGON((5 5,20 0,10 0,5 5)))";
39  if ( strcmp(wkt, exp_wkt) )
40  {
41  fprintf(stderr, "\nExp: %s\nObt: %s\n", exp_wkt, wkt);
42  }
43  CU_ASSERT_STRING_EQUAL(wkt, exp_wkt);
44  lwfree(wkt);
45 
46 #endif /* POSTGIS_GEOS_VERSION >= 33 */
47 }
48 
49 
50 /*
51 ** Used by test harness to register the tests in this file.
52 */
53 void triangulate_suite_setup(void);
55 {
56  CU_pSuite suite = CU_add_suite("triangulate", NULL, NULL);
58 }
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
void cu_error_msg_reset()
LWGEOM * lwgeom_delaunay_triangulation(const LWGEOM *geom, double tolerance, int edgeOnly)
Take vertices of a geometry and build a delaunay triangulation on them.
#define PG_ADD_TEST(suite, testfunc)
LWGEOM * lwgeom_normalize(const LWGEOM *geom)
static void test_lwgeom_delaunay_triangulation(void)
void triangulate_suite_setup(void)
This library is the generic geometry handling section of PostGIS.