+ more realistic clipping benchmark

This commit is contained in:
artemp 2013-09-17 11:59:38 +01:00
parent c6a093f55a
commit 4143d52c16
2 changed files with 14 additions and 11 deletions

View file

@ -1 +1 @@
MULTIPOLYGON (((30 20, 10 40, 45 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5))) POLYGON ((155 203, 233 454, 315 340, 421 446, 463 324, 559 466, 665 253, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 155 203),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190))

View file

@ -542,10 +542,10 @@ struct test11
for (geometry_type & geom : paths) for (geometry_type & geom : paths)
{ {
poly_clipper clipped(geom,ps, poly_clipper clipped(geom,ps,
agg::clipper_and, agg::clipper_and,
agg::clipper_non_zero, agg::clipper_non_zero,
agg::clipper_non_zero, agg::clipper_non_zero,
1); 1);
clipped.rewind(0); clipped.rewind(0);
unsigned cmd; unsigned cmd;
double x,y; double x,y;
@ -762,6 +762,13 @@ int main( int argc, char** argv)
benchmark(runner,"rule caching using heap allocation"); benchmark(runner,"rule caching using heap allocation");
} }
// polygon/rect clipping
// IN : POLYGON ((155 203, 233 454, 315 340, 421 446, 463 324, 559 466, 665 253, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 155 203),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190))
// RECT : POLYGON ((181 106, 181 470, 631 470, 631 106, 181 106))
// OUT (expected)
// POLYGON ((181 286.6666666666667, 233 454, 315 340, 421 446, 463 324, 559 466, 631 321.3207547169811, 631 234.38686131386862, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 181 238.24444444444444, 181 286.6666666666667),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190))
mapnik::box2d<double> clipping_box(181,106,631,470);
{ {
std::string filename_("benchmark/data/polygon.wkt"); std::string filename_("benchmark/data/polygon.wkt");
std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary); std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary);
@ -769,23 +776,19 @@ int main( int argc, char** argv)
throw std::runtime_error("could not open: '" + filename_ + "'"); throw std::runtime_error("could not open: '" + filename_ + "'");
std::string wkt_in( (std::istreambuf_iterator<char>(in) ), std::string wkt_in( (std::istreambuf_iterator<char>(in) ),
(std::istreambuf_iterator<char>()) ); (std::istreambuf_iterator<char>()) );
mapnik::box2d<double> clipping_box(0,0,40,40); test11 runner(10000,10,wkt_in,clipping_box);
test11 runner(100000,10,wkt_in,clipping_box);
benchmark(runner,"clipping polygon with agg_conv_clipper"); benchmark(runner,"clipping polygon with agg_conv_clipper");
} }
{ {
std::string filename_("benchmark/data/polygon.wkt"); std::string filename_("benchmark/data/polygon.wkt");
std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary); std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary);
if (!in.is_open()) if (!in.is_open())
throw std::runtime_error("could not open: '" + filename_ + "'"); throw std::runtime_error("could not open: '" + filename_ + "'");
std::string wkt_in( (std::istreambuf_iterator<char>(in) ), std::string wkt_in( (std::istreambuf_iterator<char>(in) ),
(std::istreambuf_iterator<char>()) ); (std::istreambuf_iterator<char>()) );
mapnik::box2d<double> clipping_box(0,0,40,40);
test12 runner(100000,10,wkt_in,clipping_box); test12 runner(10000,10,wkt_in,clipping_box);
benchmark(runner,"clipping polygon with mapnik::polygon_clipper"); benchmark(runner,"clipping polygon with mapnik::polygon_clipper");
} }