Skip to content

Commit 4cf1785

Browse files
tananaevclaude
andcommitted
Skip invalid S2 polygons with crossing edges
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5959d7a commit 4cf1785

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

builder/src/build_index.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,11 @@ static std::vector<std::pair<S2CellId, bool>> cover_polygon(const std::vector<st
158158
}
159159
if (points.size() < 3) return {};
160160

161-
// Build S2Loop (must be CCW)
162-
auto loop = std::make_unique<S2Loop>(points);
161+
// Build S2Loop (must be CCW), skip invalid polygons
162+
S2Error error;
163+
auto loop = std::make_unique<S2Loop>(points, S2Debug::DISABLE);
163164
loop->Normalize();
165+
if (loop->FindValidationError(&error)) return {};
164166

165167
S2Polygon polygon(std::move(loop));
166168

0 commit comments

Comments
 (0)