offset_converter: Don't filter out closing and moving segments
This commit is contained in:
parent
2461058ecc
commit
fb5ca1bb8e
2 changed files with 53 additions and 0 deletions
|
@ -129,6 +129,14 @@ struct offset_converter
|
|||
//break; // uncomment this to see all the curls
|
||||
|
||||
vertex2d const& u0 = vertices_[i];
|
||||
|
||||
// End or beginning of a line or ring must not be filtered out
|
||||
// to not to join lines or rings together.
|
||||
if (u0.cmd == SEG_CLOSE || u0.cmd == SEG_MOVETO)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
vertex2d const& u1 = vertices_[i+1];
|
||||
double const dx = u0.x - cur_.x;
|
||||
double const dy = u0.y - cur_.y;
|
||||
|
|
|
@ -336,4 +336,49 @@ SECTION("s curve") {
|
|||
}
|
||||
}
|
||||
|
||||
SECTION("offsect converter does not skip SEG_MOVETO or SEG_CLOSE vertices") {
|
||||
|
||||
const double offset = 0.2;
|
||||
|
||||
fake_path path = {};
|
||||
path.vertices_.emplace_back(-2, -2, mapnik::SEG_MOVETO);
|
||||
path.vertices_.emplace_back( 2, -2, mapnik::SEG_LINETO);
|
||||
path.vertices_.emplace_back( 2, 2, mapnik::SEG_LINETO);
|
||||
path.vertices_.emplace_back(-2, 2, mapnik::SEG_LINETO);
|
||||
path.vertices_.emplace_back(-2, -1.9, mapnik::SEG_LINETO);
|
||||
path.vertices_.emplace_back( 0, 0, mapnik::SEG_CLOSE);
|
||||
path.vertices_.emplace_back(-1.9, -1.9, mapnik::SEG_MOVETO);
|
||||
path.vertices_.emplace_back( 1, -1, mapnik::SEG_LINETO);
|
||||
path.vertices_.emplace_back( 1, 1, mapnik::SEG_LINETO);
|
||||
path.vertices_.emplace_back(-1, 1, mapnik::SEG_LINETO);
|
||||
path.vertices_.emplace_back(-1, -1, mapnik::SEG_LINETO);
|
||||
path.vertices_.emplace_back( 0, 0, mapnik::SEG_CLOSE);
|
||||
path.rewind(0);
|
||||
|
||||
mapnik::offset_converter<fake_path> off_path(path);
|
||||
off_path.set_offset(offset);
|
||||
|
||||
unsigned cmd;
|
||||
double x, y;
|
||||
|
||||
unsigned move_to_count = 0;
|
||||
unsigned close_count = 0;
|
||||
|
||||
while((cmd = off_path.vertex(&x, &y)) != mapnik::SEG_END)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case mapnik::SEG_MOVETO:
|
||||
move_to_count++;
|
||||
break;
|
||||
case mapnik::SEG_CLOSE:
|
||||
close_count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CHECK(move_to_count == 2);
|
||||
CHECK(close_count == 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue