/// <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)
        {
            //选中要素的样式
            Pen selectedPen = new Pen(Color.Cyan);

            selectedPen.Width = 2.5F;

            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 < polylines.Count; i++)
            {
                //从symbol中获取样式
                LineSymbol ls    = (LineSymbol)fid2Symbol[polylines[i].FID];
                Pen        mypen = ls.GetPen;

                List <int> parts = new List <int>(polylines[i].firstIndex);
                parts.Add(polylines[i].PointCount);
                for (int k = 0; k < polylines[i].firstIndex.Length; k++)  //对于每一条多线的子线段
                {
                    List <PointF> pointfs = new List <PointF>();
                    for (int j = parts[k]; j < parts[k + 1]; j++)
                    {
                        MyPoint xyProjection = ETCProjection.LngLat2XY(polylines[i].Points[j]);
                        double  xScreen      = bounds.Width * (xyProjection.X - xmin) / (xmax - xmin);
                        double  yScreen      = bounds.Height * (xyProjection.Y - ymin) / (ymax - ymin);
                        PointF  p            = new PointF((float)xScreen, bounds.Height - (float)yScreen);
                        pointfs.Add(p);
                    }
                    if (GeometryTools.IsPointsPartInRectangle(pointfs.ToArray(), new MyRectangle(bounds.X, bounds.Width, bounds.Y, bounds.Height)) == true)
                    {
                        if (polylines[i].Selected == false)
                        {
                            g.DrawLines(mypen, pointfs.ToArray());
                        }
                        else
                        {
                            g.DrawLines(selectedPen, pointfs.ToArray());
                        }
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 简单渲染时的绘制要素
        /// </summary>
        /// <param name="g"></param>
        /// <param name="bounds"></param>
        /// <param name="centerPos"></param>
        /// <param name="scale"></param>
        /// <param name="symbol"></param>
        internal override void DrawSpaceData(Graphics g, Rectangle bounds, PointF centerPos, double scale, Symbol symbol)
        {
            //选中要素的样式
            Pen selectedPen = new Pen(Color.Cyan);

            selectedPen.Width = 2.5F;
            //从symbol中获取样式
            PolygonSymbol ps      = (PolygonSymbol)symbol;
            Pen           mypen   = ps.LineStyle.GetPen;
            Brush         mybrush = new SolidBrush(ps.GetColor());

            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 < polygons.Count; i++)
            {
                List <int> parts = new List <int>(polygons[i].firstIndex);
                parts.Add(polygons[i].PointCount);
                for (int k = 0; k < polygons[i].firstIndex.Length; k++)  //对于每一个MultiPolygon的子多边形
                {
                    List <PointF> pointfs = new List <PointF>();
                    for (int j = parts[k]; j < parts[k + 1]; j++)
                    {
                        MyPoint xyProjection = ETCProjection.LngLat2XY(polygons[i].Points[j]);
                        double  xScreen      = bounds.Width * (xyProjection.X - xmin) / (xmax - xmin);
                        double  yScreen      = bounds.Height * (xyProjection.Y - ymin) / (ymax - ymin);
                        PointF  p            = new PointF((float)xScreen, bounds.Height - (float)yScreen);
                        pointfs.Add(p);
                    }
                    if (GeometryTools.IsPointsPartInRectangle(pointfs.ToArray(), new MyRectangle(bounds.X, bounds.Width, bounds.Y, bounds.Height)) == true)
                    {
                        g.DrawPolygon(mypen, pointfs.ToArray());
                        g.FillPolygon(mybrush, pointfs.ToArray());
                    }
                }
            }
            for (int i = 0; i < polygons.Count; i++)
            {
                if (polygons[i].Selected == true)
                {
                    List <int> parts = new List <int>(polygons[i].firstIndex);
                    parts.Add(polygons[i].PointCount);
                    for (int k = 0; k < polygons[i].firstIndex.Length; k++)  //对于每一个MultiPolygon的子多边形
                    {
                        List <PointF> pointfs = new List <PointF>();
                        for (int j = parts[k]; j < parts[k + 1]; j++)
                        {
                            MyPoint xyProjection = ETCProjection.LngLat2XY(polygons[i].Points[j]);
                            double  xScreen      = bounds.Width * (xyProjection.X - xmin) / (xmax - xmin);
                            double  yScreen      = bounds.Height * (xyProjection.Y - ymin) / (ymax - ymin);
                            PointF  p            = new PointF((float)xScreen, bounds.Height - (float)yScreen);
                            pointfs.Add(p);
                        }
                        if (GeometryTools.IsPointsPartInRectangle(pointfs.ToArray(), new MyRectangle(bounds.X, bounds.Width, bounds.Y, bounds.Height)) == true)
                        {
                            g.DrawPolygon(selectedPen, pointfs.ToArray());  //画选中多边形的轮廓
                        }
                    }
                }
            }
        }