Skip to content

Commit

Permalink
ForceOrderPoints: add test from #268 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti committed Jul 11, 2024
1 parent 80dc39a commit 5e10315
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/unit/SFCGAL/capi/sfcgal_cTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,47 @@ BOOST_AUTO_TEST_CASE(testLineSubstring)

BOOST_CHECK(sfcgal_geometry_covers_3d(ls, g2.get()));
}

BOOST_AUTO_TEST_CASE(testForceRHR)
{
sfcgal_set_error_handlers(printf, on_error);

std::string strGeom{"POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,2 1,2 2,1 2,1 1))"};

std::unique_ptr<Geometry> const geom(io::readWkt(strGeom));

sfcgal_geometry_t *rhr = sfcgal_geometry_force_rhr(geom.get());
// retrieve wkb from C api
char *wkbApi;
size_t wkbLen;
sfcgal_geometry_as_text_decim(rhr, 0, &wkbApi, &wkbLen);
std::string strApi(wkbApi, wkbLen);

// check
BOOST_CHECK_EQUAL(strGeom, strApi);
delete[] wkbApi;
}

BOOST_AUTO_TEST_CASE(testForceLHR)
{
sfcgal_set_error_handlers(printf, on_error);

std::string strGeom{"POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,2 1,2 2,1 2,1 1))"};
std::string expectedGeom{
"POLYGON((0 0,5 0,5 5,0 5,0 0),(1 1,1 2,2 2,2 1,1 1))"};

std::unique_ptr<Geometry> const geom(io::readWkt(strGeom));

sfcgal_geometry_t *lhr = sfcgal_geometry_force_lhr(geom.get());
// retrieve wkb from C api
char *wkbApi;
size_t wkbLen;
sfcgal_geometry_as_text_decim(lhr, 0, &wkbApi, &wkbLen);
std::string strApi(wkbApi, wkbLen);

// check
BOOST_CHECK_EQUAL(expectedGeom, strApi);
delete[] wkbApi;
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 5e10315

Please sign in to comment.