Ejemplo n.º 1
0
        /// <summary>
        /// 获取两个矩形的最小外包矩形
        /// </summary>
        /// <param name="mbr1"></param>
        /// <param name="mbr2"></param>
        /// <returns>两个矩形的最小外包矩形</returns>
        public static MyRectangle GetMBR(MyRectangle mbr1, MyRectangle mbr2)
        {
            double minx = Math.Min(mbr1.MinX, mbr2.MinX);
            double maxx = Math.Min(mbr1.MaxX, mbr2.MaxX);
            double miny = Math.Min(mbr1.MinY, mbr2.MinY);
            double maxy = Math.Min(mbr1.MaxY, mbr2.MaxY);

            return(new MyRectangle(minx, maxx, miny, maxy));
        }
Ejemplo n.º 2
0
 public static bool IsPointsPartInRectangle(PointF[] points, MyRectangle rect)
 {
     for (int i = 0; i < points.Length; i++)
     {
         if (IsPointInBox(new MyPoint(points[i].X, points[i].Y), rect) == true)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据矩形盒选择要素,矩形盒坐标位于投影坐标系
        /// </summary>
        /// <param name="box">矩形盒</param>
        internal override List <int> SelectByBox(MyRectangle box)
        {
            List <int> selectedID = new List <int>();

            for (int i = 0; i < polygons.Count; i++)
            {
                polygons[i].Selected = GeometryTools.IsPolygonCompleteInBox(polygons[i], box);
                if (polygons[i].Selected == true)
                {
                    selectedID.Add(i);
                }
            }
            return(selectedID);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 根据矩形盒选择要素,矩形盒坐标位于投影坐标系
        /// </summary>
        /// <param name="box">矩形盒</param>
        internal override List <int> SelectByBox(MyRectangle box)
        {
            List <int> selectedID = new List <int>();

            for (int i = 0; i < myPoints.Count; i++)
            {
                MyPoint pointXY = ETCProjection.LngLat2XY(myPoints[i]);  //投影坐标系下的坐标
                myPoints[i].Selected = GeometryTools.IsPointInBox(pointXY, box);
                if (myPoints[i].Selected == true)
                {
                    selectedID.Add(i);
                }
            }
            return(selectedID);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 判断一个点是否位于矩形盒内
 /// </summary>
 /// <param name="point"></param>
 /// <param name="box"></param>
 /// <returns></returns>
 public static bool IsPointInBox(MyPoint point, MyRectangle box)
 {
     if (point.X < box.MinX || point.X > box.MaxX)
     {
         return(false);
     }
     else if (point.Y < box.MinY || point.Y > box.MaxY)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 根据矩形盒选择要素
 /// </summary>
 /// <param name="box">矩形盒</param>
 internal abstract List <int> SelectByBox(MyRectangle box);