PostGIS  2.5.0dev-r@@SVN_REVISION@@
static void test_point_density ( void  )
static

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

1235 {
1236  LWGEOM *geom;
1237  LWMPOINT *mpt;
1238  // char *ewkt;
1239 
1240  /* POLYGON */
1241  geom = lwgeom_from_wkt("POLYGON((1 0,0 1,1 2,2 1,1 0))", LW_PARSER_CHECK_NONE);
1242  mpt = lwgeom_to_points(geom, 100);
1243  CU_ASSERT_EQUAL(mpt->ngeoms,100);
1244  // ewkt = lwgeom_to_ewkt((LWGEOM*)mpt);
1245  // printf("%s\n", ewkt);
1246  // lwfree(ewkt);
1247  lwmpoint_free(mpt);
1248 
1249  mpt = lwgeom_to_points(geom, 1);
1250  CU_ASSERT_EQUAL(mpt->ngeoms,1);
1251  lwmpoint_free(mpt);
1252 
1253  mpt = lwgeom_to_points(geom, 0);
1254  CU_ASSERT_EQUAL(mpt, NULL);
1255  lwmpoint_free(mpt);
1256 
1257  lwgeom_free(geom);
1258 
1259  /* MULTIPOLYGON */
1260  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);
1261 
1262  mpt = lwgeom_to_points(geom, 1000);
1263  CU_ASSERT_EQUAL(mpt->ngeoms,1000);
1264  lwmpoint_free(mpt);
1265 
1266  mpt = lwgeom_to_points(geom, 1);
1267  CU_ASSERT_EQUAL(mpt->ngeoms,1);
1268  lwmpoint_free(mpt);
1269 
1270  lwgeom_free(geom);
1271 }
uint32_t ngeoms
Definition: liblwgeom.h:467
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1137
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1998
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: