Skip to content

Commit

Permalink
fix line clipping (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Jul 26, 2016
1 parent bc730b0 commit b9df0ca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion include/mapbox/geojsonvt/clip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ class clipper {
} else if (bk > k2) { // | ---|-->
slice.push_back(intersect<I>(a, b, k2));
slice = newSlice(slices, slice, dist);

} else if (i == len - 2) { // | --> |
slice.push_back(b);
}
// | --> |
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ TEST(Clip, Polylines) {
const detail::vt_line_string points1{ { 0, 0 }, { 50, 0 }, { 50, 10 }, { 20, 10 },
{ 20, 20 }, { 30, 20 }, { 30, 30 }, { 50, 30 },
{ 50, 40 }, { 25, 40 }, { 25, 50 }, { 0, 50 },
{ 0, 60 }, { 25, 60 } };
{ 0, 60 }, { 25, 60 }, { 30, 60 } };

const detail::vt_line_string points2{ { 0, 0 }, { 50, 0 }, { 50, 10 }, { 0, 10 } };

Expand All @@ -97,7 +97,7 @@ TEST(Clip, Polylines) {
{ { 10, 0 }, { 40, 0 } },
{ { 40, 10 }, { 20, 10 }, { 20, 20 }, { 30, 20 }, { 30, 30 }, { 40, 30 } },
{ { 40, 40 }, { 25, 40 }, { 25, 50 }, { 10, 50 } },
{ { 10, 60 }, { 25, 60 } } } };
{ { 10, 60 }, { 25, 60 }, { 30, 60 } } } };

const detail::vt_geometry expected2{ detail::vt_multi_line_string{
{ { 10, 0 }, { 40, 0 } }, { { 40, 10 }, { 10, 10 } } } };
Expand Down

0 comments on commit b9df0ca

Please sign in to comment.