Ejemplo n.º 1
0
 /// <summary>
 /// 由于多边形创建要求环闭合,需要在调用构造函数前进行检查,故不具备用点数组作为集合的构造函数
 /// </summary>
 /// <param name="ring">单独外环</param>
 public MLPolygon(PolylineD ring)
 {
     featureType = FeatureType.POLYGON;
     mbr[0]      = mbr[1] = ring.GetPoint(0).X;
     mbr[2]      = mbr[3] = ring.GetPoint(0).Y;
     for (int i = 1; i < ring.Count; ++i)
     {
         if (ring.GetPoint(i).X < mbr[0])
         {
             mbr[0] = ring.GetPoint(i).X;
         }
         if (ring.GetPoint(i).X > mbr[1])
         {
             mbr[1] = ring.GetPoint(i).X;
         }
         if (ring.GetPoint(i).Y < mbr[2])
         {
             mbr[2] = ring.GetPoint(i).Y;
         }
         if (ring.GetPoint(i).Y > mbr[3])
         {
             mbr[3] = ring.GetPoint(i).Y;
         }
     }
     pointNum = ring.Count;
     polygon  = new PolygonD(new PolylineD[] { ring });
 }
Ejemplo n.º 2
0
 public MLPolyline(PolylineD segment)
 {
     featureType = FeatureType.POLYLINE;
     mbr[0]      = mbr[1] = segment.GetPoint(0).X;
     mbr[2]      = mbr[3] = segment.GetPoint(0).Y;
     for (int i = 1; i < segment.Count; ++i)
     {
         if (segment.GetPoint(i).X < mbr[0])
         {
             mbr[0] = segment.GetPoint(i).X;
         }
         if (segment.GetPoint(i).X > mbr[1])
         {
             mbr[1] = segment.GetPoint(i).X;
         }
         if (segment.GetPoint(i).Y < mbr[2])
         {
             mbr[2] = segment.GetPoint(i).Y;
         }
         if (segment.GetPoint(i).Y > mbr[3])
         {
             mbr[3] = segment.GetPoint(i).Y;
         }
     }
     pointNum = segment.Count;
     segments = new PolylineD[] { segment };
 }
Ejemplo n.º 3
0
        public MLPolyline(PointD[] points)
        {
            PolylineD segment = new PolylineD(points);

            featureType = FeatureType.POLYLINE;
            mbr[0]      = mbr[1] = points[0].X;
            mbr[2]      = mbr[3] = points[0].Y;
            for (int i = 1; i < points.Length; ++i)
            {
                if (points[i].X < mbr[0])
                {
                    mbr[0] = points[i].X;
                }
                if (points[i].X > mbr[1])
                {
                    mbr[1] = points[i].X;
                }
                if (points[i].Y < mbr[2])
                {
                    mbr[2] = points[i].Y;
                }
                if (points[i].Y > mbr[3])
                {
                    mbr[3] = points[i].Y;
                }
            }
            pointNum = points.Length;
            segments = new PolylineD[] { segment };
        }
Ejemplo n.º 4
0
 public void AddLine(PolylineD pd)
 {
     PolylineD[] ori = segments;
     segments = new PolylineD[ori.Length + 1];
     for (int i = 0; i != ori.Length; ++i)
     {
         segments[i] = ori[i];
     }
     segments[ori.Length] = pd;
 }
Ejemplo n.º 5
0
        public MLPolygon(byte[] feaContent) : base()
        {
            using (MemoryStream ms = new MemoryStream(feaContent))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    featureType = FeatureType.POLYGON;
                    br.BaseStream.Seek(4, SeekOrigin.Current);
                    mbr[0] = br.ReadDouble();
                    mbr[2] = br.ReadDouble();
                    mbr[1] = br.ReadDouble();
                    mbr[3] = br.ReadDouble();
                    int partNum = br.ReadInt32();
                    pointNum = br.ReadInt32();
                    PolylineD[] rings = new PolylineD[partNum];

                    //将part数组后面多加一个元素pointNum,方便计算每个part的长度
                    int[] parts = new int[partNum + 1];
                    for (int i = 0; i < partNum; ++i)
                    {
                        parts[i] = br.ReadInt32();
                    }
                    parts[partNum] = pointNum;

                    double   x, y;
                    PointD[] segPoints;
                    for (int i = 0; i < partNum; ++i)
                    {
                        segPoints = new PointD[parts[i + 1] - parts[i]];
                        for (int j = 0; j < parts[i + 1] - parts[i]; ++j)
                        {
                            x            = br.ReadDouble();
                            y            = br.ReadDouble();
                            segPoints[j] = new PointD(x, y);
                        }
                        rings[i] = new PolylineD(segPoints);
                    }

                    polygon = new PolygonD(rings);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 从shp初始化要素
        /// </summary>
        /// <param name="biReader"></param>
        public MLPolyline(BinaryReader biReader) : base()
        {
            featureType = FeatureType.POLYLINE;
            biReader.BaseStream.Seek(12, SeekOrigin.Current);
            mbr[0] = biReader.ReadDouble();
            mbr[2] = biReader.ReadDouble();
            mbr[1] = biReader.ReadDouble();
            mbr[3] = biReader.ReadDouble();
            int partNum = biReader.ReadInt32();

            pointNum = biReader.ReadInt32();
            segments = new PolylineD[partNum];

            //将part数组后面多加一个元素pointNum,方便计算每个part的长度
            int[] parts = new int[partNum + 1];
            for (int i = 0; i < partNum; ++i)
            {
                parts[i] = biReader.ReadInt32();
            }
            parts[partNum] = pointNum;

            double x, y;

            PointD[] segPoints;
            for (int i = 0; i < partNum; ++i)
            {
                segPoints = new PointD[parts[i + 1] - parts[i]];
                for (int j = 0; j < parts[i + 1] - parts[i]; ++j)
                {
                    x            = biReader.ReadDouble();
                    y            = biReader.ReadDouble();
                    segPoints[j] = new PointD(x, y);
                }
                segments[i] = new PolylineD(segPoints);
            }
        }
Ejemplo n.º 7
0
 public void AddPolygon(PolylineD pd)
 {
     polygon.AddRing(pd);
 }
Ejemplo n.º 8
0
 public void AddRing(PolylineD ring)
 {
     rings.Add(ring);
 }