Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,14 @@ private Geometry CreatePolygonal(CoordinateSequence[] sequences)

LinearRing shell = null;
var holes = new List<LinearRing>();
bool reverse = false;

for (int i = 0; i < sequences.Length; i++)
{
var ring = _factory.CreateLinearRing(sequences[i]);

// Shell rings should be CW (https://docs.mapbox.com/vector-tiles/specification/#winding-order)
if (!ring.IsCCW)
if (!ring.IsCCW && !reverse)
{
if (shell != null)
{
Expand All @@ -175,13 +176,14 @@ private Geometry CreatePolygonal(CoordinateSequence[] sequences)
{
if (shell == null)
{
if (sequences.Length == 1)
if (sequences.Length >= 1)
{
// WARNING: this is not according to the spec but tiles exists like this in the wild
// that are rendered just fine by other tools, we can ignore them if we want to but
// should not throw an exception. The solution preferred here is to just read them
// but reverse them so the user gets what they expect according to the spec.
shell = ring.Reverse() as LinearRing;
reverse = true;
}
else
{
Expand All @@ -190,7 +192,7 @@ private Geometry CreatePolygonal(CoordinateSequence[] sequences)
}
else
{
holes.Add(ring);
holes.Add(reverse ? ring.Reverse() as LinearRing : ring);
}
}
}
Expand Down
Loading