Example #1
0
        /// <summary>
        /// 判断一个多边形是否完全位于矩形盒内
        /// </summary>
        /// <param name="polygon"></param>
        /// <param name="box"></param>
        /// <returns></returns>
        public static bool IsPolygonCompleteInBox(MyMultiPolygon polygon, MyRectangle box)
        {
            int sPointCount = polygon.PointCount;

            for (int i = 0; i < sPointCount; i++)
            {
                MyPoint pointXY = ETCProjection.LngLat2XY(polygon.Points[i]);  //投影坐标系下的坐标
                if (IsPointInBox(pointXY, box) == false)
                {
                    return(false);
                }
            }
            return(true);
        }
Example #2
0
        /// <summary>
        /// 返回一个此MultiPolygon对象的副本
        /// </summary>
        /// <returns></returns>
        public MyMultiPolygon Clone()
        {
            MyMultiPolygon copy = new MyMultiPolygon();

            copy.polygonCount = this.polygonCount;
            copy.selected     = this.selected;
            for (int i = 0; i < this.points.Count; i++)
            {
                copy.points.Add(new MyPoint(this.points[i].X, this.points[i].Y));
            }
            copy.firstIndex = new int[this.firstIndex.Length];
            for (int i = 0; i < this.firstIndex.Length; i++)
            {
                copy.firstIndex[i] = this.firstIndex[i];
            }
            copy.isIsland = new bool[this.isIsland.Length];
            for (int i = 0; i < this.firstIndex.Length; i++)
            {
                copy.isIsland[i] = this.isIsland[i];
            }
            return(copy);
        }
Example #3
0
        /// <summary>
        /// 添加指定复合多边形对象
        /// </summary>
        /// <param name="geo">复合多边形对象</param>
        /// <returns>是否成功添加</returns>
        internal override bool AddGeoObj(object geo)
        {
            try
            {
                MyMultiPolygon polygon = (MyMultiPolygon)geo;
                if (polygons.Count == 0)
                {
                    polygon.FID = 0;
                }
                else
                {
                    polygon.FID = polygons[polygons.Count - 1].FID + 1;
                }
                polygons.Add(polygon);

                //调整minx,maxx,miny,maxy
                if (polygon.MaxX > this.maxX)
                {
                    this.maxX = polygon.MaxX;
                }
                if (polygon.MinX < this.minX)
                {
                    this.minX = polygon.MinX;
                }
                if (polygon.MaxY > this.maxY)
                {
                    this.maxY = polygon.MaxY;
                }
                if (polygon.MinY < this.minY)
                {
                    this.minY = polygon.MinY;
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }