make mapnik::geometry::line_string<T> an alias to mapbox::geometry::line_string<T>

This commit is contained in:
artemp 2016-06-27 10:23:13 +01:00
parent 19d376b7e6
commit 3b1c7308cc
15 changed files with 368 additions and 384 deletions

View file

@ -123,10 +123,10 @@ public:
if (cmd == mapnik::SEG_CLOSE) if (cmd == mapnik::SEG_CLOSE)
{ {
ring.add_coord(x0, y0); ring.emplace_back(x0, y0);
break; break;
} }
ring.add_coord(x,y); ring.emplace_back(x,y);
} }
poly2.set_exterior_ring(std::move(ring)); poly2.set_exterior_ring(std::move(ring));
// interior rings // interior rings
@ -139,12 +139,12 @@ public:
} }
else if (cmd == mapnik::SEG_CLOSE) else if (cmd == mapnik::SEG_CLOSE)
{ {
ring.add_coord(x0,y0); ring.emplace_back(x0,y0);
poly2.add_hole(std::move(ring)); poly2.add_hole(std::move(ring));
ring.clear(); ring.clear();
continue; continue;
} }
ring.add_coord(x,y); ring.emplace_back(x,y);
} }
std::string expect = expected_+".png"; std::string expect = expected_+".png";
@ -243,11 +243,11 @@ public:
mapnik::geometry::correct(poly); mapnik::geometry::correct(poly);
mapnik::geometry::linear_ring<double> bbox; mapnik::geometry::linear_ring<double> bbox;
bbox.add_coord(extent_.minx(), extent_.miny()); bbox.emplace_back(extent_.minx(), extent_.miny());
bbox.add_coord(extent_.minx(), extent_.maxy()); bbox.emplace_back(extent_.minx(), extent_.maxy());
bbox.add_coord(extent_.maxx(), extent_.maxy()); bbox.emplace_back(extent_.maxx(), extent_.maxy());
bbox.add_coord(extent_.maxx(), extent_.miny()); bbox.emplace_back(extent_.maxx(), extent_.miny());
bbox.add_coord(extent_.minx(), extent_.miny()); bbox.emplace_back(extent_.minx(), extent_.miny());
std::deque<mapnik::geometry::polygon<double> > result; std::deque<mapnik::geometry::polygon<double> > result;
boost::geometry::intersection(bbox, poly, result); boost::geometry::intersection(bbox, poly, result);
@ -291,11 +291,11 @@ public:
mapnik::geometry::correct(poly); mapnik::geometry::correct(poly);
mapnik::geometry::linear_ring<double> bbox; mapnik::geometry::linear_ring<double> bbox;
bbox.add_coord(extent_.minx(), extent_.miny()); bbox.emplace_back(extent_.minx(), extent_.miny());
bbox.add_coord(extent_.minx(), extent_.maxy()); bbox.emplace_back(extent_.minx(), extent_.maxy());
bbox.add_coord(extent_.maxx(), extent_.maxy()); bbox.emplace_back(extent_.maxx(), extent_.maxy());
bbox.add_coord(extent_.maxx(), extent_.miny()); bbox.emplace_back(extent_.maxx(), extent_.miny());
bbox.add_coord(extent_.minx(), extent_.miny()); bbox.emplace_back(extent_.minx(), extent_.miny());
bool valid = true; bool valid = true;
for (unsigned i=0;i<iterations_;++i) for (unsigned i=0;i<iterations_;++i)

View file

@ -24,25 +24,12 @@
#define MAPNIK_GEOMETRY_LINE_STRING_HPP #define MAPNIK_GEOMETRY_LINE_STRING_HPP
// mapnik // mapnik
#include <mapnik/geometry/point.hpp> #include <mapbox/geometry/line_string.hpp>
// stl
#include <vector>
namespace mapnik { namespace geometry { namespace mapnik { namespace geometry {
template <typename T, template <typename...> class Cont = std::vector> template <typename T>
struct line_string : Cont<point<T> > using line_string = mapbox::geometry::line_string<T>;
{
using coordinate_type = T;
using point_type = point<coordinate_type>;
using container_type = Cont<point_type>;
line_string() = default;
explicit line_string(std::size_t size)
: container_type(size) {}
inline std::size_t num_points() const { return container_type::size(); }
inline void add_coord(coordinate_type x, coordinate_type y) { container_type::template emplace_back(x,y);}
};
}} }}
#endif // MAPNIK_GEOMETRY_LINE_STRING_HPP #endif // MAPNIK_GEOMETRY_LINE_STRING_HPP

View file

@ -68,7 +68,7 @@ struct hit_test_visitor
} }
bool operator() (geometry::line_string<double> const& geom) const bool operator() (geometry::line_string<double> const& geom) const
{ {
std::size_t num_points = geom.num_points(); std::size_t num_points = geom.size();
if (num_points > 1) if (num_points > 1)
{ {
for (std::size_t i = 1; i < num_points; ++i) for (std::size_t i = 1; i < num_points; ++i)
@ -92,7 +92,7 @@ struct hit_test_visitor
bool operator() (geometry::polygon<double> const& geom) const bool operator() (geometry::polygon<double> const& geom) const
{ {
auto const& exterior = geom.exterior_ring; auto const& exterior = geom.exterior_ring;
std::size_t num_points = exterior.num_points(); std::size_t num_points = exterior.size();
if (num_points < 4) return false; if (num_points < 4) return false;
bool inside = false; bool inside = false;
for (std::size_t i = 1; i < num_points; ++i) for (std::size_t i = 1; i < num_points; ++i)

View file

@ -313,7 +313,7 @@ struct feature_generator
x = x * (*topo_.tr).scale_x + (*topo_.tr).translate_x; x = x * (*topo_.tr).scale_x + (*topo_.tr).translate_x;
y = y * (*topo_.tr).scale_y + (*topo_.tr).translate_y; y = y * (*topo_.tr).scale_y + (*topo_.tr).translate_y;
} }
multi_point.add_coord(x, y); multi_point.emplace_back(x, y);
} }
feature->set_geometry(std::move(multi_point)); feature->set_geometry(std::move(multi_point));
assign_properties(*feature, multi_pt, tr_); assign_properties(*feature, multi_pt, tr_);
@ -344,7 +344,7 @@ struct feature_generator
x = (px += x) * (*topo_.tr).scale_x + (*topo_.tr).translate_x; x = (px += x) * (*topo_.tr).scale_x + (*topo_.tr).translate_x;
y = (py += y) * (*topo_.tr).scale_y + (*topo_.tr).translate_y; y = (py += y) * (*topo_.tr).scale_y + (*topo_.tr).translate_y;
} }
line_string.add_coord(x,y); line_string.emplace_back(x,y);
} }
} }
} }
@ -383,7 +383,7 @@ struct feature_generator
x = (px += x) * (*topo_.tr).scale_x + (*topo_.tr).translate_x; x = (px += x) * (*topo_.tr).scale_x + (*topo_.tr).translate_x;
y = (py += y) * (*topo_.tr).scale_y + (*topo_.tr).translate_y; y = (py += y) * (*topo_.tr).scale_y + (*topo_.tr).translate_y;
} }
line_string.add_coord(x, y); line_string.emplace_back(x, y);
} }
} }
@ -524,14 +524,14 @@ struct feature_generator
{ {
for (auto const& c : (processed_coords | reversed)) for (auto const& c : (processed_coords | reversed))
{ {
linear_ring.add_coord(c.x, c.y); linear_ring.emplace_back(c.x, c.y);
} }
} }
else else
{ {
for (auto const& c : processed_coords) for (auto const& c : processed_coords)
{ {
linear_ring.add_coord(c.x, c.y); linear_ring.emplace_back(c.x, c.y);
} }
} }
} }

View file

@ -98,7 +98,7 @@ mapnik::geometry::line_string<double> ogr_converter::convert_linestring(OGRLineS
geom.reserve(num_points); geom.reserve(num_points);
for (int i = 0; i < num_points; ++i) for (int i = 0; i < num_points; ++i)
{ {
geom.add_coord(ogr_geom->getX(i), ogr_geom->getY(i)); geom.emplace_back(ogr_geom->getX(i), ogr_geom->getY(i));
} }
return geom; return geom;
} }

View file

@ -114,7 +114,7 @@ mapnik::geometry::geometry<double> shape_io::read_polyline(shape_file::record_ty
{ {
double x = record.read_double(); double x = record.read_double();
double y = record.read_double(); double y = record.read_double();
line.add_coord(x, y); line.emplace_back(x, y);
} }
geom = std::move(line); geom = std::move(line);
} }
@ -144,7 +144,7 @@ mapnik::geometry::geometry<double> shape_io::read_polyline(shape_file::record_ty
{ {
double x = record.read_double(); double x = record.read_double();
double y = record.read_double(); double y = record.read_double();
line.add_coord(x, y); line.emplace_back(x, y);
} }
multi_line.push_back(std::move(line)); multi_line.push_back(std::move(line));
} }

View file

@ -30,9 +30,9 @@ SECTION("point") {
SECTION("linestring") { SECTION("linestring") {
mapnik::geometry::line_string<double> line; mapnik::geometry::line_string<double> line;
line.add_coord(0, 0); line.emplace_back(0, 0);
line.add_coord(25, 25); line.emplace_back(25, 25);
line.add_coord(50, 50); line.emplace_back(50, 50);
mapnik::geometry::point<double> centroid; mapnik::geometry::point<double> centroid;
REQUIRE(mapnik::geometry::centroid(line, centroid)); REQUIRE(mapnik::geometry::centroid(line, centroid));
REQUIRE(centroid.x == 25); REQUIRE(centroid.x == 25);
@ -50,11 +50,11 @@ SECTION("polygon") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0, 0); ring.emplace_back(0, 0);
ring.add_coord(1, 0); ring.emplace_back(1, 0);
ring.add_coord(1, 1); ring.emplace_back(1, 1);
ring.add_coord(0, 1); ring.emplace_back(0, 1);
ring.add_coord(0, 0); ring.emplace_back(0, 0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
mapnik::geometry::point<double> centroid; mapnik::geometry::point<double> centroid;
@ -83,9 +83,9 @@ SECTION("empty polygon") {
SECTION("multi-point") { SECTION("multi-point") {
mapnik::geometry::multi_point<double> geom; mapnik::geometry::multi_point<double> geom;
geom.add_coord(0, 0); geom.emplace_back(0, 0);
geom.add_coord(25, 25); geom.emplace_back(25, 25);
geom.add_coord(50, 50); geom.emplace_back(50, 50);
mapnik::geometry::point<double> centroid; mapnik::geometry::point<double> centroid;
REQUIRE(mapnik::geometry::centroid(geom, centroid)); REQUIRE(mapnik::geometry::centroid(geom, centroid));
REQUIRE(centroid.x == 25); REQUIRE(centroid.x == 25);
@ -104,16 +104,16 @@ SECTION("multi-linestring") {
mapnik::geometry::multi_line_string<double> geom; mapnik::geometry::multi_line_string<double> geom;
{ {
mapnik::geometry::line_string<double> line; mapnik::geometry::line_string<double> line;
line.add_coord(0, 0); line.emplace_back(0, 0);
line.add_coord(0, 25); line.emplace_back(0, 25);
line.add_coord(0, 50); line.emplace_back(0, 50);
geom.emplace_back(std::move(line)); geom.emplace_back(std::move(line));
} }
{ {
mapnik::geometry::line_string<double> line; mapnik::geometry::line_string<double> line;
line.add_coord(0, 0); line.emplace_back(0, 0);
line.add_coord(25, 0); line.emplace_back(25, 0);
line.add_coord(50, 0); line.emplace_back(50, 0);
geom.emplace_back(std::move(line)); geom.emplace_back(std::move(line));
} }
mapnik::geometry::point<double> centroid; mapnik::geometry::point<double> centroid;
@ -126,9 +126,9 @@ SECTION("multi-linestring: one component empty") {
mapnik::geometry::multi_line_string<double> geom; mapnik::geometry::multi_line_string<double> geom;
mapnik::geometry::line_string<double> line; mapnik::geometry::line_string<double> line;
line.add_coord(0, 0); line.emplace_back(0, 0);
line.add_coord(0, 25); line.emplace_back(0, 25);
line.add_coord(0, 50); line.emplace_back(0, 50);
geom.emplace_back(std::move(line)); geom.emplace_back(std::move(line));
geom.emplace_back(); geom.emplace_back();
mapnik::geometry::point<double> centroid; mapnik::geometry::point<double> centroid;
@ -150,22 +150,22 @@ SECTION("multi-polygon") {
{ {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0, 0); ring.emplace_back(0, 0);
ring.add_coord(1, 0); ring.emplace_back(1, 0);
ring.add_coord(1, 1); ring.emplace_back(1, 1);
ring.add_coord(0, 1); ring.emplace_back(0, 1);
ring.add_coord(0, 0); ring.emplace_back(0, 0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
geom.emplace_back(std::move(poly)); geom.emplace_back(std::move(poly));
} }
{ {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(1, 1); ring.emplace_back(1, 1);
ring.add_coord(2, 1); ring.emplace_back(2, 1);
ring.add_coord(2, 2); ring.emplace_back(2, 2);
ring.add_coord(1, 2); ring.emplace_back(1, 2);
ring.add_coord(1, 1); ring.emplace_back(1, 1);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
geom.emplace_back(std::move(poly)); geom.emplace_back(std::move(poly));
} }
@ -181,11 +181,11 @@ SECTION("multi-polygon: one component empty") {
mapnik::geometry::multi_polygon<double> geom; mapnik::geometry::multi_polygon<double> geom;
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0, 0); ring.emplace_back(0, 0);
ring.add_coord(1, 0); ring.emplace_back(1, 0);
ring.add_coord(1, 1); ring.emplace_back(1, 1);
ring.add_coord(0, 1); ring.emplace_back(0, 1);
ring.add_coord(0, 0); ring.emplace_back(0, 0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
geom.emplace_back(std::move(poly)); geom.emplace_back(std::move(poly));
geom.emplace_back(); geom.emplace_back();

View file

@ -27,9 +27,9 @@ void envelope_test()
} }
{ {
line_string<coord_type> line; line_string<coord_type> line;
line.add_coord(0,0); line.emplace_back(0,0);
line.add_coord(1,1); line.emplace_back(1,1);
line.add_coord(2,2); line.emplace_back(2,2);
geometry<coord_type> geom(line); geometry<coord_type> geom(line);
mapnik::box2d<coord_type> bbox = mapnik::geometry::envelope(geom); mapnik::box2d<coord_type> bbox = mapnik::geometry::envelope(geom);
REQUIRE( bbox.minx() == 0 ); REQUIRE( bbox.minx() == 0 );
@ -39,13 +39,13 @@ void envelope_test()
} }
{ {
line_string<coord_type> line; line_string<coord_type> line;
line.add_coord(0,0); line.emplace_back(0,0);
line.add_coord(1,1); line.emplace_back(1,1);
line.add_coord(2,2); line.emplace_back(2,2);
line_string<coord_type> line2; line_string<coord_type> line2;
line2.add_coord(0,0); line2.emplace_back(0,0);
line2.add_coord(-1,-1); line2.emplace_back(-1,-1);
line2.add_coord(-2,-2); line2.emplace_back(-2,-2);
multi_line_string<coord_type> multi_line; multi_line_string<coord_type> multi_line;
multi_line.emplace_back(std::move(line)); multi_line.emplace_back(std::move(line));
multi_line.emplace_back(std::move(line2)); multi_line.emplace_back(std::move(line2));
@ -59,11 +59,11 @@ void envelope_test()
{ {
polygon<coord_type> poly; polygon<coord_type> poly;
linear_ring<coord_type> ring; linear_ring<coord_type> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(-10,0); ring.emplace_back(-10,0);
ring.add_coord(-10,10); ring.emplace_back(-10,10);
ring.add_coord(0,10); ring.emplace_back(0,10);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
geometry<coord_type> geom(poly); geometry<coord_type> geom(poly);
mapnik::box2d<coord_type> bbox = mapnik::geometry::envelope(geom); mapnik::box2d<coord_type> bbox = mapnik::geometry::envelope(geom);
@ -102,18 +102,18 @@ void envelope_test()
// polygon with hole // polygon with hole
polygon<coord_type> poly; polygon<coord_type> poly;
linear_ring<coord_type> ring; linear_ring<coord_type> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(-10,0); ring.emplace_back(-10,0);
ring.add_coord(-10,10); ring.emplace_back(-10,10);
ring.add_coord(0,10); ring.emplace_back(0,10);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
linear_ring<coord_type> hole; linear_ring<coord_type> hole;
hole.add_coord(-7,7); hole.emplace_back(-7,7);
hole.add_coord(-7,3); hole.emplace_back(-7,3);
hole.add_coord(-3,3); hole.emplace_back(-3,3);
hole.add_coord(-3,7); hole.emplace_back(-3,7);
hole.add_coord(-7,7); hole.emplace_back(-7,7);
poly.add_hole(std::move(hole)); poly.add_hole(std::move(hole));
geometry<coord_type> geom(poly); geometry<coord_type> geom(poly);
mapnik::box2d<coord_type> bbox = mapnik::geometry::envelope(poly); mapnik::box2d<coord_type> bbox = mapnik::geometry::envelope(poly);
@ -124,11 +124,11 @@ void envelope_test()
// add another hole inside the first hole // add another hole inside the first hole
// which should be considered a hit // which should be considered a hit
linear_ring<coord_type> fill; linear_ring<coord_type> fill;
fill.add_coord(-6,4); fill.emplace_back(-6,4);
fill.add_coord(-6,6); fill.emplace_back(-6,6);
fill.add_coord(-4,6); fill.emplace_back(-4,6);
fill.add_coord(-4,4); fill.emplace_back(-4,4);
fill.add_coord(-6,4); fill.emplace_back(-6,4);
poly.add_hole(std::move(fill)); poly.add_hole(std::move(fill));
bbox = mapnik::geometry::envelope(poly); bbox = mapnik::geometry::envelope(poly);
REQUIRE( bbox.minx() == -10 ); REQUIRE( bbox.minx() == -10 );

View file

@ -1,4 +1,3 @@
#include "catch.hpp" #include "catch.hpp"
#include <mapnik/geometry.hpp> #include <mapnik/geometry.hpp>
@ -27,17 +26,17 @@ SECTION("hit_test_filter - double") {
} }
{ {
line_string<double> line; line_string<double> line;
line.add_coord(0,0); line.emplace_back(0,0);
line.add_coord(1,1); line.emplace_back(1,1);
line.add_coord(2,2); line.emplace_back(2,2);
geometry<double> geom(line); geometry<double> geom(line);
REQUIRE( mapnik::hit_test(geom,0,0,1.5) ); REQUIRE( mapnik::hit_test(geom,0,0,1.5) );
} }
{ {
line_string<double> line; line_string<double> line;
line.add_coord(0,0); line.emplace_back(0,0);
line.add_coord(1,1); line.emplace_back(1,1);
line.add_coord(2,2); line.emplace_back(2,2);
multi_line_string<double> multi_line; multi_line_string<double> multi_line;
multi_line.emplace_back(std::move(line)); multi_line.emplace_back(std::move(line));
geometry<double> geom(multi_line); geometry<double> geom(multi_line);
@ -46,11 +45,11 @@ SECTION("hit_test_filter - double") {
{ {
polygon<double> poly; polygon<double> poly;
linear_ring<double> ring; linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(-10,0); ring.emplace_back(-10,0);
ring.add_coord(-10,10); ring.emplace_back(-10,10);
ring.add_coord(0,10); ring.emplace_back(0,10);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
geometry<double> geom(poly); geometry<double> geom(poly);
REQUIRE( mapnik::hit_test(geom,-5,5,0) ); REQUIRE( mapnik::hit_test(geom,-5,5,0) );
@ -78,29 +77,29 @@ SECTION("hit_test_filter - double") {
// polygon with hole // polygon with hole
polygon<double> poly; polygon<double> poly;
linear_ring<double> ring; linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(-10,0); ring.emplace_back(-10,0);
ring.add_coord(-10,10); ring.emplace_back(-10,10);
ring.add_coord(0,10); ring.emplace_back(0,10);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
linear_ring<double> hole; linear_ring<double> hole;
hole.add_coord(-7,7); hole.emplace_back(-7,7);
hole.add_coord(-7,3); hole.emplace_back(-7,3);
hole.add_coord(-3,3); hole.emplace_back(-3,3);
hole.add_coord(-3,7); hole.emplace_back(-3,7);
hole.add_coord(-7,7); hole.emplace_back(-7,7);
poly.add_hole(std::move(hole)); poly.add_hole(std::move(hole));
geometry<double> geom(poly); geometry<double> geom(poly);
REQUIRE( !mapnik::hit_test(geom,-5,5,0) ); REQUIRE( !mapnik::hit_test(geom,-5,5,0) );
// add another hole inside the first hole // add another hole inside the first hole
// which should be considered a hit // which should be considered a hit
linear_ring<double> fill; linear_ring<double> fill;
fill.add_coord(-6,4); fill.emplace_back(-6,4);
fill.add_coord(-6,6); fill.emplace_back(-6,6);
fill.add_coord(-4,6); fill.emplace_back(-4,6);
fill.add_coord(-4,4); fill.emplace_back(-4,4);
fill.add_coord(-6,4); fill.emplace_back(-6,4);
poly.add_hole(std::move(fill)); poly.add_hole(std::move(fill));
REQUIRE( mapnik::hit_test(geometry<double>(poly),-5,5,0) ); REQUIRE( mapnik::hit_test(geometry<double>(poly),-5,5,0) );
} }

View file

@ -52,8 +52,8 @@ SECTION("point Infinity") {
SECTION("multi point") { SECTION("multi point") {
mapnik::geometry::multi_point<double> mpt; mapnik::geometry::multi_point<double> mpt;
mpt.add_coord(0,0); mpt.emplace_back(0,0);
mpt.add_coord(1,1); mpt.emplace_back(1,1);
CHECK( mapnik::geometry::is_simple(mpt) ); CHECK( mapnik::geometry::is_simple(mpt) );
} }
@ -64,18 +64,18 @@ SECTION("multi point empty") {
SECTION("line_string") { SECTION("line_string") {
mapnik::geometry::line_string<double> line; mapnik::geometry::line_string<double> line;
line.add_coord(0,0); line.emplace_back(0,0);
line.add_coord(1,1); line.emplace_back(1,1);
CHECK( mapnik::geometry::is_simple(line) ); CHECK( mapnik::geometry::is_simple(line) );
} }
// This fails while is_valid will not fail! // This fails while is_valid will not fail!
SECTION("line_string repeated points") { SECTION("line_string repeated points") {
mapnik::geometry::line_string<double> line; mapnik::geometry::line_string<double> line;
line.add_coord(0,0); line.emplace_back(0,0);
line.add_coord(1,1); line.emplace_back(1,1);
line.add_coord(1,1); line.emplace_back(1,1);
line.add_coord(2,2); line.emplace_back(2,2);
CHECK( !mapnik::geometry::is_simple(line) ); CHECK( !mapnik::geometry::is_simple(line) );
} }
@ -86,11 +86,11 @@ SECTION("line_string empty") {
SECTION("multi_line_string") { SECTION("multi_line_string") {
mapnik::geometry::line_string<double> line1; mapnik::geometry::line_string<double> line1;
line1.add_coord(0,0); line1.emplace_back(0,0);
line1.add_coord(1,1); line1.emplace_back(1,1);
mapnik::geometry::line_string<double> line2; mapnik::geometry::line_string<double> line2;
line2.add_coord(0,1); line2.emplace_back(0,1);
line2.add_coord(1,2); line2.emplace_back(1,2);
mapnik::geometry::multi_line_string<double> lines; mapnik::geometry::multi_line_string<double> lines;
lines.emplace_back(line1); lines.emplace_back(line1);
lines.emplace_back(line2); lines.emplace_back(line2);
@ -112,11 +112,11 @@ SECTION("multi_line_string empty") {
SECTION("polygon") { SECTION("polygon") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
CHECK( mapnik::geometry::is_simple(poly) ); CHECK( mapnik::geometry::is_simple(poly) );
} }
@ -124,11 +124,11 @@ SECTION("polygon") {
SECTION("polygon invalid winding order") { SECTION("polygon invalid winding order") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
CHECK( mapnik::geometry::is_simple(poly) ); CHECK( mapnik::geometry::is_simple(poly) );
} }
@ -138,12 +138,12 @@ SECTION("polygon invalid winding order") {
SECTION("polygon 2 repeated points") { SECTION("polygon 2 repeated points") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
CHECK( !mapnik::geometry::is_simple(poly) ); CHECK( !mapnik::geometry::is_simple(poly) );
} }
@ -152,13 +152,13 @@ SECTION("polygon 2 repeated points") {
SECTION("polygon 3 repeated points") { SECTION("polygon 3 repeated points") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
CHECK( !mapnik::geometry::is_simple(poly) ); CHECK( !mapnik::geometry::is_simple(poly) );
} }
@ -180,11 +180,11 @@ SECTION("polygon that has empty exterior ring") {
SECTION("polygon that has empty interior ring") { SECTION("polygon that has empty interior ring") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
mapnik::geometry::linear_ring<double> ring2; mapnik::geometry::linear_ring<double> ring2;
poly.add_hole(std::move(ring2)); poly.add_hole(std::move(ring2));
@ -208,11 +208,11 @@ SECTION("polygon that has empty exterior ring") {
SECTION("polygon that has empty interior ring") { SECTION("polygon that has empty interior ring") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
mapnik::geometry::linear_ring<double> ring2; mapnik::geometry::linear_ring<double> ring2;
poly.add_hole(std::move(ring2)); poly.add_hole(std::move(ring2));
@ -225,13 +225,13 @@ SECTION("polygon that has empty interior ring") {
SECTION("polygon with spike") { SECTION("polygon with spike") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(2,2); ring.emplace_back(2,2);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
CHECK( mapnik::geometry::is_simple(poly) ); CHECK( mapnik::geometry::is_simple(poly) );
} }
@ -239,18 +239,18 @@ SECTION("polygon with spike") {
SECTION("polygon with hole") { SECTION("polygon with hole") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(3,0); ring.emplace_back(3,0);
ring.add_coord(3,3); ring.emplace_back(3,3);
ring.add_coord(0,3); ring.emplace_back(0,3);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
mapnik::geometry::linear_ring<double> hole; mapnik::geometry::linear_ring<double> hole;
hole.add_coord(1,1); hole.emplace_back(1,1);
hole.add_coord(1,2); hole.emplace_back(1,2);
hole.add_coord(2,2); hole.emplace_back(2,2);
hole.add_coord(2,1); hole.emplace_back(2,1);
hole.add_coord(1,1); hole.emplace_back(1,1);
poly.add_hole(std::move(hole)); poly.add_hole(std::move(hole));
CHECK( mapnik::geometry::is_simple(poly) ); CHECK( mapnik::geometry::is_simple(poly) );
} }
@ -259,18 +259,18 @@ SECTION("polygon with hole") {
SECTION("polygon with hole with invalid winding order") { SECTION("polygon with hole with invalid winding order") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(3,0); ring.emplace_back(3,0);
ring.add_coord(3,3); ring.emplace_back(3,3);
ring.add_coord(0,3); ring.emplace_back(0,3);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
mapnik::geometry::linear_ring<double> hole; mapnik::geometry::linear_ring<double> hole;
hole.add_coord(1,1); hole.emplace_back(1,1);
hole.add_coord(2,1); hole.emplace_back(2,1);
hole.add_coord(2,2); hole.emplace_back(2,2);
hole.add_coord(1,2); hole.emplace_back(1,2);
hole.add_coord(1,1); hole.emplace_back(1,1);
poly.add_hole(std::move(hole)); poly.add_hole(std::move(hole));
CHECK( mapnik::geometry::is_simple(poly) ); CHECK( mapnik::geometry::is_simple(poly) );
} }
@ -279,19 +279,19 @@ SECTION("multi polygon") {
mapnik::geometry::multi_polygon<double> mp; mapnik::geometry::multi_polygon<double> mp;
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
mapnik::geometry::polygon<double> poly2; mapnik::geometry::polygon<double> poly2;
mapnik::geometry::linear_ring<double> ring2; mapnik::geometry::linear_ring<double> ring2;
ring2.add_coord(0,0); ring2.emplace_back(0,0);
ring2.add_coord(-1,0); ring2.emplace_back(-1,0);
ring2.add_coord(-1,-1); ring2.emplace_back(-1,-1);
ring2.add_coord(0,-1); ring2.emplace_back(0,-1);
ring2.add_coord(0,0); ring2.emplace_back(0,0);
poly2.set_exterior_ring(std::move(ring2)); poly2.set_exterior_ring(std::move(ring2));
mp.emplace_back(poly); mp.emplace_back(poly);
mp.emplace_back(poly2); mp.emplace_back(poly2);
@ -302,33 +302,33 @@ SECTION("multi polygon with hole") {
mapnik::geometry::multi_polygon<double> mp; mapnik::geometry::multi_polygon<double> mp;
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(3,0); ring.emplace_back(3,0);
ring.add_coord(3,3); ring.emplace_back(3,3);
ring.add_coord(0,3); ring.emplace_back(0,3);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
mapnik::geometry::linear_ring<double> hole; mapnik::geometry::linear_ring<double> hole;
hole.add_coord(1,1); hole.emplace_back(1,1);
hole.add_coord(1,2); hole.emplace_back(1,2);
hole.add_coord(2,2); hole.emplace_back(2,2);
hole.add_coord(2,1); hole.emplace_back(2,1);
hole.add_coord(1,1); hole.emplace_back(1,1);
poly.add_hole(std::move(hole)); poly.add_hole(std::move(hole));
mapnik::geometry::polygon<double> poly2; mapnik::geometry::polygon<double> poly2;
mapnik::geometry::linear_ring<double> ring2; mapnik::geometry::linear_ring<double> ring2;
ring2.add_coord(0,0); ring2.emplace_back(0,0);
ring2.add_coord(-3,0); ring2.emplace_back(-3,0);
ring2.add_coord(-3,-3); ring2.emplace_back(-3,-3);
ring2.add_coord(0,-3); ring2.emplace_back(0,-3);
ring2.add_coord(0,0); ring2.emplace_back(0,0);
poly2.set_exterior_ring(std::move(ring2)); poly2.set_exterior_ring(std::move(ring2));
mapnik::geometry::linear_ring<double> hole2; mapnik::geometry::linear_ring<double> hole2;
hole2.add_coord(-1,-1); hole2.emplace_back(-1,-1);
hole2.add_coord(-1,-2); hole2.emplace_back(-1,-2);
hole2.add_coord(-2,-2); hole2.emplace_back(-2,-2);
hole2.add_coord(-2,-1); hole2.emplace_back(-2,-1);
hole2.add_coord(-1,-1); hole2.emplace_back(-1,-1);
poly2.add_hole(std::move(hole2)); poly2.add_hole(std::move(hole2));
mp.emplace_back(poly); mp.emplace_back(poly);
mp.emplace_back(poly2); mp.emplace_back(poly2);

View file

@ -123,8 +123,8 @@ SECTION("point Infinity") {
SECTION("multi point") { SECTION("multi point") {
mapnik::geometry::multi_point<double> mpt; mapnik::geometry::multi_point<double> mpt;
mpt.add_coord(0,0); mpt.emplace_back(0,0);
mpt.add_coord(1,1); mpt.emplace_back(1,1);
CHECK( mapnik::geometry::is_valid(mpt) ); CHECK( mapnik::geometry::is_valid(mpt) );
std::string message; std::string message;
CHECK( mapnik::geometry::is_valid(mpt, message) ); CHECK( mapnik::geometry::is_valid(mpt, message) );
@ -148,8 +148,8 @@ SECTION("multi point empty") {
SECTION("line_string") { SECTION("line_string") {
mapnik::geometry::line_string<double> line; mapnik::geometry::line_string<double> line;
line.add_coord(0,0); line.emplace_back(0,0);
line.add_coord(1,1); line.emplace_back(1,1);
CHECK( mapnik::geometry::is_valid(line) ); CHECK( mapnik::geometry::is_valid(line) );
std::string message; std::string message;
CHECK( mapnik::geometry::is_valid(line, message) ); CHECK( mapnik::geometry::is_valid(line, message) );
@ -162,10 +162,10 @@ SECTION("line_string") {
// This shouldn't fail -- test added in case logic ever changes // This shouldn't fail -- test added in case logic ever changes
SECTION("line_string repeated points") { SECTION("line_string repeated points") {
mapnik::geometry::line_string<double> line; mapnik::geometry::line_string<double> line;
line.add_coord(0,0); line.emplace_back(0,0);
line.add_coord(1,1); line.emplace_back(1,1);
line.add_coord(1,1); line.emplace_back(1,1);
line.add_coord(2,2); line.emplace_back(2,2);
CHECK( mapnik::geometry::is_valid(line) ); CHECK( mapnik::geometry::is_valid(line) );
std::string message; std::string message;
CHECK( mapnik::geometry::is_valid(line, message) ); CHECK( mapnik::geometry::is_valid(line, message) );
@ -188,11 +188,11 @@ SECTION("line_string empty") {
SECTION("multi_line_string") { SECTION("multi_line_string") {
mapnik::geometry::line_string<double> line1; mapnik::geometry::line_string<double> line1;
line1.add_coord(0,0); line1.emplace_back(0,0);
line1.add_coord(1,1); line1.emplace_back(1,1);
mapnik::geometry::line_string<double> line2; mapnik::geometry::line_string<double> line2;
line2.add_coord(0,1); line2.emplace_back(0,1);
line2.add_coord(1,2); line2.emplace_back(1,2);
mapnik::geometry::multi_line_string<double> lines; mapnik::geometry::multi_line_string<double> lines;
lines.emplace_back(line1); lines.emplace_back(line1);
lines.emplace_back(line2); lines.emplace_back(line2);
@ -219,11 +219,11 @@ SECTION("multi_line_string empty") {
SECTION("polygon") { SECTION("polygon") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
CHECK( mapnik::geometry::is_valid(poly) ); CHECK( mapnik::geometry::is_valid(poly) );
std::string message; std::string message;
@ -237,11 +237,11 @@ SECTION("polygon") {
SECTION("polygon invalid winding order") { SECTION("polygon invalid winding order") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
CHECK( !mapnik::geometry::is_valid(poly) ); CHECK( !mapnik::geometry::is_valid(poly) );
std::string message; std::string message;
@ -256,12 +256,12 @@ SECTION("polygon invalid winding order") {
SECTION("polygon 2 repeated points") { SECTION("polygon 2 repeated points") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
CHECK( mapnik::geometry::is_valid(poly) ); CHECK( mapnik::geometry::is_valid(poly) );
std::string message; std::string message;
@ -275,13 +275,13 @@ SECTION("polygon 2 repeated points") {
SECTION("polygon 3 repeated points") { SECTION("polygon 3 repeated points") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
CHECK( mapnik::geometry::is_valid(poly) ); CHECK( mapnik::geometry::is_valid(poly) );
std::string message; std::string message;
@ -306,13 +306,13 @@ SECTION("polygon that is empty") {
SECTION("polygon with spike") { SECTION("polygon with spike") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(2,2); ring.emplace_back(2,2);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
CHECK( !mapnik::geometry::is_valid(poly) ); CHECK( !mapnik::geometry::is_valid(poly) );
std::string message; std::string message;
@ -326,18 +326,18 @@ SECTION("polygon with spike") {
SECTION("polygon with hole") { SECTION("polygon with hole") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(3,0); ring.emplace_back(3,0);
ring.add_coord(3,3); ring.emplace_back(3,3);
ring.add_coord(0,3); ring.emplace_back(0,3);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
mapnik::geometry::linear_ring<double> hole; mapnik::geometry::linear_ring<double> hole;
hole.add_coord(1,1); hole.emplace_back(1,1);
hole.add_coord(1,2); hole.emplace_back(1,2);
hole.add_coord(2,2); hole.emplace_back(2,2);
hole.add_coord(2,1); hole.emplace_back(2,1);
hole.add_coord(1,1); hole.emplace_back(1,1);
poly.add_hole(std::move(hole)); poly.add_hole(std::move(hole));
CHECK( mapnik::geometry::is_valid(poly) ); CHECK( mapnik::geometry::is_valid(poly) );
std::string message; std::string message;
@ -351,11 +351,11 @@ SECTION("polygon with hole") {
SECTION("polygon with empty hole") { SECTION("polygon with empty hole") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(3,0); ring.emplace_back(3,0);
ring.add_coord(3,3); ring.emplace_back(3,3);
ring.add_coord(0,3); ring.emplace_back(0,3);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
mapnik::geometry::linear_ring<double> hole; mapnik::geometry::linear_ring<double> hole;
poly.add_hole(std::move(hole)); poly.add_hole(std::move(hole));
@ -372,18 +372,18 @@ SECTION("polygon with empty hole") {
SECTION("polygon with hole with invalid winding order") { SECTION("polygon with hole with invalid winding order") {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(3,0); ring.emplace_back(3,0);
ring.add_coord(3,3); ring.emplace_back(3,3);
ring.add_coord(0,3); ring.emplace_back(0,3);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
mapnik::geometry::linear_ring<double> hole; mapnik::geometry::linear_ring<double> hole;
hole.add_coord(1,1); hole.emplace_back(1,1);
hole.add_coord(2,1); hole.emplace_back(2,1);
hole.add_coord(2,2); hole.emplace_back(2,2);
hole.add_coord(1,2); hole.emplace_back(1,2);
hole.add_coord(1,1); hole.emplace_back(1,1);
poly.add_hole(std::move(hole)); poly.add_hole(std::move(hole));
CHECK( !mapnik::geometry::is_valid(poly) ); CHECK( !mapnik::geometry::is_valid(poly) );
std::string message; std::string message;
@ -398,19 +398,19 @@ SECTION("multi polygon") {
mapnik::geometry::multi_polygon<double> mp; mapnik::geometry::multi_polygon<double> mp;
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(1,0); ring.emplace_back(1,0);
ring.add_coord(1,1); ring.emplace_back(1,1);
ring.add_coord(0,1); ring.emplace_back(0,1);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
mapnik::geometry::polygon<double> poly2; mapnik::geometry::polygon<double> poly2;
mapnik::geometry::linear_ring<double> ring2; mapnik::geometry::linear_ring<double> ring2;
ring2.add_coord(0,0); ring2.emplace_back(0,0);
ring2.add_coord(-1,0); ring2.emplace_back(-1,0);
ring2.add_coord(-1,-1); ring2.emplace_back(-1,-1);
ring2.add_coord(0,-1); ring2.emplace_back(0,-1);
ring2.add_coord(0,0); ring2.emplace_back(0,0);
poly2.set_exterior_ring(std::move(ring2)); poly2.set_exterior_ring(std::move(ring2));
mp.emplace_back(poly); mp.emplace_back(poly);
mp.emplace_back(poly2); mp.emplace_back(poly2);
@ -427,33 +427,33 @@ SECTION("multi polygon with hole") {
mapnik::geometry::multi_polygon<double> mp; mapnik::geometry::multi_polygon<double> mp;
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0,0); ring.emplace_back(0,0);
ring.add_coord(3,0); ring.emplace_back(3,0);
ring.add_coord(3,3); ring.emplace_back(3,3);
ring.add_coord(0,3); ring.emplace_back(0,3);
ring.add_coord(0,0); ring.emplace_back(0,0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
mapnik::geometry::linear_ring<double> hole; mapnik::geometry::linear_ring<double> hole;
hole.add_coord(1,1); hole.emplace_back(1,1);
hole.add_coord(1,2); hole.emplace_back(1,2);
hole.add_coord(2,2); hole.emplace_back(2,2);
hole.add_coord(2,1); hole.emplace_back(2,1);
hole.add_coord(1,1); hole.emplace_back(1,1);
poly.add_hole(std::move(hole)); poly.add_hole(std::move(hole));
mapnik::geometry::polygon<double> poly2; mapnik::geometry::polygon<double> poly2;
mapnik::geometry::linear_ring<double> ring2; mapnik::geometry::linear_ring<double> ring2;
ring2.add_coord(0,0); ring2.emplace_back(0,0);
ring2.add_coord(-3,0); ring2.emplace_back(-3,0);
ring2.add_coord(-3,-3); ring2.emplace_back(-3,-3);
ring2.add_coord(0,-3); ring2.emplace_back(0,-3);
ring2.add_coord(0,0); ring2.emplace_back(0,0);
poly2.set_exterior_ring(std::move(ring2)); poly2.set_exterior_ring(std::move(ring2));
mapnik::geometry::linear_ring<double> hole2; mapnik::geometry::linear_ring<double> hole2;
hole2.add_coord(-1,-1); hole2.emplace_back(-1,-1);
hole2.add_coord(-1,-2); hole2.emplace_back(-1,-2);
hole2.add_coord(-2,-2); hole2.emplace_back(-2,-2);
hole2.add_coord(-2,-1); hole2.emplace_back(-2,-1);
hole2.add_coord(-1,-1); hole2.emplace_back(-1,-1);
poly2.add_hole(std::move(hole2)); poly2.add_hole(std::move(hole2));
mp.emplace_back(poly); mp.emplace_back(poly);
mp.emplace_back(poly2); mp.emplace_back(poly2);

View file

@ -34,7 +34,7 @@ SECTION("geometry collection") {
mapnik::geometry::geometry_collection<double> geom; mapnik::geometry::geometry_collection<double> geom;
mapnik::geometry::multi_line_string<double> mls; mapnik::geometry::multi_line_string<double> mls;
mapnik::geometry::line_string<double> line; mapnik::geometry::line_string<double> line;
line.add_coord(0, 0); line.emplace_back(0, 0);
mls.emplace_back(std::move(line)); mls.emplace_back(std::move(line));
geom.emplace_back(std::move(mls)); geom.emplace_back(std::move(mls));
REQUIRE(!mapnik::geometry::has_empty(geom)); REQUIRE(!mapnik::geometry::has_empty(geom));
@ -55,9 +55,9 @@ SECTION("linestring") {
} }
{ {
mapnik::geometry::line_string<double> line; mapnik::geometry::line_string<double> line;
line.add_coord(0, 0); line.emplace_back(0, 0);
line.add_coord(25, 25); line.emplace_back(25, 25);
line.add_coord(50, 50); line.emplace_back(50, 50);
REQUIRE(!mapnik::geometry::has_empty(line)); REQUIRE(!mapnik::geometry::has_empty(line));
} }
} }
@ -77,11 +77,11 @@ SECTION("polygon") {
{ {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0, 0); ring.emplace_back(0, 0);
ring.add_coord(1, 0); ring.emplace_back(1, 0);
ring.add_coord(1, 1); ring.emplace_back(1, 1);
ring.add_coord(0, 1); ring.emplace_back(0, 1);
ring.add_coord(0, 0); ring.emplace_back(0, 0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
REQUIRE(!mapnik::geometry::has_empty(poly)); REQUIRE(!mapnik::geometry::has_empty(poly));
} }
@ -95,9 +95,9 @@ SECTION("multi-point") {
} }
{ {
mapnik::geometry::multi_point<double> geom; mapnik::geometry::multi_point<double> geom;
geom.add_coord(0, 0); geom.emplace_back(0, 0);
geom.add_coord(25, 25); geom.emplace_back(25, 25);
geom.add_coord(50, 50); geom.emplace_back(50, 50);
REQUIRE(!mapnik::geometry::has_empty(geom)); REQUIRE(!mapnik::geometry::has_empty(geom));
} }
} }
@ -117,7 +117,7 @@ SECTION("multi-linestring") {
{ {
mapnik::geometry::multi_line_string<double> geom; mapnik::geometry::multi_line_string<double> geom;
mapnik::geometry::line_string<double> line; mapnik::geometry::line_string<double> line;
line.add_coord(0, 0); line.emplace_back(0, 0);
geom.emplace_back(std::move(line)); geom.emplace_back(std::move(line));
REQUIRE(!mapnik::geometry::has_empty(geom)); REQUIRE(!mapnik::geometry::has_empty(geom));
} }
@ -141,7 +141,7 @@ SECTION("multi-polygon") {
mapnik::geometry::multi_polygon<double> geom; mapnik::geometry::multi_polygon<double> geom;
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0, 0); ring.emplace_back(0, 0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
geom.emplace_back(std::move(poly)); geom.emplace_back(std::move(poly));
REQUIRE(!mapnik::geometry::has_empty(geom)); REQUIRE(!mapnik::geometry::has_empty(geom));

View file

@ -38,9 +38,9 @@ SECTION("linestring") {
} }
{ {
mapnik::geometry::line_string<double> line; mapnik::geometry::line_string<double> line;
line.add_coord(0, 0); line.emplace_back(0, 0);
line.add_coord(25, 25); line.emplace_back(25, 25);
line.add_coord(50, 50); line.emplace_back(50, 50);
REQUIRE(!mapnik::geometry::is_empty(line)); REQUIRE(!mapnik::geometry::is_empty(line));
} }
} }
@ -60,11 +60,11 @@ SECTION("polygon") {
{ {
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0, 0); ring.emplace_back(0, 0);
ring.add_coord(1, 0); ring.emplace_back(1, 0);
ring.add_coord(1, 1); ring.emplace_back(1, 1);
ring.add_coord(0, 1); ring.emplace_back(0, 1);
ring.add_coord(0, 0); ring.emplace_back(0, 0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
REQUIRE(!mapnik::geometry::is_empty(poly)); REQUIRE(!mapnik::geometry::is_empty(poly));
} }
@ -78,9 +78,9 @@ SECTION("multi-point") {
} }
{ {
mapnik::geometry::multi_point<double> geom; mapnik::geometry::multi_point<double> geom;
geom.add_coord(0, 0); geom.emplace_back(0, 0);
geom.add_coord(25, 25); geom.emplace_back(25, 25);
geom.add_coord(50, 50); geom.emplace_back(50, 50);
REQUIRE(!mapnik::geometry::is_empty(geom)); REQUIRE(!mapnik::geometry::is_empty(geom));
} }
} }

View file

@ -1,4 +1,3 @@
#include "catch.hpp" #include "catch.hpp"
#include <mapnik/geometry_remove_empty.hpp> #include <mapnik/geometry_remove_empty.hpp>
@ -19,9 +18,9 @@ SECTION("multi-linestring") {
using geom_type = mapnik::geometry::multi_line_string<double>; using geom_type = mapnik::geometry::multi_line_string<double>;
geom_type geom; geom_type geom;
mapnik::geometry::line_string<double> line; mapnik::geometry::line_string<double> line;
line.add_coord(0, 0); line.emplace_back(0, 0);
line.add_coord(0, 25); line.emplace_back(0, 25);
line.add_coord(0, 50); line.emplace_back(0, 50);
geom.emplace_back(std::move(line)); geom.emplace_back(std::move(line));
geom.emplace_back(); geom.emplace_back();
@ -37,11 +36,11 @@ SECTION("multi-polygon") {
geom_type geom; geom_type geom;
mapnik::geometry::polygon<double> poly; mapnik::geometry::polygon<double> poly;
mapnik::geometry::linear_ring<double> ring; mapnik::geometry::linear_ring<double> ring;
ring.add_coord(0, 0); ring.emplace_back(0, 0);
ring.add_coord(1, 0); ring.emplace_back(1, 0);
ring.add_coord(1, 1); ring.emplace_back(1, 1);
ring.add_coord(0, 1); ring.emplace_back(0, 1);
ring.add_coord(0, 0); ring.emplace_back(0, 0);
poly.set_exterior_ring(std::move(ring)); poly.set_exterior_ring(std::move(ring));
geom.emplace_back(std::move(poly)); geom.emplace_back(std::move(poly));
geom.emplace_back(); geom.emplace_back();

View file

@ -1,4 +1,3 @@
#include "catch.hpp" #include "catch.hpp"
#include <mapnik/vertex_adapters.hpp> #include <mapnik/vertex_adapters.hpp>
@ -8,10 +7,10 @@ TEST_CASE("vertex_adapters") {
SECTION("polygon") { SECTION("polygon") {
mapnik::geometry::polygon<double> g; mapnik::geometry::polygon<double> g;
g.exterior_ring.add_coord(1,1); g.exterior_ring.emplace_back(1,1);
g.exterior_ring.add_coord(2,2); g.exterior_ring.emplace_back(2,2);
g.exterior_ring.add_coord(100,100); g.exterior_ring.emplace_back(100,100);
g.exterior_ring.add_coord(1,1); g.exterior_ring.emplace_back(1,1);
mapnik::geometry::polygon_vertex_adapter<double> va(g); mapnik::geometry::polygon_vertex_adapter<double> va(g);
double x,y; double x,y;
@ -47,26 +46,26 @@ SECTION("polygon") {
SECTION("polygon with hole") { SECTION("polygon with hole") {
mapnik::geometry::polygon<double> g; mapnik::geometry::polygon<double> g;
g.exterior_ring.add_coord(0,0); g.exterior_ring.emplace_back(0,0);
g.exterior_ring.add_coord(-10,0); g.exterior_ring.emplace_back(-10,0);
g.exterior_ring.add_coord(-10,10); g.exterior_ring.emplace_back(-10,10);
g.exterior_ring.add_coord(0,10); g.exterior_ring.emplace_back(0,10);
g.exterior_ring.add_coord(0,0); g.exterior_ring.emplace_back(0,0);
std::vector<mapnik::geometry::linear_ring<double> > interior_rings; std::vector<mapnik::geometry::linear_ring<double> > interior_rings;
mapnik::geometry::linear_ring<double> hole; mapnik::geometry::linear_ring<double> hole;
hole.add_coord(-7,7); hole.emplace_back(-7,7);
hole.add_coord(-7,3); hole.emplace_back(-7,3);
hole.add_coord(-3,3); hole.emplace_back(-3,3);
hole.add_coord(-3,7); hole.emplace_back(-3,7);
hole.add_coord(-7,7); hole.emplace_back(-7,7);
g.add_hole(std::move(hole)); g.add_hole(std::move(hole));
mapnik::geometry::linear_ring<double> hole_in_hole; mapnik::geometry::linear_ring<double> hole_in_hole;
hole_in_hole.add_coord(-6,4); hole_in_hole.emplace_back(-6,4);
hole_in_hole.add_coord(-6,6); hole_in_hole.emplace_back(-6,6);
hole_in_hole.add_coord(-4,6); hole_in_hole.emplace_back(-4,6);
hole_in_hole.add_coord(-4,4); hole_in_hole.emplace_back(-4,4);
hole_in_hole.add_coord(-6,4); hole_in_hole.emplace_back(-6,4);
g.add_hole(std::move(hole_in_hole)); g.add_hole(std::move(hole_in_hole));
mapnik::geometry::polygon_vertex_adapter<double> va(g); mapnik::geometry::polygon_vertex_adapter<double> va(g);