2015-04-24 12:40:22 +00:00
|
|
|
#include "catch.hpp"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <mapnik/geometry.hpp>
|
|
|
|
#include <mapnik/geometry_centroid.hpp>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
TEST_CASE("labeling") {
|
|
|
|
|
|
|
|
SECTION("algorithms") {
|
|
|
|
|
2015-10-29 15:20:46 +00:00
|
|
|
// reused these for simplicity
|
|
|
|
mapnik::geometry::point<double> centroid;
|
2015-04-24 12:40:22 +00:00
|
|
|
{
|
2015-10-29 15:20:46 +00:00
|
|
|
// single point
|
|
|
|
mapnik::geometry::point<double> pt(10,10);
|
|
|
|
REQUIRE( mapnik::geometry::centroid(pt, centroid));
|
|
|
|
REQUIRE( pt.x == centroid.x);
|
|
|
|
REQUIRE( pt.y == centroid.y);
|
2015-04-24 12:40:22 +00:00
|
|
|
}
|
2015-10-29 15:20:46 +00:00
|
|
|
|
|
|
|
// linestring with three consecutive verticies
|
2015-04-24 12:40:22 +00:00
|
|
|
{
|
2015-10-29 15:20:46 +00:00
|
|
|
mapnik::geometry::line_string<double> line;
|
|
|
|
line.add_coord(0, 0);
|
|
|
|
line.add_coord(25, 25);
|
|
|
|
line.add_coord(50, 50);
|
|
|
|
REQUIRE(mapnik::geometry::centroid(line, centroid));
|
|
|
|
REQUIRE( centroid.x == 25 );
|
|
|
|
REQUIRE( centroid.y == 25 );
|
2015-04-24 12:40:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|