Merge branch 'offset-converter-topology' of https://github.com/mapycz/mapnik into mapycz-offset-converter-topology
This commit is contained in:
commit
37b7f05180
3 changed files with 54 additions and 1 deletions
|
@ -129,6 +129,14 @@ struct offset_converter
|
||||||
//break; // uncomment this to see all the curls
|
//break; // uncomment this to see all the curls
|
||||||
|
|
||||||
vertex2d const& u0 = vertices_[i];
|
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];
|
vertex2d const& u1 = vertices_[i+1];
|
||||||
double const dx = u0.x - cur_.x;
|
double const dx = u0.x - cur_.x;
|
||||||
double const dy = u0.y - cur_.y;
|
double const dy = u0.y - cur_.y;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit a270d939f1b2b978203b9a91a3cdb4eff9f9f826
|
Subproject commit d374baac6cd72e7de665a27ded9b129e92661e18
|
|
@ -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