Skip to content

Commit

Permalink
Merge pull request #15 from tudelft3d/fix/empty-poly-import
Browse files Browse the repository at this point in the history
Fix/empty poly import
  • Loading branch information
ipadjen authored Jan 10, 2024
2 parents 6fc3d30 + c418ec5 commit b3bb4ac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/PolyFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ PolyFeature::PolyFeature(const Polygon_with_attr& poly, const bool checkSimplici
bool isOuterRing = true;
for (auto& ring : poly.polygon.rings()) {
Polygon_2 tempPoly;
const double minDist = 0.0001;
const double minDist = 0.0001; // hardcoded
Point_2 prev(global::largnum, global::largnum);
for (auto& pt: ring.vertices()) {
if (CGAL::squared_distance(pt, prev) > minDist) {
Expand All @@ -84,6 +84,11 @@ PolyFeature::PolyFeature(const Polygon_with_attr& poly, const bool checkSimplici
}
}
geomutils::pop_back_if_equal_to_front(tempPoly);
if (tempPoly.size() < 3) { // Sanity check if it is even a polygon
std::cout << "WARNING: Skipping import of a zero-area polygon" << std::endl;
this->deactivate();
return;
}
if (isOuterRing) {
if (tempPoly.is_clockwise_oriented()) tempPoly.reverse_orientation();
isOuterRing = false;
Expand Down

0 comments on commit b3bb4ac

Please sign in to comment.