Skip to content

Commit

Permalink
Port fix for mapbox/earcut#29
Browse files Browse the repository at this point in the history
Refs #6
  • Loading branch information
jfirebaugh committed Oct 8, 2015
1 parent 4825b46 commit 423596a
Show file tree
Hide file tree
Showing 4 changed files with 16 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 @@ -683,7 +683,8 @@ Earcut<Coord, N>::getLeftmost(Node* start) {
// check if a diagonal between two polygon nodes is valid (lies in polygon interior)
template <typename Coord, typename N>
bool Earcut<Coord, N>::isValidDiagonal(Node* a, Node* b) {
return !intersectsPolygon(a, a, b) &&
return a->next->i != b->i && a->prev->i != b->i &&
!intersectsPolygon(a, a, b) &&
locallyInside(a, b) && locallyInside(b, a) &&
middleInside(a, a->v, b->v);
}
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/geometries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extern const DoublePolygon dude;
extern const IntegerPolygon empty_square;
extern const DoublePolygon issue16;
extern const DoublePolygon issue17;
extern const DoublePolygon issue29;
extern const IntegerPolygon water_huge;
extern const IntegerPolygon water_huge2;
extern const IntegerPolygon water;
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/issue29.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "geometries.hpp"

namespace mapbox {
namespace fixtures {

const DoublePolygon issue29 = {
{{200.95000055654114,69.90565782485673},{201.73186418809928,76.50881049432792},{204.05247248713854,82.73234962527638},{207.79442497901618,88.23839184455574},{212.7323883100471,92.70045673093409},{218.58296075442922,95.86217257360113},{225.00460918453172,97.53918036725955},{231.66534446463922,97.66082593216561},{238.15796607054654,96.21973398409901},{244.1176358256489,93.27806596420706},{249.2188404462824,88.99822680730722},{253.15628113771672,83.64108043884043},{255.70631344406866,77.51111824424007},{256.73126424155197,70.93641692795792},{256.19351709797047,64.30797780468129},{254.1057433114911,57.996416078653425},{250.56431880965246,52.346517799043795},{245.8112865351897,47.719993951247304},{240.07834375849924,44.33761266223155},{233.71343464441597,42.419284673407674},{227.06488359675492,42.055728640102465},{220.51757991796475,43.257153422775446},{214.45449861431845,45.97523169373744},{209.20995664413203,50.053084840223896},{205.06721924245355,55.271000209450726},{202.29122001552022,61.30178454495035},{201.02451470680535,67.8368895214051}},
{{242.34999892718187,69.90549289577612},{240.7584948063828,76.30057721128688},{236.31611852571368,81.17358751371503},{230.07699953842675,83.34595728587593},{223.55761859836056,82.33733346881347},{218.2910646148026,78.34856240227819},{215.5668820463121,72.34290095195175},{215.9904494531453,65.75019118711353},{219.47497291108593,60.1536534355022},{225.2189893186092,56.88651757836341},{231.8100271829404,56.72041164720431},{237.70269737243652,59.67713584899902},{241.47838292121884,65.0856644153595}},
};

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

Expand Down

0 comments on commit 423596a

Please sign in to comment.