예제 #1
0
 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)))))))));
 }
예제 #2
0
        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]}"))})"))})"))})");
        }