[test] add case for simplify which previously failed within countries test

to the unit test. It checks only for output area.
This commit is contained in:
Barend Gehrels 2018-02-14 12:22:23 +01:00
parent 1ce9583b17
commit 5bf3d27701
2 changed files with 35 additions and 0 deletions

View File

@ -155,6 +155,18 @@ void test_all()
"POLYGON((0 0,0 5,5 5,5 0,4 0,3 0,2 0,1 0,0 0))",
"POLYGON((0 0,0 5,5 5,5 0,0 0))", 0.1);
// Test simplifying away the closing point, and closing it explicitly
std::string const salamina = "POLYGON((2616131.59828 4579307.29099,2616687.86177 4579151.05325,2618172.52982 4578718.79836,2618728.79332 4578522.73574,2620336.91468 4577424.54293,2620522.48427 4576992.50129,2621264.76264 4569815.3917,2621140.75272 4569502.07546,2620491.53745 4568208.96982,2620151.34509 4567855.90928,2612606.55528 4562800.36094,2611833.3301 4562291.50023,2611369.5731 4562174.16117,2610225.54269 4562408.69959,2605896.21638 4564367.29512,2605494.13038 4564641.6634,2605277.94792 4566288.44857,2606019.89233 4569423.46562,2609050.12019 4577424.54293,2614337.90732 4579347.12775,2615296.7021 4579543.34723,2616131.59828 4579307.29099))";
test_geometry<bg::model::polygon<P> >(salamina, 195902881.31854457, 100);
if (boost::is_same<typename bg::coordinate_type<P>::type, double>())
{
test_geometry<bg::model::polygon<P> >(salamina, 194953862.82737178, 200);
test_geometry<bg::model::polygon<P> >(salamina, 191011489.23318481, 500);
}
test_geometry<bg::model::polygon<P> >(salamina, 188663074.84678423, 1000);
test_geometry<bg::model::polygon<P> >(salamina, 181970866.62688220, 2000);
test_geometry<bg::model::polygon<P> >(salamina, 135209933.31675398, 5000);
// // Non-closed version

View File

@ -106,6 +106,17 @@ void check_geometry(Geometry const& geometry,
BOOST_CHECK_EQUAL(out.str(), expected);
}
template <typename Geometry, typename DistanceMeasure>
void check_geometry(Geometry const& geometry,
double expected_area,
DistanceMeasure const& distance)
{
Geometry simplified;
bg::simplify(geometry, simplified, distance);
BOOST_CHECK_CLOSE(bg::area(simplified), expected_area, 0.01);
}
template <typename Geometry, typename DistanceMeasure>
void test_geometry(std::string const& wkt,
@ -181,4 +192,16 @@ void test_geometry(std::string const& wkt,
check_geometry(v, expected, distance, strategy);
}
template <typename Geometry, typename DistanceMeasure>
void test_geometry(std::string const& wkt,
double expected_area,
DistanceMeasure const& distance)
{
Geometry geometry;
bg::read_wkt(wkt, geometry);
bg::correct_closure(geometry);
check_geometry(geometry, expected_area, distance);
}
#endif