parent
0259ad8041
commit
a30f8ed20c
2 changed files with 58 additions and 1 deletions
|
@ -146,6 +146,12 @@ unsigned polygon_vertex_adapter<T>::vertex(coord_type * x, coord_type * y) const
|
|||
{
|
||||
current_index_ = 0;
|
||||
end_index_ = poly_.interior_rings[rings_itr_ - 1].size();
|
||||
if (end_index_ == 0)
|
||||
{
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
return mapnik::SEG_CLOSE;
|
||||
}
|
||||
point<T> const& coord = poly_.interior_rings[rings_itr_ - 1][current_index_++];
|
||||
*x = coord.x;
|
||||
*y = coord.y;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <mapnik/vertex_adapters.hpp>
|
||||
|
@ -267,4 +266,56 @@ SECTION("polygon with hole") {
|
|||
REQUIRE( y == 0 );
|
||||
}
|
||||
|
||||
SECTION("polygon with empty interior ring") {
|
||||
mapnik::geometry::polygon<double> g;
|
||||
g.exterior_ring.add_coord(-1, -1);
|
||||
g.exterior_ring.add_coord( 1, -1);
|
||||
g.exterior_ring.add_coord( 1, 1);
|
||||
g.exterior_ring.add_coord(-1, 1);
|
||||
g.exterior_ring.add_coord(-1, -1);
|
||||
|
||||
// Emplace empty interior ring
|
||||
mapnik::geometry::linear_ring<double> empty_ring;
|
||||
g.add_hole(std::move(empty_ring));
|
||||
|
||||
mapnik::geometry::polygon_vertex_adapter<double> va(g);
|
||||
double x,y;
|
||||
unsigned cmd;
|
||||
|
||||
cmd = va.vertex(&x,&y);
|
||||
CHECK( cmd == mapnik::SEG_MOVETO );
|
||||
CHECK( x == Approx(-1) );
|
||||
CHECK( y == Approx(-1) );
|
||||
|
||||
cmd = va.vertex(&x,&y);
|
||||
CHECK( cmd == mapnik::SEG_LINETO );
|
||||
CHECK( x == Approx(1) );
|
||||
CHECK( y == Approx(-1) );
|
||||
|
||||
cmd = va.vertex(&x,&y);
|
||||
CHECK( cmd == mapnik::SEG_LINETO );
|
||||
CHECK( x == Approx(1) );
|
||||
CHECK( y == Approx(1) );
|
||||
|
||||
cmd = va.vertex(&x,&y);
|
||||
CHECK( cmd == mapnik::SEG_LINETO );
|
||||
CHECK( x == Approx(-1) );
|
||||
CHECK( y == Approx(1) );
|
||||
|
||||
cmd = va.vertex(&x,&y);
|
||||
CHECK( cmd == mapnik::SEG_CLOSE );
|
||||
CHECK( x == Approx(0) );
|
||||
CHECK( y == Approx(0) );
|
||||
|
||||
cmd = va.vertex(&x,&y);
|
||||
CHECK( cmd == mapnik::SEG_CLOSE );
|
||||
CHECK( x == Approx(0) );
|
||||
CHECK( y == Approx(0) );
|
||||
|
||||
cmd = va.vertex(&x,&y);
|
||||
REQUIRE( cmd == mapnik::SEG_END );
|
||||
REQUIRE( x == Approx(0) );
|
||||
REQUIRE( y == Approx(0) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue