Example #1
0
        /// <summary>
        /// 唯一值渲染和分级渲染时的绘制要素
        /// </summary>
        /// <param name="g"></param>
        /// <param name="bounds"></param>
        /// <param name="centerPos"></param>
        /// <param name="scale"></param>
        /// <param name="fid2Symbol"></param>
        internal override void DrawSpaceData(Graphics g, Rectangle bounds, PointF centerPos, double scale, Dictionary <int, Symbol> fid2Symbol)
        {
            //选中要素的样式
            Brush selectedBrush = new SolidBrush(Color.Cyan);

            MyPoint xyCenter = ETCProjection.LngLat2XY(new MyPoint(centerPos.X, centerPos.Y));
            double  xmin     = xyCenter.X - scale * bounds.Width / 2;
            double  xmax     = xyCenter.X + scale * bounds.Width / 2;
            double  ymin     = xyCenter.Y - scale * bounds.Height / 2;
            double  ymax     = xyCenter.Y + scale * bounds.Height / 2;

            for (int i = 0; i < myPoints.Count; i++)
            {
                //从symbol中获取样式
                PointSymbol ps           = (PointSymbol)fid2Symbol[myPoints[i].FID];
                MyPoint     xyProjection = ETCProjection.LngLat2XY(myPoints[i]);
                double      xScreen      = bounds.Width * (xyProjection.X - xmin) / (xmax - xmin);
                double      yScreen      = bounds.Height * (xyProjection.Y - ymin) / (ymax - ymin);
                if (GeometryTools.IsPointInBox(new MyPoint(xScreen, yScreen), new MyRectangle(bounds.X, bounds.Width, bounds.Y, bounds.Height)) == true)
                {
                    if (myPoints[i].Selected == true)
                    {
                        Rectangle rect = new Rectangle((int)xScreen - 5, bounds.Height - (int)yScreen - 5, 10, 10);
                        g.FillEllipse(selectedBrush, rect);
                    }
                    else
                    {
                        ps.GetSymbol(g, new PointF((float)xScreen, bounds.Height - (float)yScreen));
                    }
                }
            }
        }
Example #2
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);
        }