zoukankan      html  css  js  c++  java
  • C# Mapxtream创建面

    /// <summary>
            /// 创建区域
            /// </summary>
            ///<param name="rectinfo">区域信息</param>
            ///<param name="points">点集</param>
            private void CreateRect(RectInfo rectinfo,List<DPoint> points)
            {
                try
                {
                    //RectInfo 的定义请看下面
                    Catalog Cat = MapInfo.Engine.Session.Current.Catalog;
                    Table tblTemp = Cat.GetTable(m_RectLayerName);
                    if (tblTemp == null) return;
    
                    FeatureGeometry geometry = new MultiPolygon(this.MapCoordSys, CurveSegmentType.Linear, points.ToArray());
                    CompositeStyle style = GetOpaqueStyle(OpaqueType.NoNe, Color.Red); //GetOpaqueStyle在下面也有
    
                    Feature ftr = new Feature(tblTemp.TableInfo.Columns);
                    ftr.Geometry = geometry;
                    ftr.Style = style;
                    ftr["Name"] = rectinfo.FeatureName; //字段一的内容
                    ftr["Remark"] = rectinfo.Remark; //字段二的内容
                    ftr["Type"] = rectinfo.Type; //字段二的内容
    
                    rectinfo.FeatureKey = tblTemp.InsertFeature(ftr).ToString();
                    tblTemp.TableInfo.WriteTabFile();//保存到文件
    
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
    
     
    
        /// <summary>
        /// 自定义区域信息
        /// </summary>
        public class RectInfo 
        {
            private string _FeatureKey = string.Empty;
            /// <summary>
            /// 图元的KEY值
            /// </summary>
            public string FeatureKey
            {
                get { return _FeatureKey; }
                set
                {
                    if (_FeatureKey != value)
                    {
                        _FeatureKey = value;
                    }
                }
            }
    
    
            private string _FeatureName;
            /// <summary>
            /// 图元名称
            /// </summary>
            public string FeatureName
            {
                get { return _FeatureName; }
                set 
                {
                    if (_FeatureName != value)
                    {
                        _FeatureName = value;
                    }
                }
            }
    
    
            private string _Type;
            /// <summary>
            /// 类型
            /// </summary>
            public string Type
            {
                get { return _Type; }
                set 
                {
                    if (_Type != value)
                    {
                        _Type = value;
                    }
                }
            }
    
            private string _Remark;
            /// <summary>
            /// 备注
            /// </summary>
            public string Remark
            {
                get { return _Remark; }
                set 
                {
                    if (_Remark != value)
                    {
                        _Remark = value;
                    }
                }
            }
    
            /// <summary>
            /// 构造函数
            /// </summary>
            public RectInfo()
            { }
    
            /// <summary>
            /// 构造函数
            /// </summary>
            /// <param name="_FeatureName">名称</param>
            /// <param name="_Type">类型</param>
            /// <param name="_Remark">备注</param>
            public RectInfo(string _FeatureName, string _Type, string _Remark)
            {
                FeatureName = _FeatureName;
                Type = _Type;
                Remark = _Remark;
            }
      }
    
     
    
    /// <summary>
            /// 创建style
            /// </summary>
            /// <param name="opaqueType">不透明类型:ALL全部不透明(白色实心);BORDER边界不透明(填充部分透明);NONE全透明</param>
            /// <param name="borderColor">如果opaqueType=BORDER,此处设定边界颜色</param>
            /// <returns>组合style</returns>
            private CompositeStyle GetOpaqueStyle(OpaqueType opaqueType, System.Drawing.Color borderColor)
            {
                MapInfo.Styles.SimpleInterior simpleInterior;
                if (opaqueType == OpaqueType.ALL)
                    simpleInterior = new MapInfo.Styles.SimpleInterior(); //缺省构造函数是白色实心
                else
                    simpleInterior = new MapInfo.Styles.SimpleInterior(1); //0是线透明,1是面透明
    
                MapInfo.Styles.LineWidth lineWidth = new MapInfo.Styles.LineWidth(1, MapInfo.Styles.LineWidthUnit.Point);
    
                MapInfo.Styles.SimpleLineStyle simpleLineStyle;
                if (opaqueType == OpaqueType.ALL)
                    simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(lineWidth, 1, borderColor);
                else if (opaqueType == OpaqueType.BORDER)
                    simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(lineWidth, 2, borderColor); //2表示填充透明,即能够显示轮廓
                else
                    simpleLineStyle = new MapInfo.Styles.SimpleLineStyle(lineWidth, 0); //0表示全部透明,即连轮廓都看不到
    
                MapInfo.Styles.AreaStyle areaStyle = new MapInfo.Styles.AreaStyle(simpleLineStyle, simpleInterior);
    
                MapInfo.Styles.CompositeStyle compositeStyle = new MapInfo.Styles.CompositeStyle(areaStyle, null, null, null);
    
                return compositeStyle;
            }
    
     
    
        /// <summary>
        /// 区域,线路样式类型
        /// </summary>
        public enum OpaqueType
        {
            /// <summary>
            /// 全部不透明
            /// </summary>
            ALL,
            /// <summary>
            /// 边界不透明
            /// </summary>
            BORDER,
            /// <summary>
            /// 全透明
            /// </summary>
            NoNe
        }
  • 相关阅读:
    [LeetCode] 71. Simplify Path 简化路径
    [LeetCode] 173. Binary Search Tree Iterator 二叉搜索树迭代器
    [LeetCode] 142. Linked List Cycle II 链表中的环 II
    [LeetCode] 141. Linked List Cycle 链表中的环
    读经典——《CLR via C#》(Jeffrey Richter著) 笔记_友元程序集
    读经典——《CLR via C#》(Jeffrey Richter著) 笔记_通过ILDasm.exe查看编译器如何将类型及其成员编译成元数据
    tfs强行签入和删除工作区
    需要提升权限才能运行dism
    读经典——《CLR via C#》(Jeffrey Richter著) 笔记_类型的各种成员
    Jquery 获取URL中的参数
  • 原文地址:https://www.cnblogs.com/googlegis/p/2978832.html
Copyright © 2011-2022 走看看