FromWkt() public static method

Creates a new polyline from well-known text (WKT).
public static FromWkt ( string wkt ) : Polyline
wkt string
return Polyline
Example #1
0
        /// <summary>
        /// Creates a new geometry from well-known text (WKT).
        /// </summary>
        /// <param name="wkt"></param>
        /// <returns></returns>
        public static Geometry ToGeometry(string wkt)
        {
            if (wkt == null)
            {
                return(null);
            }

            var s = wkt.ToUpperInvariant().Trim();

            if (s.StartsWith("POINT"))
            {
                return(Point.FromWkt(wkt));
            }
            if (s.StartsWith("MULTIPOINT"))
            {
                return(Multipoint.FromWkt(wkt));
            }
            if (s.StartsWith("MULTILINESTRING"))
            {
                return(Polyline.FromWkt(wkt));
            }
            if (s.StartsWith("MULTIPOLYGON"))
            {
                return(Polygon.FromWkt(wkt));
            }

            throw new ArgumentException("This geometry type is not supported.", nameof(wkt));
        }