Skip to content

Commit

Permalink
fix colinear hole bridges race condition, close #11
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Oct 8, 2015
1 parent bfbe17d commit 2d095a6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/earcut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ Earcut<Coord, N>::findHoleBridge(Node* const holeNode, Node* const outerNode) {

if (t >= 0 && A * sign - s - t >= 0) {
tanCur = double(std::abs(double(py - my))) / amx; // tangential
if (tanCur < tanMin && locallyInside(node, holeNode)) {
if ((tanCur < tanMin || (tanCur == tanMin && mx > bx)) &&
locallyInside(node, holeNode)) {
mNode = node;
tanMin = tanCur;
}
Expand Down
18 changes: 18 additions & 0 deletions test/fixtures/issue34.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "geometries.hpp"

namespace mapbox {
namespace fixtures {

const IntegerPolygon issue34 = {
{{1500,0},{0,0},{0,1000},{1500,1000},{1500,0}},
{{804,642},{814,644},{818,676},{850,690},{838,728},{806,728},{772,752},{748,746},{764,724},{728,726},{710,708},{738,656},{764,668},{784,700},{806,702},{792,666},{804,642}},
{{1176,214},{1254,216},{1292,242},{1324,242},{1332,268},{1352,278},{1352,298},{1290,348},{1290,358},{1312,350},{1314,362},{1266,416},{1240,474},{1182,500},{1200,510},{1200,520},{1186,520},{1200,544},{1186,580},{1160,584},{1162,606},{1146,620},{1162,650},{1136,672},{1124,658},{1076,668},{1022,658},{1036,698},{1066,706},{1118,688},{1144,708},{1132,746},{1064,748},{1004,740},{990,668},{966,670},{946,648},{948,632},{962,628},{992,650},{1016,648},{1054,622},{1044,592},{1054,584},{1078,606},{1076,576},{1052,570},{1056,540},{1038,568},{1004,570},{976,526},{996,502},{958,496},{948,454},{962,454},{952,436},{964,390},{986,382},{974,368},{1004,376},{1018,420},{1052,434},{1060,482},{1078,490},{1062,472},{1062,442},{1104,450},{1104,436},{1142,422},{1154,402},{1110,424},{1046,416},{1022,388},{1022,344},{1002,344},{1018,318},{1060,308},{1076,272},{1104,288},{1122,246},{1140,230},{1168,234},{1176,214}},
{{974,698},{986,738},{964,740},{952,714},{974,698}},
{{842,596},{860,626},{848,622},{842,596}},
{{798,572},{792,606},{768,614},{740,580},{758,586},{798,572}},
{{892,584},{894,594},{882,588},{892,584}},
{{870,500},{912,538},{922,586},{908,590},{894,568},{864,564},{854,550},{868,538},{846,520},{854,500},{870,500}}
};

}
}
1 change: 1 addition & 0 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ int main() {
areaTest<int>("water3b", mapbox::fixtures::water3b);
areaTest<int>("water4", mapbox::fixtures::water4);
areaTest<short>("park", mapbox::fixtures::park);
areaTest<int>("issue34", mapbox::fixtures::issue34);

return 0;
}

0 comments on commit 2d095a6

Please sign in to comment.