pre-commit run --all-files

This commit is contained in:
Artem Pavlenko 2022-11-04 09:46:00 +00:00
parent bd018ef5ab
commit 5522cdd201
2 changed files with 37 additions and 18 deletions

View file

@ -62,7 +62,6 @@ struct spatially_equal_visitor
result_type operator()(mapnik::geometry::multi_line_string<double> const& lhs,
mapnik::geometry::multi_line_string<double> const& rhs) const
{
std::size_t size0 = lhs.size();
std::size_t size1 = rhs.size();
if (size0 != size1)

View file

@ -8,20 +8,19 @@
#include <mapnik/vertex_adapters.hpp>
#include <mapnik/util/geometry_to_wkt.hpp>
// stl
#include <stdexcept>
// Convenience method for test cases
void simplify(std::string const& wkt_in, double tolerance, std::string const& method, std::string const& expected)
{
//grab the geom
// grab the geom
mapnik::geometry::geometry<double> input;
if (!mapnik::from_wkt(wkt_in , input))
if (!mapnik::from_wkt(wkt_in, input))
{
throw std::runtime_error("Failed to parse WKT");
}
//setup the generalization for LineStings
// setup the generalization for LineStings
if (mapnik::geometry::geometry_type(input) == mapnik::geometry::geometry_types::LineString)
{
mapnik::geometry::line_string<double> line = input.get<mapnik::geometry::line_string<double>>();
@ -83,10 +82,21 @@ TEST_CASE("converters")
"douglas-peucker",
std::string("LINESTRING(0 0,0 -10,-5 7,4 6)"));
simplify(std::string("LINESTRING(19.1425676643848 48.3706356666503,19.1425502300262 48.3706623938922,19.1425006091595 48.3706410120998,19.1425113379955 48.3706784302306,19.1424550116062 48.3706632848,19.1424348950386 48.3707069392642,19.1423343122005 48.3706632848,19.1422645747662 48.3706677393389,19.1411232948303 48.3712040629718,19.1395568847656 48.3707336664687,19.1382908821106 48.3711042822585,19.1368532180786 48.3705055938728,19.1365367174149 48.3702775202553,19.1362524032593 48.3704022481414,19.1361290216446 48.3702917748863,19.1359841823578 48.3703594843292,19.1358715295792 48.3702953385434,19.1357481479645 48.3703844298907,19.1356247663498 48.3703452297171,19.1356556117535 48.3704075936154,19.1355912387371 48.3704102663522,19.1355885565281 48.3704432300945)"),
0.0001,
"douglas-peucker",
std::string("LINESTRING(19.1425676643848 48.3706356666503,19.1411232948303 48.3712040629718,19.1395568847656 48.3707336664687,19.1382908821106 48.3711042822585,19.1365367174149 48.3702775202553,19.1355885565281 48.3704432300945)"));
simplify(
std::string(
"LINESTRING(19.1425676643848 48.3706356666503,19.1425502300262 48.3706623938922,19.1425006091595 "
"48.3706410120998,19.1425113379955 48.3706784302306,19.1424550116062 48.3706632848,19.1424348950386 "
"48.3707069392642,19.1423343122005 48.3706632848,19.1422645747662 48.3706677393389,19.1411232948303 "
"48.3712040629718,19.1395568847656 48.3707336664687,19.1382908821106 48.3711042822585,19.1368532180786 "
"48.3705055938728,19.1365367174149 48.3702775202553,19.1362524032593 48.3704022481414,19.1361290216446 "
"48.3702917748863,19.1359841823578 48.3703594843292,19.1358715295792 48.3702953385434,19.1357481479645 "
"48.3703844298907,19.1356247663498 48.3703452297171,19.1356556117535 48.3704075936154,19.1355912387371 "
"48.3704102663522,19.1355885565281 48.3704432300945)"),
0.0001,
"douglas-peucker",
std::string("LINESTRING(19.1425676643848 48.3706356666503,19.1411232948303 48.3712040629718,19.1395568847656 "
"48.3707336664687,19.1382908821106 48.3711042822585,19.1365367174149 "
"48.3702775202553,19.1355885565281 48.3704432300945)"));
}
SECTION("simplify-radial-distance")
{
@ -101,10 +111,10 @@ TEST_CASE("converters")
std::string("LINESTRING(0 0,3 5,5 0,6 7,7 0)"));
simplify(
std::string("LINESTRING(10 0,9 -4,7 -7,4 -9,0 -10,-4 -9,-7 -7,-9 -4,-10 0,-9 4,-7 7,-4 9,0 10,4 9,7 7,9 4)"),
40,
"radial-distance",
std::string("LINESTRING(10 0,7 -7,0 -10,-7 -7,-10 0,-7 7,0 10,7 7,9 4)"));
std::string("LINESTRING(10 0,9 -4,7 -7,4 -9,0 -10,-4 -9,-7 -7,-9 -4,-10 0,-9 4,-7 7,-4 9,0 10,4 9,7 7,9 4)"),
40,
"radial-distance",
std::string("LINESTRING(10 0,7 -7,0 -10,-7 -7,-10 0,-7 7,0 10,7 7,9 4)"));
simplify(std::string("LINESTRING(0 0,1 1,2 2,0 10,0 0)"),
100,
@ -120,10 +130,20 @@ TEST_CASE("converters")
"radial-distance",
std::string("LINESTRING(0 0,0 -10,0 0,-5 7,4 6)"));
simplify(std::string("LINESTRING(19.1425676643848 48.3706356666503,19.1425502300262 48.3706623938922,19.1425006091595 48.3706410120998,19.1425113379955 48.3706784302306,19.1424550116062 48.3706632848,19.1424348950386 48.3707069392642,19.1423343122005 48.3706632848,19.1422645747662 48.3706677393389,19.1411232948303 48.3712040629718,19.1395568847656 48.3707336664687,19.1382908821106 48.3711042822585,19.1368532180786 48.3705055938728,19.1365367174149 48.3702775202553,19.1362524032593 48.3704022481414,19.1361290216446 48.3702917748863,19.1359841823578 48.3703594843292,19.1358715295792 48.3702953385434,19.1357481479645 48.3703844298907,19.1356247663498 48.3703452297171,19.1356556117535 48.3704075936154,19.1355912387371 48.3704102663522,19.1355885565281 48.3704432300945)"),
0.000001,
"radial-distance",
std::string("LINESTRING(19.1425676643848 48.3706356666503,19.1411232948303 48.3712040629718,19.1395568847656 48.3707336664687,19.1382908821106 48.3711042822585,19.1368532180786 48.3705055938728,19.1358715295792 48.3702953385434,19.1355885565281 48.3704432300945)"));
simplify(
std::string(
"LINESTRING(19.1425676643848 48.3706356666503,19.1425502300262 48.3706623938922,19.1425006091595 "
"48.3706410120998,19.1425113379955 48.3706784302306,19.1424550116062 48.3706632848,19.1424348950386 "
"48.3707069392642,19.1423343122005 48.3706632848,19.1422645747662 48.3706677393389,19.1411232948303 "
"48.3712040629718,19.1395568847656 48.3707336664687,19.1382908821106 48.3711042822585,19.1368532180786 "
"48.3705055938728,19.1365367174149 48.3702775202553,19.1362524032593 48.3704022481414,19.1361290216446 "
"48.3702917748863,19.1359841823578 48.3703594843292,19.1358715295792 48.3702953385434,19.1357481479645 "
"48.3703844298907,19.1356247663498 48.3703452297171,19.1356556117535 48.3704075936154,19.1355912387371 "
"48.3704102663522,19.1355885565281 48.3704432300945)"),
0.000001,
"radial-distance",
std::string("LINESTRING(19.1425676643848 48.3706356666503,19.1411232948303 48.3712040629718,19.1395568847656 "
"48.3707336664687,19.1382908821106 48.3711042822585,19.1368532180786 "
"48.3705055938728,19.1358715295792 48.3702953385434,19.1355885565281 48.3704432300945)"));
}
}