PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ test_point_density()

static void test_point_density ( void  )
static

Definition at line 1317 of file cu_algorithm.c.

References LW_PARSER_CHECK_NONE, lwgeom_free(), lwgeom_from_wkt(), lwgeom_to_points(), lwmpoint_free(), and LWMPOINT::ngeoms.

Referenced by algorithms_suite_setup().

1318 {
1319  LWGEOM *geom;
1320  LWMPOINT *mpt;
1321  // char *ewkt;
1322 
1323  /* POLYGON */
1324  geom = lwgeom_from_wkt("POLYGON((1 0,0 1,1 2,2 1,1 0))", LW_PARSER_CHECK_NONE);
1325  mpt = lwgeom_to_points(geom, 100);
1326  CU_ASSERT_EQUAL(mpt->ngeoms,100);
1327  // ewkt = lwgeom_to_ewkt((LWGEOM*)mpt);
1328  // printf("%s\n", ewkt);
1329  // lwfree(ewkt);
1330  lwmpoint_free(mpt);
1331 
1332  mpt = lwgeom_to_points(geom, 1);
1333  CU_ASSERT_EQUAL(mpt->ngeoms,1);
1334  lwmpoint_free(mpt);
1335 
1336  mpt = lwgeom_to_points(geom, 0);
1337  CU_ASSERT_EQUAL(mpt, NULL);
1338  lwmpoint_free(mpt);
1339 
1340  lwgeom_free(geom);
1341 
1342  /* MULTIPOLYGON */
1343  geom = lwgeom_from_wkt("MULTIPOLYGON(((10 0,0 10,10 20,20 10,10 0)),((0 0,5 0,5 5,0 5,0 0)))", LW_PARSER_CHECK_NONE);
1344 
1345  mpt = lwgeom_to_points(geom, 1000);
1346  CU_ASSERT_EQUAL(mpt->ngeoms,1000);
1347  lwmpoint_free(mpt);
1348 
1349  mpt = lwgeom_to_points(geom, 1);
1350  CU_ASSERT_EQUAL(mpt->ngeoms,1);
1351  lwmpoint_free(mpt);
1352 
1353  lwgeom_free(geom);
1354 }
uint32_t ngeoms
Definition: liblwgeom.h:470
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2004
void lwmpoint_free(LWMPOINT *mpt)
Definition: lwmpoint.c:72
LWMPOINT * lwgeom_to_points(const LWGEOM *lwgeom, uint32_t npoints)
Here is the call graph for this function:
Here is the caller graph for this function: