This project has moved. For the latest updates, please go here.

Multiple linearRing in InnerBoundary

Oct 25, 2013 at 10:38 AM
Edited Oct 25, 2013 at 10:38 AM
I'm trying to read a kml file with contains a polygon with a outerboundary and innerboundary with multiple linearring to draw some holes into the polygon.
But when I read LinearRing property of InnerBoundary object I retrieve only the last linearRing of kml file. This is a chunk of code I used to read innerboundary linearring

foreach (var folder in kml.Flatten().OfType<Folder>())
            {
                foreach (var placemark in folder.Flatten().OfType<Placemark>())
                {
                  foreach (var polygon in placemark.Flatten().OfType<Polygon>())
                    {
                       foreach(var innerboundary in polygon.InnerBoundary)
                        {
                               var rings= innerboundary.Flatten().OfType<LinearRing>(); //this retrieve only one linering
                        }
                    }
                  }
                }
Oct 28, 2013 at 8:38 AM
I think I have found the bug, not in my code but in the library
In the source code the innerboundary object is defined with only one LinearRing and not with a list of linearring.
So when the kml file is deserialized, only the last linearring of innerboundary was read

There is someone that can patch this bug?
Jun 30, 2016 at 9:30 PM
Hi

I need linearring list for the same reason. I have a polygon that contains multiple linearrings in a single innerboundary. I'm inserting kml content here. Can you add multiple linearring support to sharpkml? Thanks.
<MultiGeometry>
            <Polygon>
                <outerBoundaryIs>
                    <LinearRing>
                        <coordinates>
                        ...
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
                <innerBoundaryIs>>
                    <LinearRing>
                        <coordinates>
                        ... 
                        </coordinates>
                    </LinearRing>
                    <LinearRing>
                        <coordinates>
                        ... 
                        </coordinates>
                    </LinearRing>
                    .
                    .
                    .
                </innerBoundaryIs>
            </Polygon>
        </MultiGeometry>
Coordinator
Jul 1, 2016 at 5:22 AM
Multiple innerBounraryIs elements are now supported in the library, however, the code snippet you posted only contains one.

I think the error is that your innerBoundaryIs element has multiple LinearRing elements, which isn't supported by the spec so each one needs to be wrapped in an innerBoundaryIs element.
Jul 1, 2016 at 6:10 AM
I understand now. Thank you for reply and developing SharpKml.