Ejemplo n.º 1
0
        public Polygon(string wkt)
        {
            InnerRings = new List <CoordinateList>();

            // POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))
            // POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30))

            var wktContent = GetWktContent(wkt);

            var temp = wktContent.Replace("(", "_").Replace(")", "_").Split('_');

            // __35 10, 45 45, 15 40, 10 20, 35 10_, _20 30, 35 35, 30 20, 20 30__

            foreach (var x in temp)
            {
                var value = x.Trim();
                if (value == string.Empty || value == ",")
                {
                    continue;
                }

                if (OuterRing == null)
                {
                    // 35 10, 45 45, 15 40, 10 20, 35 10
                    OuterRing = new CoordinateList(value);
                }
                else
                {
                    // 20 30, 35 35, 30 20, 20 30
                    InnerRings.Add(new CoordinateList(value));
                }
            }
        }
Ejemplo n.º 2
0
        public LineString(string wkt)
        {
            // LINESTRING (30 10, 10 30, 40 40)

            var wktContent = GetWktContent(wkt);

            CoordinateList = new CoordinateList(wktContent);
        }
Ejemplo n.º 3
0
        protected override void FillGeometriesFromWkt(string wkt)
        {
            // MULTIPOINT ((10 40), (40 30), (20 20), (30 10))
            // MULTIPOINT (10 40, 40 30, 20 20, 30 10)

            var wktContent = GetWktContent(wkt);

            if (wktContent.StartsWith("(("))
            { // ((10 40), (40 30), (20 20), (30 10))
                wktContent = wktContent.Remove("(", ")");
            }

            // (10 40, 40 30, 20 20, 30 10)
            var coordinateList = new CoordinateList(wktContent);

            foreach (var coordinate in coordinateList.Coordinates)
            {
                AddGeometry(new Point(coordinate));
            }
        }
Ejemplo n.º 4
0
 public LineString()
 {
     CoordinateList = new CoordinateList();
 }
Ejemplo n.º 5
0
 public Polygon()
 {
     OuterRing  = new CoordinateList();
     InnerRings = new List <CoordinateList>();
 }