示例#1
0
        }                                            //图层的注记风格

        #endregion

        #region 方法

        /// <summary>
        /// 构造函数
        /// </summary>
        public Layer()
        {
            Name         = "new_layer"; //默认名称为‘new_layer’
            Visible      = true;
            IsEdit       = false;
            FeatureType  = typeof(PointD);  //默认类型为点
            Box          = new RectangleD();
            Renderer     = new SimpleRenderer(FeatureType);
            LabelVisible = false;
            LabelStyle   = new LabelStyle();
            Table        = new DataTable();
            Table.Columns.Add("ID", typeof(int));
            SelectedItems = new List <int>();
            Features      = new List <Geometry>();
        }
示例#2
0
 public Layer(string name, Type type)
 {
     Name         = name;
     Visible      = true;
     IsEdit       = false;
     FeatureType  = type;  //默认类型为点
     Box          = new RectangleD();
     Renderer     = new SimpleRenderer(FeatureType);
     LabelVisible = false;
     LabelStyle   = new LabelStyle();
     Table        = new DataTable();
     Table.Columns.Add("ID", typeof(int));
     SelectedItems = new List <int>();
     Features      = new List <Geometry>();
 }
示例#3
0
文件: Map.cs 项目: ToaruJ/GISDesgin
        /// <summary>
        /// 简单渲染单个图层
        /// </summary>
        /// <param name="g"></param>
        /// <param name="layer"></param>
        private void RenderAsSimpleRenderer(Graphics g, Layer layer)
        {
            SimpleRenderer sRenderer = layer.Renderer as SimpleRenderer; // 强转,使图层渲染器为唯一值渲染器

            //图层类型为点
            if (layer.FeatureType == typeof(PointD))
            {
                PointSymbol pSymbol = sRenderer.Symbol as PointSymbol;  //强转,使符号为点符号
                for (int i = 0; i < layer.Features.Count; i++)
                {
                    PointD point = layer.Features[i] as PointD;

                    //转换为屏幕坐标,绘制
                    PointD screenPoint = FromMapPoint(point);
                    PointF DrawPoint   = new PointF((float)screenPoint.X, (float)screenPoint.Y);
                    pSymbol.DrawPoint(g, DrawPoint);
                }
            }

            //图层类型为折线
            else if (layer.FeatureType == typeof(Polyline))
            {
                LineSymbol lSymbol = sRenderer.Symbol as LineSymbol;  //强转,使符号为线符号
                for (int i = 0; i < layer.Features.Count; i++)
                {
                    Polyline      line       = layer.Features[i] as Polyline; //获得折线
                    List <PointF> screenLine = new List <PointF>();

                    for (int j = 0; j < line.Data.Count; j++)
                    {
                        PointD point = FromMapPoint(line.Data[j]);                  //坐标转换
                        screenLine.Add(new PointF((float)point.X, (float)point.Y)); //添加到绘制队列
                    }
                    lSymbol.DrawLine(g, screenLine.ToArray());                      //绘制
                }
            }

            //图层类型为复合折线
            else if (layer.FeatureType == typeof(MultiPolyline))
            {
                LineSymbol lSymbol = sRenderer.Symbol as LineSymbol;  //强转,使符号为线符号
                for (int i = 0; i < layer.Features.Count; i++)
                {
                    MultiPolyline lines = layer.Features[i] as MultiPolyline;  //获得复合折线
                    for (int j = 0; j < lines.Data.Count; j++)
                    {
                        Polyline      line       = lines.Data[j];
                        List <PointF> screenLine = new List <PointF>();
                        for (int k = 0; k < line.Data.Count; k++)
                        {
                            PointD point = FromMapPoint(line.Data[k]);                  //坐标转换
                            screenLine.Add(new PointF((float)point.X, (float)point.Y)); //添加到绘制队列
                        }
                        lSymbol.DrawLine(g, screenLine.ToArray());                      //绘制
                    }
                }
            }

            //图层类型为多边形
            else if (layer.FeatureType == typeof(Polygon))
            {
                PolygonSymbol pSymbol = sRenderer.Symbol as PolygonSymbol;  //强转,使符号为面符号
                for (int i = 0; i < layer.Features.Count; i++)
                {
                    Polygon       polygon       = layer.Features[i] as Polygon; //获得折线
                    List <PointF> screenPolygon = new List <PointF>();

                    for (int j = 0; j < polygon.Data.Count; j++)
                    {
                        PointD point = FromMapPoint(polygon.Data[j]);                  //坐标转换
                        screenPolygon.Add(new PointF((float)point.X, (float)point.Y)); //添加到绘制队列
                    }
                    pSymbol.DrawPolygon(g, screenPolygon.ToArray());                   //绘制
                }
            }

            //图层类型为复合多边形
            else if (layer.FeatureType == typeof(MultiPolygon))
            {
                PolygonSymbol pSymbol = sRenderer.Symbol as PolygonSymbol;  //强转,使符号为线符号
                for (int i = 0; i < layer.Features.Count; i++)
                {
                    MultiPolygon polygons = layer.Features[i] as MultiPolygon;  //获得复合折线
                    for (int j = 0; j < polygons.Data.Count; j++)
                    {
                        Polygon       polygon       = polygons.Data[j];
                        List <PointF> screenPolygon = new List <PointF>();
                        for (int k = 0; k < polygon.Data.Count; k++)
                        {
                            PointD point = FromMapPoint(polygon.Data[k]);                  //坐标转换
                            screenPolygon.Add(new PointF((float)point.X, (float)point.Y)); //添加到绘制队列
                        }
                        pSymbol.DrawPolygon(g, screenPolygon.ToArray());                   //绘制
                    }
                }
            }
        }