private static XElement ToKmlPolygon(this Polygon geometry, double?z, XElement[] extraElements) { return(new XElement(ns + "MultiGeometry", geometry.GroupRings().Select(p => new XElement(ns + "Polygon", extraElements, p.Select(r => new XElement(ns + (r.IsClockwise() ? "innerBoundaryIs" : "outerBoundaryIs"), new XElement(ns + "LinearRing", new XElement(ns + "coordinates", r.ToCoordinates(z))))))))); }
internal static string ToWkt(this Polygon polygon) { if (polygon == null) { return(null); } if (polygon.rings == null || polygon.rings.Length == 0) { return("MULTIPOLYGON EMPTY"); } return($"MULTIPOLYGON({string.Join(",", polygon.GroupRings().Select(p => $"({string.Join(",", p.Select(r => $"({string.Join(",", r.Select(c => $"{c[0]} {c[1]}"))})"))})"))})"); }