示例#1
0
        /// <summary>
        /// µã»÷ʼþ
        /// </summary>
        public override void OnClick()
        {
            DataEditCommon.InitEditEnvironment();
            DataEditCommon.CheckEditState();

            m_pCurrentLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_XianLuoZhu1);
            IFeatureLayer featureLayer = m_pCurrentLayer as IFeatureLayer;

            if (featureLayer == null)
            {
                MessageBox.Show(@"ÏÝÂäÖùͼ²ã¶ªÊ§£¡", "Ìáʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DataEditCommon.g_pMyMapCtrl.CurrentTool = null;
                return;
            }
            else
            {
                if (featureLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon)
                {
                    MessageBox.Show(@"ÏÝÂäÖùͼ²ã¶ªÊ§£¡", "Ìáʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DataEditCommon.g_pMyMapCtrl.CurrentTool = null;
                    return;
                }
            }

            m_pMap = m_hookHelper.FocusMap;
        }
示例#2
0
        private bool IntersectAll(IFeatureClass lineLayer, IPolygon polygon2, List <ziduan> list)
        {
            try
            {
                if (radioBtnKJ.Checked && polygon2 != null)
                {
                    //  根据组合成的面裁剪压力等值线
                    SpatialFilterClass qfilter = new SpatialFilterClass();
                    qfilter.Geometry   = polygon2;
                    qfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

                    IFeatureCursor qfeatureCursor = lineLayer.Search(qfilter, false);

                    if (qfeatureCursor != null)
                    {
                        IFeature       feature       = qfeatureCursor.NextFeature();
                        IGeometryArray geometryArray = new GeometryArrayClass();
                        while (feature != null)
                        {
                            geometryArray.Add(feature.Shape);
                            feature = qfeatureCursor.NextFeature();
                        }

                        IGeometryServer2 geometryServer2 = new GeometryServerClass();
                        IGeometryArray   geometryArray2  = geometryServer2.Intersect(polygon2.SpatialReference, geometryArray, polygon2);
                        //DataEditCommon.DeleteFeatureByWhereClause(lineLayer, "");
                        IFeatureLayer pFeatureLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, EditLayerName) as IFeatureLayer;
                        DataEditCommon.CreateFeature(pFeatureLayer.FeatureClass, geometryArray2, list);
                    }
                }
                return(true);
            }
            catch
            { return(false); }
        }
示例#3
0
        private void btndel_Click(object sender, EventArgs e)
        {
            if (this.Tag == null || this.Text != "修改小柱状")
            {
                MessageBox.Show("请先使用修改按钮选中要删除的小柱状");
                return;
            }
            string bid       = this.Tag.ToString();
            var    AnnoLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_AnnotationXZZ) as IFeatureLayer; //注记图层
            var    lineLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_PolylineXZZ) as IFeatureLayer;   //线源图层
            var    topLayer  = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_PolygonXZZ) as IFeatureLayer;    //外部图形图层

            if (AnnoLayer == null || lineLayer == null || topLayer == null)
            {
                return;
            }
            DataEditCommon.DeleteFeatureByBId(AnnoLayer, bid);
            DataEditCommon.DeleteFeatureByBId(lineLayer, bid);
            DataEditCommon.DeleteFeatureByBId(topLayer, bid);
            FrmNewXZZ frm = new FrmNewXZZ();

            frm.Show(this.Owner);
            frm.Location = this.Location;
            this.Close();
            DataEditCommon.g_pAxMapControl.CurrentTool = null;
        }
示例#4
0
        //获取矿界
        private IPolygon GetPolygon()
        {
            IPolygon      polygon2     = null;
            ILayer        pLayer       = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MINE_BOUNDARY);
            IFeatureLayer polygonLayer = (IFeatureLayer)pLayer;

            IQueryFilter filter = new QueryFilterClass();

            filter.WhereClause = "layer = '预警矿界'";

            IFeatureLayer         featureLayer        = polygonLayer as IFeatureLayer;
            IFeatureCursor        featureCursor       = featureLayer.Search(filter, false);
            ITopologicalOperator2 topologicalOperator = null;

            //  获得矿界组合成面
            if (featureCursor != null)
            {
                ISegmentCollection polygon = new PolygonClass();

                IFeature feature = featureCursor.NextFeature();

                while (feature != null)
                {
                    polygon.AddSegmentCollection((ISegmentCollection)feature.Shape);
                    feature = featureCursor.NextFeature();
                }

                topologicalOperator = (ITopologicalOperator2)polygon;
                topologicalOperator.IsKnownSimple_2 = true;
                topologicalOperator.Simplify();

                polygon2 = (IPolygon)topologicalOperator;
            }
            return(polygon2);
        }
示例#5
0
        /// <summary>
        ///     删除瓦斯信息
        /// </summary>
        /// <params name="bid">绑定ID</params>
        /// <params name="mc">煤层</params>
        private void DelGasGushQuantityPt(string bid, string mc)
        {
            var pLayer        = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_HCGZMWSYCLD);
            var pFeatureLayer = (IFeatureLayer)pLayer;

            DataEditCommon.DeleteFeatureByWhereClause(pFeatureLayer, "bid='" + bid + "' and mc='" + mc + "'");
        }
示例#6
0
        /// <summary>
        ///     20140801SDE中添加瓦斯压力点
        /// </summary>
        private void DrawGasGushQuantityPt(GasPressure gasGushQuantityEntity)
        {
            var    dCoordinateX = Convert.ToDouble(txtCoordinateX.Text);
            var    dCoordinateY = Convert.ToDouble(txtCoordinateY.Text);
            var    dCoordinateZ = Convert.ToDouble(txtCoordinateZ.Text);
            IPoint pt           = new PointClass();

            pt.X = dCoordinateX;
            pt.Y = dCoordinateY;
            pt.Z = dCoordinateZ;
            var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_WSYLD);

            if (pLayer == null)
            {
                MessageBox.Show(@"未找到瓦斯压力点图层,无法绘制瓦斯压力点图元。");
                return;
            }
            var       pFeatureLayer = (IFeatureLayer)pLayer;
            IGeometry geometry      = pt;
            var       list          = new List <ziduan>
            {
                new ziduan("bid", gasGushQuantityEntity.BindingId),
                new ziduan("mc", gasGushQuantityEntity.CoalSeams.ToString()),
                new ziduan("addtime", DateTime.Now.ToString(CultureInfo.InvariantCulture))
            };
            var wsyl = gasGushQuantityEntity.GasPressureValue.ToString(CultureInfo.InvariantCulture);
            var cdbg = gasGushQuantityEntity.CoordinateZ.ToString(CultureInfo.InvariantCulture);
            var ms   = gasGushQuantityEntity.Depth.ToString(CultureInfo.InvariantCulture);

            if (DataEditCommon.strLen(cdbg) < DataEditCommon.strLen(ms))
            {
                var count = DataEditCommon.strLen(ms) - DataEditCommon.strLen(cdbg);
                for (var i = 0; i < count; i++)
                {
                    cdbg = " " + cdbg; // // 测点标高
                }
            }
            else if (DataEditCommon.strLen(cdbg) > DataEditCommon.strLen(ms))
            {
                var count = DataEditCommon.strLen(cdbg) - DataEditCommon.strLen(ms);
                for (var i = 0; i < count; i++)
                {
                    ms += " ";
                }
            }

            list.Add(new ziduan("wsyl", wsyl));
            list.Add(new ziduan("cdbg", cdbg));
            list.Add(new ziduan("ms", ms));

            var pfeature = DataEditCommon.CreateNewFeature(pFeatureLayer, geometry, list);

            if (pfeature != null)
            {
                MyMapHelp.Jump(pt);
                DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(
                    (esriViewDrawPhase)34, null, null);
            }
        }
示例#7
0
 public override void OnDblClick()
 {
     if (pFeature != null)
     {
         var AnnoLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_AnnotationXZZ) as IFeatureLayer;//×¢¼Çͼ²ã
         if (AnnoLayer == null)
         {
             return;
         }
         string bid = pFeature.get_Value(pFeature.Fields.FindField("bid")).ToString();
         Form.Text = "ÐÞ¸ÄСÖù×´";
         Form.Tag  = bid;
         IFeatureClass pFeatureClass = AnnoLayer.FeatureClass;
         IQueryFilter  pFilter       = new QueryFilterClass();
         pFilter.WhereClause = "bid='" + bid + "'";
         IFeatureCursor pCursor  = pFeatureClass.Search(pFilter, false);
         IFeature       mFeature = pCursor.NextFeature();
         int            k        = 0;
         int            count    = pFeatureClass.FeatureCount(pFilter);
         System.Collections.Generic.KeyValuePair <int, string>[] listobj = new System.Collections.Generic.KeyValuePair <int, string> [count];
         while (mFeature != null)
         {
             if (k == 0)
             {
                 Form.txtAngle.Text = mFeature.get_Value(mFeature.Fields.FindField("strAngle")).ToString();
                 Form.txtBlc.Text   = mFeature.get_Value(mFeature.Fields.FindField("strScale")).ToString();
                 Form.txtX.Text     = mFeature.get_Value(mFeature.Fields.FindField("strX")).ToString();
                 Form.txtY.Text     = mFeature.get_Value(mFeature.Fields.FindField("strY")).ToString();
             }
             int    index = Convert.ToInt32(mFeature.get_Value(mFeature.Fields.FindField("strIndex")).ToString());
             int    type  = Convert.ToInt32(mFeature.get_Value(mFeature.Fields.FindField("strType")).ToString());
             string str   = mFeature.get_Value(mFeature.Fields.FindField("TextString")).ToString();
             listobj[index - 1] = new System.Collections.Generic.KeyValuePair <int, string>(type, str);
             mFeature           = pCursor.NextFeature();
             k++;
         }
         if (listobj.Length > 0)
         {
             Form.dgrdvZhzzt.RowCount = listobj.Length;
             for (int i = 0; i < listobj.Length - 1; i++)
             {
                 Form.dgrdvZhzzt.Rows[i].Cells[0].Value = listobj[i].Value;
                 DataGridViewComboBoxCell cell = Form.dgrdvZhzzt.Rows[i].Cells[1] as DataGridViewComboBoxCell;
                 if (listobj[i].Key == 0)
                 {
                     cell.Value = "ÑÒ²ã";
                 }
                 else
                 {
                     cell.Value = "ú²ã";
                 }
             }
             Form.txtDBBG.Text = listobj[listobj.Length - 1].Value;
         }
     }
 }
示例#8
0
        /// <summary>
        ///     带参数的构造方法
        /// </summary>
        public FaultageInfoEntering(Faultage faultage)
        {
            InitializeComponent();
            Faultage = faultage;
            // 设置窗体默认属性
            FormDefaultPropertiesSetter.SetEnteringFormDefaultProperties(this, Const_GM.UPDATE_FAULTAGE_INFO);

            // 设置断层信息
            // 断层名称
            txtFaultageName.Text = Faultage.FaultageName;
            // 落差
            txtGap.Text = Faultage.Gap;
            // 倾角
            txtAngle.Text = Faultage.Angle.ToString(CultureInfo.InvariantCulture);
            // 类型
            if (Const_GM.FRONT_FAULTAGE.Equals(Faultage.Type))
            {
                rbtnFrontFaultage.Checked = true;
            }
            else
            {
                rbtnOppositeFaultage.Checked = true;
            }
            // 走向
            txtTrend.Text = Faultage.Trend.ToString(CultureInfo.InvariantCulture);
            // 断距
            txtSeparation.Text = Faultage.Separation;
            // 坐标X
            txtCoordinateX.Text = Faultage.CoordinateX.ToString(CultureInfo.InvariantCulture);
            // 坐标Y
            txtCoordinateY.Text = Faultage.CoordinateY.ToString(CultureInfo.InvariantCulture);
            // 坐标Z
            txtCoordinateZ.Text = Faultage.CoordinateZ.ToString(CultureInfo.InvariantCulture);
            //长度
            var bid          = Faultage.BindingId;
            var pLayer       = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.DEFALUT_EXPOSE_FAULTAGE);
            var featureLayer = (IFeatureLayer)pLayer;

            if (pLayer == null)
            {
                txtLength.Text = @"0";
                return;
            }
            var pFeature = MyMapHelp.FindFeatureByWhereClause(featureLayer, "BID='" + bid + "'");

            if (pFeature != null)
            {
                var pline = (IPolyline)pFeature.Shape;
                if (pline == null)
                {
                    return;
                }
                txtLength.Text = Math.Round(pline.Length).ToString(CultureInfo.InvariantCulture);
            }
        }
示例#9
0
        /// <summary>
        ///     带参数的构造方法
        /// </summary>
        public FaultageInfoEntering(Faultage faultage)
        {
            InitializeComponent();
            Faultage = faultage;

            // 设置断层信息
            // 断层名称
            txtFaultageName.Text = Faultage.name;
            // 落差
            txtGap.Text = Faultage.gap;
            // 倾角
            txtAngle.Text = Faultage.angle.ToString(CultureInfo.InvariantCulture);
            // 类型
            if (Faultage.type == "正断层")
            {
                rbtnFrontFaultage.Checked = true;
            }
            else
            {
                rbtnOppositeFaultage.Checked = true;
            }
            // 走向
            txtTrend.Text = Faultage.trend.ToString(CultureInfo.InvariantCulture);
            // 断距
            txtSeparation.Text = Faultage.separation;
            // 坐标X
            txtCoordinateX.Text = Faultage.coordinate_x.ToString(CultureInfo.InvariantCulture);
            // 坐标Y
            txtCoordinateY.Text = Faultage.coordinate_y.ToString(CultureInfo.InvariantCulture);
            // 坐标Z
            txtCoordinateZ.Text = Faultage.coordinate_z.ToString(CultureInfo.InvariantCulture);
            //长度
            var bid          = Faultage.bid;
            var pLayer       = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.DEFALUT_EXPOSE_FAULTAGE);
            var featureLayer = (IFeatureLayer)pLayer;

            if (pLayer == null)
            {
                txtLength.Text = @"0";
                return;
            }
            var pFeature = MyMapHelp.FindFeatureByWhereClause(featureLayer, "BID='" + bid + "'");

            if (pFeature != null)
            {
                var pline = (IPolyline)pFeature.Shape;
                if (pline == null)
                {
                    return;
                }
                txtLength.Text = Math.Round(pline.Length).ToString(CultureInfo.InvariantCulture);
            }
        }
示例#10
0
        /// <summary>
        ///     图显按钮事件
        /// </summary>
        /// <params name="sender"></params>
        /// <params name="e"></params>
        private void btnMap_Click(object sender, EventArgs e)
        {
            // 获取已选择明细行的索引
            int[] iSelIdxsArr = { ((InferFaultage)gridView1.GetFocusedRow()).id };

            var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.DEFALUT_INFERRED_FAULTAGE);

            if (pLayer == null)
            {
                MessageBox.Show(@"未发现推断断层图层!");
                return;
            }
            var pFeatureLayer = (IFeatureLayer)pLayer;
            var str           = "";

            for (var i = 0; i < iSelIdxsArr.Length; i++)
            {
                var bid = ((InferFaultage)gridView1.GetFocusedRow()).bid;
                if (bid == "")
                {
                    continue;
                }
                if (i == 0)
                {
                    str = "bid='" + bid + "'";
                }
                else
                {
                    str += " or bid='" + bid + "'";
                }
            }
            var list = MyMapHelp.FindFeatureListByWhereClause(pFeatureLayer, str);

            if (list.Count > 0)
            {
                MyMapHelp.Jump(MyMapHelp.GetGeoFromFeature(list));
                DataEditCommon.g_pMap.ClearSelection();
                for (var i = 0; i < list.Count; i++)
                {
                    DataEditCommon.g_pMap.SelectFeature(pLayer, list[i]);
                }
                WindowState = FormWindowState.Normal;
                Location    = DataEditCommon.g_axTocControl.Location;
                Width       = DataEditCommon.g_axTocControl.Width;
                Height      = DataEditCommon.g_axTocControl.Height;
                DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null,
                                                                      DataEditCommon.g_pAxMapControl.Extent);
            }
            else
            {
                Alert.AlertMsg("图元丢失");
            }
        }
示例#11
0
        private void btnMap_Click(object sender, EventArgs e)
        {
            var faultage = (Faultage)gridView1.GetFocusedRow();
            var bid      = faultage.bid;
            var pLayer   = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.DEFALUT_EXPOSE_FAULTAGE);

            if (pLayer == null)
            {
                MessageBox.Show(@"未发现揭露断层图层!");
                return;
            }
            var pFeatureLayer = (IFeatureLayer)pLayer;
            var str           = "";

            //for (int i = 0; i < iSelIdxsArr.Length; i++)
            //{
            if (bid != "")
            {
                if (true)
                {
                    str = "bid='" + bid + "'";
                }
                //else
                //    str += " or bid='" + bid + "'";
            }
            //}
            var list = MyMapHelp.FindFeatureListByWhereClause(pFeatureLayer, str);

            if (list.Count > 0)
            {
                MyMapHelp.Jump(MyMapHelp.GetGeoFromFeature(list));
                DataEditCommon.g_pMap.ClearSelection();
                foreach (var t in list)
                {
                    DataEditCommon.g_pMap.SelectFeature(pLayer, t);
                }
                WindowState = FormWindowState.Normal;
                Location    = DataEditCommon.g_axTocControl.Location;
                Width       = DataEditCommon.g_axTocControl.Width;
                Height      = DataEditCommon.g_axTocControl.Height;
                DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null,
                                                                      DataEditCommon.g_pAxMapControl.Extent);
            }
            else
            {
                Alert.AlertMsg("图元丢失");
            }
        }
示例#12
0
        /// <summary>
        ///     图显按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMap_Click(object sender, EventArgs e)
        {
            // 获取已选择明细行的索引

            var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.DEFALUT_BOREHOLE);

            if (pLayer == null)
            {
                MessageBox.Show(@"未发现钻孔图层!");
                return;
            }
            var pFeatureLayer = (IFeatureLayer)pLayer;
            var str           = "";
            var bid           = ((Borehole)gridView1.GetFocusedRow()).BindingId;

            if (bid != "")
            {
                if (true)
                {
                    str = "bid='" + bid + "'";
                }
                //else
                //    str += " or bid='" + bid + "'";
            }
            var list = MyMapHelp.FindFeatureListByWhereClause(pFeatureLayer, str);

            if (list.Count > 0)
            {
                MyMapHelp.Jump(MyMapHelp.GetGeoFromFeature(list));
                DataEditCommon.g_pMap.ClearSelection();
                foreach (var t in list)
                {
                    DataEditCommon.g_pMap.SelectFeature(pLayer, t);
                }
                WindowState = FormWindowState.Normal;
                Location    = DataEditCommon.g_axTocControl.Location;
                Width       = DataEditCommon.g_axTocControl.Width;
                Height      = DataEditCommon.g_axTocControl.Height;
                DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null,
                                                                      DataEditCommon.g_pAxMapControl.Extent);
            }
            else
            {
                Alert.alert("图元丢失");
            }
        }
示例#13
0
        /// <summary>
        ///     图显按钮事件
        /// </summary>
        /// <params name="sender"></params>
        /// <params name="e"></params>
        private void btnMap_Click(object sender, EventArgs e)
        {
            var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_XianLuoZhu1);

            if (pLayer == null)
            {
                MessageBox.Show(@"未发现陷落柱图层!");
                return;
            }
            var pFeatureLayer = (IFeatureLayer)pLayer;
            var str           = "";
            var obj           = (CollapsePillar)gridView1.GetFocusedRow();
            var bid           = obj.bid;

            if (bid != "")
            {
                if (true)
                {
                    str = "bid='" + bid + "'";
                }
                //else
                //    str += " or bid='" + bid + "'";
            }
            var list = MyMapHelp.FindFeatureListByWhereClause(pFeatureLayer, str);

            if (list.Count > 0)
            {
                MyMapHelp.Jump(MyMapHelp.GetGeoFromFeature(list));
                DataEditCommon.g_pMap.ClearSelection();
                foreach (var t in list)
                {
                    DataEditCommon.g_pMap.SelectFeature(pLayer, t);
                }
                WindowState = FormWindowState.Normal;
                Location    = DataEditCommon.g_axTocControl.Location;
                Width       = DataEditCommon.g_axTocControl.Width;
                Height      = DataEditCommon.g_axTocControl.Height;
                DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null,
                                                                      DataEditCommon.g_pAxMapControl.Extent);
            }
            else
            {
                Alert.AlertMsg("图元丢失");
            }
        }
示例#14
0
        private void btnMap_Click(object sender, EventArgs e)
        {
            // 获取已选择明细行的索引
            var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_TUNNEL);

            if (pLayer == null)
            {
                MessageBox.Show(@"未发现巷道全图层!");
                return;
            }
            var pFeatureLayer = (IFeatureLayer)pLayer;
            //for (int i = 0; i < iSelIdxsArr.Length; i++)
            //{
            var tunnel = (Tunnel)gridView1.GetFocusedRow();
            //if (bid != "")
            //{
            //if (true)
            var str = "HdId='" + tunnel.TunnelId + "'";
            //else
            //    str += " or HdId='" + bid + "'";
            //}
            //}
            var list = MyMapHelp.FindFeatureListByWhereClause(pFeatureLayer, str);

            if (list.Count > 0)
            {
                MyMapHelp.Jump(MyMapHelp.GetGeoFromFeature(list));
                DataEditCommon.g_pMap.ClearSelection();
                foreach (var t in list)
                {
                    DataEditCommon.g_pMap.SelectFeature(pLayer, t);
                }
                WindowState = FormWindowState.Normal;
                Location    = DataEditCommon.g_axTocControl.Location;
                Width       = DataEditCommon.g_axTocControl.Width;
                Height      = DataEditCommon.g_axTocControl.Height;
                DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null,
                                                                      DataEditCommon.g_pAxMapControl.Extent);
            }
            else
            {
                Alert.alert("图元丢失");
            }
        }
示例#15
0
        /// <summary>
        ///     删除瓦斯信息
        /// </summary>
        /// <params name="bid">绑定ID</params>
        private void DelGasGushQuantityPt(string[] bid)
        {
            var pLayer        = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_WSHLD);
            var pFeatureLayer = (IFeatureLayer)pLayer;
            var strsql        = "";

            for (var i = 0; i < bid.Length; i++)
            {
                if (i == 0)
                {
                    strsql = "bid='" + bid[i] + "'";
                }
                else
                {
                    strsql += " or bid='" + bid[i] + "' ";
                }
            }
            DataEditCommon.DeleteFeatureByWhereClause(pFeatureLayer, strsql);
        }
示例#16
0
        public static IWorkspace connectSde()
        {
            try
            {
                //定义工作空间,工作空间的数据源来自SDE,IWorkspaceFactory是Geodatabase的入口
                //Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");
                //IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);

                ////通过IPropertySet设置通过SDE连接数据库的各种参数
                //IPropertySet propertySet = new PropertySetClass();
                //propertySet.SetProperty("SERVER", "10.64.192.51");
                //propertySet.SetProperty("SERVICE", "esri_sde");
                //propertySet.SetProperty("INSTANCE", "sde:sqlserver:10.64.192.51");
                ////propertySet.SetProperty("Instance", "port:5151");
                //propertySet.SetProperty("DATABASE", "GasEarlyWarningGIS");
                //propertySet.SetProperty("USER", "sde");
                //propertySet.SetProperty("PASSWORD", "sde");
                //propertySet.SetProperty("VERSION", "sde.DEFAULT");

                ////通过以上设置的参数将数据库的数据通过SDE读入工作空间
                //IWorkspace workspace = workspaceFactory.Open(propertySet, 0);
                IWorkspace workspace = null;

                ILayer        pLayer        = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, "默认_点");
                IFeatureLayer pFeatureLayer = (IFeatureLayer)pLayer;
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                IDataset      pDataset      = (IDataset)pFeatureClass;
                workspace = pDataset.Workspace;
                //IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactoryClass();
                //workspace = workspaceFactory.Open(ConnectSDE(true), 0);
                return(workspace);



                //return GetSDEWorkspace();
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据库连接失败!" + ex.Message);
            }

            return(null);
        }
示例#17
0
 public static bool DelTddc(string bid)
 {
     try
     {
         const string sLayerAliasName = LayerNames.DEFALUT_INFERRED_FAULTAGE;
         ILayer       pLayer          = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap,
                                                                      sLayerAliasName);
         IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
         if (pFeatureLayer == null)
         {
             MessageBox.Show(@"推断断层图层确实!");
             return(false);
         }
         return(DataEditCommon.DeleteFeatureByBId(pFeatureLayer, bid));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         throw;
     }
 }
示例#18
0
        double huangse = 100; //黄色预警距离
        private void FrmWarningPolygon_Load(object sender, EventArgs e)
        {
            pFeatureLayer_QYYJY = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_QYYJT) as IFeatureLayer;
            if (pFeatureLayer_QYYJY == null)
            {
                MessageBox.Show("区域预警图层丢失!");
                this.Close();
            }
            ListViewItem view = new ListViewItem("陷落柱");

            view.SubItems.Add(LayerNames.LAYER_ALIAS_MR_XianLuoZhu1);
            listView1.Items.Add(view);
            view = new ListViewItem("揭露断层");
            view.SubItems.Add(LayerNames.LAYER_NAME_MR_JLDC);
            listView1.Items.Add(view);
            view = new ListViewItem("推断断层");
            view.SubItems.Add(LayerNames.LAYER_NAME_MR_TDDC);
            listView1.Items.Add(view);
            view = new ListViewItem("钻孔");
            view.SubItems.Add(LayerNames.LAYER_NAME_MR_ZK);
            listView1.Items.Add(view);
        }
示例#19
0
        private void FrmZhzzt_Load(object sender, EventArgs e)
        {
            axMapControlZZT.LoadMxFile(Application.StartupPath + @"\综合柱状图.mxd");
            pLayer = DataEditCommon.GetLayerByName(axMapControlZZT.Map, LayerNames.LAYER_ALIAS_MR_Zhuzhuang);
            ESRI.ArcGIS.Carto.IFeatureLayer pFeatureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)pLayer;
            pFeatureClass = pFeatureLayer.FeatureClass;
            if (pFeatureLayer == null)
            {
                MessageBox.Show("柱状图图层缺失!");
                this.Close();
                return;
            }
            if (pFeatureClass == null)
            {
                MessageBox.Show("柱状图图层缺失!");
                this.Close();
                return;
            }
            if (BID == "" || pGeometry == null)
            {
                return;
            }
            List <IGeometry> listgeo = new List <IGeometry>();
            IQueryFilter     pFilter = new QueryFilterClass();

            pFilter.WhereClause = "BID='" + BID + "'";
            IFeatureCursor pCursor  = pFeatureClass.Search(pFilter, false);
            IFeature       pFeature = pCursor.NextFeature();

            while (pFeature != null)
            {
                listgeo.Add(pFeature.Shape);
                pFeature = pCursor.NextFeature();
            }
            pGeometry = setgeo(MyMapHelp.GetGeoFromGeos(listgeo));
            axMapControlZZT.Extent   = pGeometry.Envelope;
            axMapControlZZT.MapScale = blc;
            axMapControlZZT.ActiveView.Refresh();
        }
示例#20
0
        /// <summary>
        ///     图显按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMap_Click(object sender, EventArgs e)
        {
            var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_TUNNEL_FD);

            if (pLayer == null)
            {
                MessageBox.Show(@"未发现掘进进尺图层!");
                return;
            }
            var pFeatureLayer = (IFeatureLayer)pLayer;
            var str           = "";
            //for (int i = 0; i < iSelIdxsArr.Length; i++)
            //{
            var bid = ((DayReportJj)gridView1.GetFocusedRow()).BindingId;

            if (bid != "")
            {
                if (true)
                {
                    str = "bid='" + bid + "'";
                }
                //else
                //    str += " or bid='" + bid + "'";
            }
            //}
            var list = MyMapHelp.FindFeatureListByWhereClause(pFeatureLayer, str);

            if (list.Count > 0)
            {
                MyMapHelp.Jump(MyMapHelp.GetGeoFromFeature(list));
            }
            else
            {
                Alert.alert("图元丢失");
            }
        }
示例#21
0
        /// <summary>
        /// Check数据是否在矿界范围之内。
        /// </summary>
        /// <params name="file"></params>
        /// <returns></returns>
        private bool withIn(string file)
        {
            try
            {
                bool   within = true;
                ILayer pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MINE_BOUNDARY);
                if (pLayer == null)
                {
                    MessageBox.Show("煤层矿界图层缺失!");
                    return(false);
                }
                IFeatureLayer pFeatureLayer = (IFeatureLayer)pLayer;
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                IQueryFilter  pFilter       = new QueryFilterClass();
                pFilter.WhereClause = "layer='预警矿界'";
                IFeatureCursor   pCursor  = pFeatureClass.Search(pFilter, false);
                IFeature         pFeature = pCursor.NextFeature();
                List <IGeometry> list     = new List <IGeometry>();
                if (pFeature == null)
                {
                    return(false);
                }
                ISegmentCollection pSegmentCollection = new PolygonClass();
                while (pFeature != null)
                {
                    list.Add(pFeature.Shape);
                    pFeature = pCursor.NextFeature();
                }
                IGeometry pgeoLine = MyMapHelp.GetGeoFromGeos(list);
                pSegmentCollection = pgeoLine as ISegmentCollection;
                IPolyline pPolyline = pSegmentCollection as IPolyline;

                IPolygon pPolygon = DataEditCommon.PolylineToPolygon(pPolyline);

                string[] liststr = File.ReadAllLines(file);
                list = new List <IGeometry>();
                IPoint pt = new PointClass();
                double x, y;
                for (int i = 0; i < liststr.Length; i++)
                {
                    pt = new PointClass();
                    if (!double.TryParse(liststr[i].Split(',')[0], out x) || !double.TryParse(liststr[i].Split(',')[1], out y))
                    {
                        MessageBox.Show("存在非数字的坐标,请检查!");
                        return(false);
                    }
                    pt.X = x;
                    pt.Y = y;
                    list.Add(pt);
                }
                if (list.Count < 3)
                {
                    MessageBox.Show("离散点数据为空或小于三个,无法生成等值线!");
                    return(false);
                }
                for (int i = 0; i < liststr.Length; i++)
                {
                    for (int j = 0; j < liststr.Length; j++)
                    {
                        if (liststr[i].Split(',')[0] == liststr[j].Split(',')[0] && liststr[i].Split(',')[1] == liststr[j].Split(',')[1] && liststr[i].Split(',')[2] == liststr[j].Split(',')[2] && i != j)
                        {
                            MessageBox.Show("存在重复点,请检查!");
                            return(false);
                        }
                    }
                }
                List <IGeometry> listrt = MyMapHelp.withIn(pPolygon, list);
                if (listrt.Count > 0)
                {
                    within = false;
                    DialogResult dr = MessageBox.Show("存在超边界的坐标,是否立即查看?", "", MessageBoxButtons.YesNo);
                    if (dr == DialogResult.Yes)
                    {
                        string strlen = "";
                        for (int i = 0; i < listrt.Count; i++)
                        {
                            pt      = listrt[i] as IPoint;
                            strlen += pt.X.ToString() + "," + pt.Y.ToString() + " \r\n";
                        }
                        string filename = Application.StartupPath + "\\ContentError.txt";
                        File.WriteAllText(filename, strlen);
                        Process.Start(filename);
                    }
                }
                return(within);
            }
            catch (Exception ex)
            {
                MessageBox.Show("获取矿界失败!" + ex.Message);
                return(false);
            }
        }
示例#22
0
        /// <summary>
        ///     20140801SDE中添加瓦斯涌出量点
        /// </summary>
        private void DrawGasGushQuantityPt(GasGushQuantity gasGushQuantityEntity)
        {
            var    dCoordinateX = Convert.ToDouble(txtCoordinateX.Text);
            var    dCoordinateY = Convert.ToDouble(txtCoordinateY.Text);
            var    dCoordinateZ = Convert.ToDouble(txtCoordinateZ.Text);
            IPoint pt           = new PointClass();

            pt.X = dCoordinateX;
            pt.Y = dCoordinateY;
            pt.Z = dCoordinateZ;
            var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_HCGZMWSYCLD);

            if (pLayer == null)
            {
                MessageBox.Show(@"未找到瓦斯涌出量点图层,无法绘制瓦斯涌出量点图元。");
                return;
            }
            var       pFeatureLayer = (IFeatureLayer)pLayer;
            IGeometry geometry      = pt;
            var       list          = new List <ziduan>
            {
                new ziduan("bid", gasGushQuantityEntity.binding_id),
                new ziduan("mc", gasGushQuantityEntity.coal_seam.ToString()),
                new ziduan("addtime", DateTime.Now.ToString(CultureInfo.InvariantCulture))
            };
            var hcny    = gasGushQuantityEntity.stope_date.ToLongDateString();
            var ydwsycl = gasGushQuantityEntity.absolute_gas_gush_quantity.ToString(CultureInfo.InvariantCulture);
            var xdwsycl = gasGushQuantityEntity.relative_gas_gush_quantity.ToString(CultureInfo.InvariantCulture);
            var gzmrcl  = gasGushQuantityEntity.working_face_day_output.ToString(CultureInfo.InvariantCulture);

            if (DataEditCommon.strLen(ydwsycl) < DataEditCommon.strLen(xdwsycl))
            {
                var count = DataEditCommon.strLen(xdwsycl) - DataEditCommon.strLen(ydwsycl);
                for (var i = 0; i < count; i++)
                {
                    ydwsycl += " ";
                }
            }
            else if (DataEditCommon.strLen(ydwsycl) > DataEditCommon.strLen(xdwsycl))
            {
                var count = DataEditCommon.strLen(ydwsycl) - DataEditCommon.strLen(xdwsycl);
                for (var i = 0; i < count; i++)
                {
                    xdwsycl += " ";
                }
            }
            if (DataEditCommon.strLen(gzmrcl) < DataEditCommon.strLen(hcny))
            {
                var count = DataEditCommon.strLen(hcny) - DataEditCommon.strLen(gzmrcl);
                for (var i = 0; i < count; i++)
                {
                    gzmrcl = " " + gzmrcl;
                }
            }
            else if (DataEditCommon.strLen(gzmrcl) > DataEditCommon.strLen(hcny))
            {
                var count = DataEditCommon.strLen(gzmrcl) - DataEditCommon.strLen(hcny);
                for (var i = 0; i < count; i++)
                {
                    hcny += " ";
                }
            }
            list.Add(new ziduan("hcny", hcny));
            list.Add(new ziduan("jdwsycl", ydwsycl));
            list.Add(new ziduan("xdwsycl", xdwsycl));
            list.Add(new ziduan("gzmrcl", gzmrcl));

            var pfeature = DataEditCommon.CreateNewFeature(pFeatureLayer, geometry, list);

            if (pfeature != null)
            {
                MyMapHelp.Jump(pt);
                DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh((esriViewDrawPhase)34, null, null);
            }
        }
示例#23
0
        /// <summary>
        ///     绘制井筒图元
        /// </summary>
        /// <param name="pitshaftEntity"></param>
        private void DrawJingTong(Pitshaft pitshaftEntity)
        {
            ////1.获得当前编辑图层
            //DrawSpecialCommon drawspecial = new DrawSpecialCommon();
            //string sLayerAliasName = LibCommon.LibLayerNames.DEFALUT_JINGTONG;//“默认_井筒”图层
            //IFeatureLayer featureLayer = drawspecial.GetFeatureLayerByName(sLayerAliasName);
            //if (featureLayer == null)
            //{
            //    MessageBox.Show("未找到" + sLayerAliasName + "图层,无法绘制井筒图元。");
            //    return;
            //}

            ////2.绘制井筒
            //double X = Convert.ToDouble(this.txtFigureCoordinateX.Text.ToString());
            //double Y = Convert.ToDouble(this.txtFigureCoordinateY.Text.ToString());
            //IPoint pt = new PointClass();
            //pt.X = X;
            //pt.Y = Y;

            //double dZ = 0;
            //if (!string.IsNullOrEmpty(this.txtFigureCoordinateZ.Text))
            //{
            //    double.TryParse(this.txtFigureCoordinateZ.Text, out dZ);
            //}
            //pt.Z = dZ;

            ////标注内容
            //string strH =(Convert.ToDouble(this.txtWellheadElevation.Text.ToString())+
            //    Convert.ToDouble(this.txtWellbottomElevation.Text.ToString())).ToString();//井口标高+井底标高
            //string strX = SplitStr(this.txtPitshaftCoordinateX.Text.ToString());
            //string strY = SplitStr(this.txtPitshaftCoordinateY.Text.ToString());
            ////string strName =this.cobPitshaftType.SelectedValue.ToString()+":"+
            ////    this.txtPitshaftName.Text.ToString();
            //string strName = this.cobPitshaftType.SelectedValue.ToString() + ":" +
            //   this.txtPitshaftName.Text.ToString();

            //GIS.SpecialGraphic.DrawJT drawJT = new GIS.SpecialGraphic.DrawJT(strX, strY, strH, strName);
            ////dfs
            //DataEditCommon.InitEditEnvironment();
            //DataEditCommon.CheckEditState();
            //DataEditCommon.g_CurWorkspaceEdit.StartEditOperation();
            ////dfe
            //IFeature feature = featureLayer.FeatureClass.CreateFeature();
            //IGeometry geometry = pt;
            //DataEditCommon.ZMValue(feature, geometry);   //几何图形Z值处理
            ////drawspecial.ZMValue(feature, geometry);//几何图形Z值处理
            //feature.Shape = pt;
            ////要素ID字段赋值(对应属性表中BindingID)
            //int iFieldID = feature.Fields.FindField(GIS_Const.FIELD_BID);
            //feature.Value[iFieldID] = pitshaftEntity.BindingId.ToString();
            //feature.Store();
            //DataEditCommon.g_CurWorkspaceEdit.StopEditOperation();
            //string strValue = feature.get_Value(feature.Fields.FindField(GIS_Const.FIELD_OBJECTID)).ToString();
            //DataEditCommon.SpecialPointRenderer(featureLayer, GIS_Const.FIELD_OBJECTID, strValue, drawJT.m_Bitmap);

            /////3.显示井筒图层
            //if (featureLayer.Visible == false)
            //    featureLayer.Visible = true;

            ////缩放到新增的线要素,并高亮该要素
            //GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = feature.Shape.Envelope;
            //GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.Extent.Expand(2.5, 2.5, true);
            //GIS.Common.DataEditCommon.g_pMyMapCtrl.Map.SelectFeature(featureLayer, feature);
            //GIS.Common.DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null);

            ////DataEditCommon.g_pMyMapCtrl.ActiveView.Refresh();

            var    X  = Convert.ToDouble(txtFigureCoordinateX.Text);
            var    Y  = Convert.ToDouble(txtFigureCoordinateY.Text);
            IPoint pt = new PointClass();

            pt.X = X;
            pt.Y = Y;

            double dZ = 0;

            if (!string.IsNullOrEmpty(txtFigureCoordinateZ.Text))
            {
                double.TryParse(txtFigureCoordinateZ.Text, out dZ);
            }
            pt.Z = dZ;
            var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.DEFALUT_JINGTONG);

            if (pLayer == null)
            {
                MessageBox.Show("未找到井筒图层,无法绘制井筒图元。");
                return;
            }
            var       pFeatureLayer = (IFeatureLayer)pLayer;
            IGeometry geometry      = pt;
            var       list          = new List <ziduan>();

            list.Add(new ziduan("bid", pitshaftEntity.BindingId));
            list.Add(new ziduan("mc", pitshaftEntity.PitshaftName));
            list.Add(new ziduan("addtime", DateTime.Now.ToString()));
            list.Add(new ziduan("jkgc", pitshaftEntity.WellheadElevation.ToString()));
            list.Add(new ziduan("jdgc", pitshaftEntity.WellbottomElevation.ToString()));
            list.Add(new ziduan("yt", cobPitshaftType.Text));
            list.Add(new ziduan("x", pitshaftEntity.PitshaftCoordinateX.ToString()));
            list.Add(new ziduan("y", pitshaftEntity.PitshaftCoordinateY.ToString()));
            list.Add(new ziduan("h", (pitshaftEntity.WellbottomElevation + pitshaftEntity.WellheadElevation).ToString()));

            var pfeature = DataEditCommon.CreateNewFeature(pFeatureLayer, geometry, list);

            if (pfeature != null)
            {
                MyMapHelp.Jump(pt);
                DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(
                    esriViewDrawPhase.esriViewGeography | esriViewDrawPhase.esriViewForeground, null, null);
            }
        }
示例#24
0
        /// <summary>
        /// 绘制推断断层
        /// </summary>
        /// <param name="title">文字</param>
        /// <param name="bid"></param>
        /// <param name="listptS">上盘坐标集合</param>
        /// <param name="listptX">下盘坐标集合</param>
        /// <returns></returns>
        public static bool DrawTDDC(string title, string bid, List <IPoint> listptS, List <IPoint> listptX)
        {
            try
            {
                const string  sLayerAliasName = LayerNames.DEFALUT_INFERRED_FAULTAGE; //“默认_推断断层”图层
                ILayer        pLayer          = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, sLayerAliasName);
                IFeatureLayer pFeatureLayer   = pLayer as IFeatureLayer;
                if (pFeatureLayer == null)
                {
                    MessageBox.Show(@"推断断层图层缺失!");
                    return(false);
                }

                INewBezierCurveFeedback pNewBezierCurveFeedback = new NewBezierCurveFeedbackClass();
                pNewBezierCurveFeedback.Display = DataEditCommon.g_pAxMapControl.ActiveView.ScreenDisplay;
                for (int i = 0; i < listptS.Count; i++)
                {
                    if (i == 0)
                    {
                        pNewBezierCurveFeedback.Start(listptS[0]);
                    }
                    else
                    {
                        pNewBezierCurveFeedback.AddPoint(listptS[i]);
                    }
                }
                IGeometry     pGeometry = pNewBezierCurveFeedback.Stop();
                var           polyline  = (IPolyline)pGeometry;
                var           pTopo     = pGeometry as ITopologicalOperator;
                List <ziduan> ziduan    = new List <ziduan>
                {
                    new ziduan("str", title),
                    new ziduan("type", "1"),
                    new ziduan("BID", bid)
                };
                IFeature pFeature = DataEditCommon.CreateNewFeature(pFeatureLayer, polyline, ziduan);
                DataEditCommon.g_pMap.SelectFeature(pFeatureLayer, pFeature);


                pNewBezierCurveFeedback = new NewBezierCurveFeedbackClass
                {
                    Display = DataEditCommon.g_pAxMapControl.ActiveView.ScreenDisplay
                };
                for (int i = 0; i < listptX.Count; i++)
                {
                    if (i == 0)
                    {
                        pNewBezierCurveFeedback.Start(listptX[0]);
                    }
                    else
                    {
                        pNewBezierCurveFeedback.AddPoint(listptX[i]);
                    }
                }
                IGeometry xGeometry = pNewBezierCurveFeedback.Stop();
                polyline = (IPolyline)xGeometry;
                ziduan   = new List <ziduan> {
                    new ziduan("str", ""), new ziduan("type", "2"), new ziduan("BID", bid)
                };
                pFeature = DataEditCommon.CreateNewFeature(pFeatureLayer, polyline, ziduan);
                if (pTopo != null)
                {
                    pTopo.Union(xGeometry);
                    DataEditCommon.g_pMap.SelectFeature(pFeatureLayer, pFeature);

                    MyMapHelp.Jump((IGeometry)pTopo);
                }
                DataEditCommon.g_pAxMapControl.ActiveView.PartialRefresh((esriViewDrawPhase)5, null, null);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
示例#25
0
        /// <summary>
        /// 绘制小柱状
        /// </summary>
        /// <param name="datasources">各地质层厚度(0.83,0.3,1.2,200)最后一个值为底板标高</param>
        /// <param name="pt">小柱状中心点</param>
        /// <param name="Angle">旋转角度</param>
        /// <param name="bili">比例</param>
        /// <param name="bid">BID</param>
        /// <param name="edit">函数外控制编辑状态为false,函数内自动控制编辑状态为true,当批量绘图时建议函数外控制编辑状态</param>
        public static bool drawXZZ(List <KeyValuePair <int, double> > datasources, IPoint pt, double Angle, string bid, double bili = 1, bool edit = true)
        {
            double angle = -Angle;

            Angle = -Angle * Math.PI / 180;
            DrawXZZMap draw      = new DrawXZZMap(bili);
            var        AnnoLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_AnnotationXZZ) as IFeatureLayer; //注记图层
            var        lineLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_PolylineXZZ) as IFeatureLayer;   //线源图层
            var        topLayer  = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_PolygonXZZ) as IFeatureLayer;    //外部图形图层

            if (AnnoLayer == null || lineLayer == null || topLayer == null)
            {
                System.Windows.Forms.MessageBox.Show("小柱状图层缺失!");
                return(false);
            }
            IWorkspaceEdit workspaceEdit = null;

            if (edit)
            {
                var dataset = lineLayer.FeatureClass as IDataset;
                workspaceEdit = dataset.Workspace as IWorkspaceEdit;
                workspaceEdit.StartEditing(true);
                workspaceEdit.StartEditOperation();
            }
            try
            {
                //  准备添加数据
                var polygonTopCursor = topLayer.FeatureClass.Insert(true);
                var polylineCursor   = lineLayer.FeatureClass.Insert(true);
                var AnnoCursor       = AnnoLayer.FeatureClass.Insert(true);
                //  从数据源图层获得数据
                var num1 = datasources[datasources.Count - 1].Value;     //  最后一条横线数值
                datasources.RemoveAt(datasources.Count - 1);
                if (datasources.Count > 1)
                {
                    List <IPoint> txtPoints;
                    List <IPoint> lineStartPoints;

                    var polygons = new List <KeyValuePair <string, IPolygon> >();

                    //  构造图形
                    draw.ContructGeometry(pt, datasources, out polygons, out lineStartPoints, out txtPoints);


                    ITransform2D pTrans2D;

                    //  生成方框图形
                    foreach (var polygon in polygons)
                    {
                        var feature2 = topLayer.FeatureClass.CreateFeatureBuffer();
                        feature2.set_Value(feature2.Fields.FindField("BID"), bid);
                        if (polygon.Key == "top")
                        {
                            feature2.set_Value(feature2.Fields.FindField("type"), 0);
                        }
                        else if (polygon.Key == "white")
                        {
                            feature2.set_Value(feature2.Fields.FindField("type"), 1);
                        }
                        else if (polygon.Key == "black")
                        {
                            feature2.set_Value(feature2.Fields.FindField("type"), 2);
                        }
                        pTrans2D = polygon.Value as ITransform2D;
                        //旋转要素
                        pTrans2D.Rotate(pt, Angle);
                        IPolygon ppp = pTrans2D as IPolygon;

                        GIS.Common.DataEditCommon.ZMValue(feature2, ppp);
                        feature2.Shape = ppp;

                        polygonTopCursor.InsertFeature(feature2);
                    }

                    //  生成注记
                    var enveloplist = new List <IEnvelope>();

                    for (int i = 0; i < txtPoints.Count; i++)
                    {
                        var featureAnno = AnnoLayer.FeatureClass.CreateFeatureBuffer();
                        IAnnotationFeature AnnoFeature = (IAnnotationFeature)featureAnno;

                        pTrans2D = txtPoints[i] as ITransform2D;
                        //旋转要素
                        pTrans2D.Rotate(pt, Angle);

                        ITextSymbol pTextSymbol = new TextSymbolClass();
                        pTextSymbol.Angle = angle;
                        var elementTxt = new TextElementClass
                        {
                            Geometry = pTrans2D as IGeometry,
                            FontName = "微软雅黑",
                            Size     = 12 * bili,
                            SymbolID = 0,
                            Symbol   = pTextSymbol
                        };

                        if (i == txtPoints.Count - 1)
                        {
                            elementTxt.Text = num1.ToString();                                   //  最后一条横线的数值
                            elementTxt.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; //  显示在线下边
                            featureAnno.set_Value(featureAnno.Fields.FindField("strType"), 2);
                        }
                        else
                        {
                            elementTxt.Text = datasources[i].Value.ToString();
                            elementTxt.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                            featureAnno.set_Value(featureAnno.Fields.FindField("strType"), datasources[i].Key);
                        }
                        AnnoFeature.Annotation = elementTxt;
                        featureAnno.set_Value(featureAnno.Fields.FindField("strAngle"), -angle);
                        featureAnno.set_Value(featureAnno.Fields.FindField("strX"), pt.X);
                        featureAnno.set_Value(featureAnno.Fields.FindField("strY"), pt.Y);
                        featureAnno.set_Value(featureAnno.Fields.FindField("strScale"), bili);
                        featureAnno.set_Value(featureAnno.Fields.FindField("strIndex"), i + 1);
                        featureAnno.set_Value(featureAnno.Fields.FindField("BID"), bid);

                        pTrans2D = featureAnno.Shape as ITransform2D;
                        pTrans2D.Rotate(pt, -Angle);

                        enveloplist.Add(((IGeometry)pTrans2D).Envelope);
                        AnnoCursor.InsertFeature(featureAnno);
                    }
                    //  生成线
                    var polyline = new PolylineClass();
                    for (int i = 0; i < enveloplist.Count; i++)
                    {
                        //  计算注记的终点
                        IPoint toPoint = new PointClass();
                        if (i % 2 == 0)
                        {
                            toPoint.X = enveloplist[i].XMax;
                        }
                        else
                        {
                            toPoint.X = enveloplist[i].XMin;
                        }

                        toPoint.Y = lineStartPoints[i].Y;

                        var line = new PathClass
                        {
                            FromPoint = lineStartPoints[i],
                            ToPoint   = toPoint
                        };

                        polyline.AddGeometry(line);
                    }
                    var featureLine = lineLayer.FeatureClass.CreateFeatureBuffer();

                    pTrans2D = polyline as ITransform2D;
                    pTrans2D.Rotate(pt, Angle);
                    IPolyline mline = pTrans2D as IPolyline;
                    GIS.Common.DataEditCommon.ZMValue(featureLine, mline);
                    featureLine.Shape = mline;
                    featureLine.set_Value(featureLine.Fields.FindField("BID"), bid);
                    polylineCursor.InsertFeature(featureLine);
                }

                AnnoCursor.Flush();
                polygonTopCursor.Flush();
                polylineCursor.Flush();
                if (edit)
                {
                    workspaceEdit.StopEditOperation();
                    workspaceEdit.StopEditing(true);

                    DataEditCommon.g_pMyMapCtrl.ActiveView.Refresh();
                }
                return(true);
            }
            catch (Exception ex)
            {
                if (edit)
                {
                    workspaceEdit.AbortEditOperation();
                    workspaceEdit.StopEditing(false);
                }
                System.Windows.Forms.MessageBox.Show(ex.Message);
                return(false);
            }
        }
示例#26
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         //去除无用空行
         for (int i = 0; i < dgrdvZhzzt.RowCount - 1; i++)
         {
             if (this.dgrdvZhzzt.Rows[i].Cells[0].Value == null &&
                 this.dgrdvZhzzt.Rows[i].Cells[1].Value == null &&
                 this.dgrdvZhzzt.Rows[i].Cells[2].Value == null)
             {
                 this.dgrdvZhzzt.Rows.RemoveAt(i);
             }
         }
         //验证
         if (!check())
         {
             this.DialogResult = DialogResult.None;
             return;
         }
         this.DialogResult = DialogResult.OK;
         string bid = IDGenerator.NewBindingID();
         //实体赋值
         IPoint pt = new PointClass();
         pt.X = Convert.ToDouble(txtX.Text);
         pt.Y = Convert.ToDouble(txtY.Text);
         pt.Z = 0;
         double bili = Convert.ToDouble(txtBlc.Text);
         //List<double> list = new List<double>();
         var datasources = new List <KeyValuePair <int, double> >();
         for (int i = 0; i < dgrdvZhzzt.RowCount - 1; i++)
         {
             DataGridViewTextBoxCell  cell  = dgrdvZhzzt.Rows[i].Cells[0] as DataGridViewTextBoxCell;
             DataGridViewComboBoxCell cell1 = dgrdvZhzzt.Rows[i].Cells[1] as DataGridViewComboBoxCell;
             //list.Add(Convert.ToDouble(cell.Value.ToString()));
             int key = 0;
             if (cell1.Value.ToString() == "煤层")
             {
                 key = 1;
             }
             datasources.Add(new KeyValuePair <int, double>(key, Convert.ToDouble(cell.Value.ToString())));
         }
         //list.Add(Convert.ToDouble(txtDBBG.Text));
         datasources.Add(new KeyValuePair <int, double>(2, Convert.ToDouble(txtDBBG.Text)));
         if (this.Text.Equals("修改小柱状") && this.Tag != null)
         {
             bid = this.Tag.ToString();
             var AnnoLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_AnnotationXZZ) as IFeatureLayer; //注记图层
             var lineLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_PolylineXZZ) as IFeatureLayer;   //线源图层
             var topLayer  = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MR_PolygonXZZ) as IFeatureLayer;    //外部图形图层
             if (AnnoLayer == null || lineLayer == null || topLayer == null)
             {
                 System.Windows.Forms.MessageBox.Show("小柱状图层缺失!");
                 return;
             }
             DataEditCommon.DeleteFeatureByBId(AnnoLayer, bid);
             DataEditCommon.DeleteFeatureByBId(lineLayer, bid);
             DataEditCommon.DeleteFeatureByBId(topLayer, bid);
         }
         if (DrawXZZ.drawXZZ(datasources, pt, Convert.ToDouble(txtAngle.Text), bid, bili))
         {
             FrmNewXZZ frm = new FrmNewXZZ();
             frm.Show(this.Owner);
             frm.Location = this.Location;
             this.Close();
             DataEditCommon.g_pAxMapControl.CurrentTool = null;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        /// <summary>
        ///     验证
        /// </summary>
        /// <returns></returns>
        private bool Check()
        {
            //陷落柱非空
            if (!LibCommon.Check.isEmpty(txtCollapsePillarsName, Const_GM.COLLAPSEPILLARE_NAME))
            {
                return(false);
            }
            //陷落柱名称特殊字符
            if (!LibCommon.Check.checkSpecialCharacters(txtCollapsePillarsName, Const_GM.COLLAPSEPILLARE_NAME))
            {
                return(false);
            }

            //datagridview内部
            for (int i = 0; i < dgrdvCoordinate.RowCount - 1; i++)
            {
                //坐标X
                var cell = dgrdvCoordinate.Rows[i].Cells[0] as DataGridViewTextBoxCell;
                //非空
                if (cell != null && cell.Value == null)
                {
                    Alert.alert(Const_GM.COORDINATE_X + Const.MSG_NOT_NULL + Const.SIGN_EXCLAMATION_MARK);
                    return(false);
                }
                //数字
                if (cell != null && !Validator.IsNumeric(cell.Value.ToString()))
                {
                    Alert.alert(Const_GM.COORDINATE_X + Const.MSG_MUST_NUMBER + Const.SIGN_EXCLAMATION_MARK);
                    return(false);
                }
                //坐标Y
                cell = dgrdvCoordinate.Rows[i].Cells[1] as DataGridViewTextBoxCell;
                //非空
                if (cell != null && cell.Value == null)
                {
                    Alert.alert(Const_GM.COORDINATE_Y + Const.MSG_NOT_NULL + Const.SIGN_EXCLAMATION_MARK);
                    return(false);
                }
                //数字
                if (cell != null && !Validator.IsNumeric(cell.Value.ToString()))
                {
                    Alert.alert(Const_GM.COORDINATE_Y + Const.MSG_MUST_NUMBER + Const.SIGN_EXCLAMATION_MARK);
                    return(false);
                }
                //坐标Z
                cell = dgrdvCoordinate.Rows[i].Cells[2] as DataGridViewTextBoxCell;
                //非空
                if (cell != null && cell.Value == null)
                {
                    Alert.alert(Const_GM.COORDINATE_Z + Const.MSG_NOT_NULL + Const.SIGN_EXCLAMATION_MARK);
                    return(false);
                }
                //数字
                if (cell == null || Validator.IsNumeric(cell.Value.ToString()))
                {
                    continue;
                }
                Alert.alert(Const_GM.COORDINATE_Z + Const.MSG_MUST_NUMBER + Const.SIGN_EXCLAMATION_MARK);
                return(false);
            }
            //关键点数>3
            if ((dgrdvCoordinate.RowCount <= 3))
            {
                Alert.alert(Const_GM.COLLAPSEPILLARE_MSG_MUST_MORE_THAN_THREE);
                return(false);
            }
            //描述特殊字符
            if (!LibCommon.Check.checkSpecialCharacters(txtDescribe, Const_GM.COLLAPSEPILLARE_DISCRIBE))
            {
                return(false);
            }
            ILayer mPCurrentLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap,
                                                                  LayerNames.LAYER_ALIAS_MR_XianLuoZhu1);
            var featureLayer = mPCurrentLayer as IFeatureLayer;

            if (featureLayer == null)
            {
                MessageBox.Show(@"陷落柱图层丢失!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DataEditCommon.g_pMyMapCtrl.CurrentTool = null;
                return(false);
            }
            if (featureLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon)
            {
                MessageBox.Show(@"陷落柱图层丢失!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DataEditCommon.g_pMyMapCtrl.CurrentTool = null;
                return(false);
            }
            //成功
            return(true);
        }
示例#28
0
        /// <summary>
        /// 生成等值线
        /// </summary>
        /// <params name="targetworkspace"></params>
        /// <params name="nameOftargetFeatureClass"></params>
        /// <params name="sLayerAliasName"></params>
        private bool CreateContours(IWorkspace targetworkspace, string nameOftargetFeatureClass,
                                    string sLayerAliasName, string extent, ref string failInfo)
        {
            double douElevation;

            //设置一个最小值
            progressBarControl1.Properties.Minimum = 0;
            //设置一个最大值
            progressBarControl1.Properties.Maximum = 6;
            //设置步长,即每次增加的数
            progressBarControl1.Properties.Step = 1;
            //设置进度条的样式
            progressBarControl1.Properties.ProgressViewStyle = ProgressViewStyle.Solid;
            progressBarControl1.Position = 0;

            try
            {
                Geoprocessor GP = new Geoprocessor();

                if (withIn(m_strDataFilePath) == false)
                {
                    return(false);
                }
                if (TB_Interval.Text == "")
                {
                    MessageBox.Show("请输入正确的等高距!", "提示!");
                    return(false);
                }
                if (double.TryParse(TB_Interval.Text.Trim(), out douElevation))
                {
                }
                else
                {
                    TB_Interval.Text = null;
                    MessageBox.Show("请输入正确的等高距!", "提示!");
                    return(false);
                }

                string featurOut = m_MakeContoursFolder + "\\Cont.shp";
                int    k         = 0;
                while (File.Exists(featurOut))
                {
                    k++;
                    featurOut = m_MakeContoursFolder + "\\Cont" + k.ToString() + ".shp";
                }
                int countCont = Directory.GetFiles(m_MakeContoursFolder, "Cont*").Length;
                if (countCont > 0)
                {
                    featurOut = m_MakeContoursFolder + "\\Cont" + countCont.ToString() + ".shp";
                }
                if (DrawContours.ConvertASCIIDescretePoint2FeatureClass(GP, m_strDataFilePath, featurOut) == false)
                {
                    return(false);
                }
                //执行步长
                this.progressBarControl1.PerformStep();

                string ContourRaster = m_MakeContoursFolder + "\\Spline";
                //string ContourRaster = m_MakeContoursFolder + "\\" + nameOftargetFeatureClass + "_Render";
                if (extent != "")//右上左下  xmax  ymax  xmin  ymin
                {
                    GP.SetEnvironmentValue("Extent", extent);
                }
                bool   suc = false;
                string sRasterLayerAliasName = sLayerAliasName + "渲染图";
                ILayer rsLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, sRasterLayerAliasName);
                if (rsLayer != null)
                {
                    DataEditCommon.g_pMap.DeleteLayer(rsLayer);
                }
                if (Directory.Exists(ContourRaster))
                {
                    try
                    {
                        Directory.Delete(ContourRaster, true);
                    }
                    catch
                    {
                        k = 1;
                        while (Directory.Exists(ContourRaster))
                        {
                            ContourRaster = m_MakeContoursFolder + "\\Spline" + k.ToString();
                            k++;
                        }
                    }
                }
                switch (CB_InterpolationMethod.Text)
                {
                case "样条函数插值法":
                    suc = DrawContours.Interpolate2RasterSpline(GP, featurOut, ContourRaster, CB_SplineType.Text);
                    break;

                case "自然邻域插值法":
                    suc = DrawContours.Interpolate2RasterNN(GP, featurOut, ContourRaster);
                    break;

                case "克里格插值法":
                    suc = DrawContours.Interpolate2RasterKriging(GP, featurOut, ContourRaster,
                                                                 CB_semiVariogramProp.Text, CB_searchRadiusProp.Text);
                    break;

                case "反距离权重插值法":
                    suc = DrawContours.Interpolate2RasterIDW(GP, featurOut, ContourRaster);
                    break;

                case "趋势面插值法":
                    suc = DrawContours.TrendToRaster(GP, featurOut, ContourRaster);
                    break;
                }
                if (suc == false)
                {
                    return(false);
                }
                this.progressBarControl1.PerformStep();
                GP = new Geoprocessor();
                string R2Contour = m_MakeContoursFolder + "\\Contour.shp";
                k = 1;
                while (File.Exists(R2Contour))
                {
                    R2Contour = m_MakeContoursFolder + "\\Contour" + k.ToString() + ".shp";
                    k++;
                }
                int countContour = Directory.GetFiles(m_MakeContoursFolder, "Contour*").Length;
                if (countContour > 0)
                {
                    R2Contour = m_MakeContoursFolder + "\\Contour" + countContour.ToString() + ".shp";
                }

                if (DrawContours.SplineRasterToContour(GP, ContourRaster, R2Contour, douElevation) == false)
                {
                    return(false);
                }
                this.progressBarControl1.PerformStep();

                string EvEContour = m_MakeContoursFolder + "\\EvEContour.shp";
                k = 1;
                while (File.Exists(EvEContour))
                {
                    EvEContour = m_MakeContoursFolder + "\\EvEContour" + k.ToString() + ".shp";
                    k++;
                }
                int countEvEContour = Directory.GetFiles(m_MakeContoursFolder, "EvEContour*").Length;
                if (countEvEContour > 0)
                {
                    EvEContour = m_MakeContoursFolder + "\\EvEContour" + countEvEContour.ToString() + ".shp";
                }
                if (DrawContours.FeaturesTo3D(GP, R2Contour, EvEContour) == false)
                {
                    return(false);
                }
                this.progressBarControl1.PerformStep();

                //获得等值线Shp文件所在的工作空间
                IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactory();
                IWorkspace        sourceworkspace  = workspaceFactory.OpenFromFile(m_MakeContoursFolder, 0);
                //裁切
                IPolygon bianjie = GetPolygon();

                //导入等值线Shp文件到数据库中
                DrawSpecialCommon drawspecial = new DrawSpecialCommon();
                string            nameOfsourceFeatureClass = EvEContour.Substring(EvEContour.LastIndexOf("\\") + 1);
                nameOfsourceFeatureClass = nameOfsourceFeatureClass.Substring(0, nameOfsourceFeatureClass.LastIndexOf("."));
                bool          Import = false;
                List <ziduan> list   = new List <ziduan>
                {
                    new ziduan("BID", ""),
                    new ziduan("mingcheng", sLayerAliasName),
                    new ziduan("mcid", "0"),
                    new ziduan("date", DateTime.Now.ToString()),
                    new ziduan("type", CB_InterpolationMethod.Text)
                };
                list.Add(new ziduan("BID", ""));
                list.Add(new ziduan("mingcheng", sLayerAliasName));
                list.Add(new ziduan("mcid", "0"));
                list.Add(new ziduan("date", DateTime.Now.ToString()));
                list.Add(new ziduan("type", CB_InterpolationMethod.Text));
                IFeatureLayer pFeatureLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, EditLayerName) as IFeatureLayer;
                string        WhereClause   = "mcid='" + "0" + "'";

                DataEditCommon.DeleteFeatureByWhereClause(pFeatureLayer, WhereClause);
                if (radioBtnKJ.Checked && bianjie != null)
                {
                    Import = IntersectAll(DataEditCommon.GetFeatureClassByName(sourceworkspace, nameOfsourceFeatureClass), bianjie, list);
                }
                else
                {
                    Import = drawspecial.ShapeImportGDB(sourceworkspace, targetworkspace, nameOfsourceFeatureClass, nameOftargetFeatureClass, list);
                }
                this.progressBarControl1.PerformStep();

                if (Import == false)
                {
                    MessageBox.Show(sLayerAliasName + "导入数据库失败!");
                    DataEditCommon.g_axTocControl.Update();
                    DataEditCommon.g_pAxMapControl.Refresh();
                    failInfo = sLayerAliasName;
                    return(false);
                }

                //添加相应的渲染图
                IRasterLayer newRasterLayer = new RasterLayerClass();
                newRasterLayer.CreateFromFilePath(ContourRaster);
                newRasterLayer = IntersectRaster(newRasterLayer, bianjie);
                //newRasterLayer.CreateFromDataset(newRasterDs);
                newRasterLayer.Name = sRasterLayerAliasName;
                UsingRasterStretchColorRampRender(newRasterLayer);
                //groupLayer.Add(newRasterLayer as ILayer);
                int indexPosition = DataEditCommon.g_pAxMapControl.LayerCount;//GroupLayer序号

                //判断MapControl中是否存在该图层
                ILayer mLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, sRasterLayerAliasName);
                if (mLayer != null)
                {
                    DataEditCommon.g_pMyMapCtrl.Map.DeleteLayer(mLayer);
                    indexPosition--;
                }
                DataEditCommon.g_pAxMapControl.AddLayer(newRasterLayer as ILayer, indexPosition);//添加到最下面
                DataEditCommon.g_pAxMapControl.ActiveView.Extent = newRasterLayer.AreaOfInterest;
                DataEditCommon.g_axTocControl.Update();
                DataEditCommon.g_pAxMapControl.Refresh();
                this.progressBarControl1.PerformStep();

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
        private void DrawXlz(List <CollapsePillarsPoint> lstCollapsePillarsEntKeyPts, string sCollapseId)
        {
            ILayer mPCurrentLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap,
                                                                  LayerNames.LAYER_ALIAS_MR_XianLuoZhu1);
            var pFeatureLayer = mPCurrentLayer as IFeatureLayer;
            INewBezierCurveFeedback pBezier = new NewBezierCurveFeedbackClass();
            IPoint    pt;
            IPolyline polyline = new PolylineClass();

            for (int i = 0; i < lstCollapsePillarsEntKeyPts.Count; i++)
            {
                pt = new PointClass();
                var mZAware = (IZAware)pt;
                mZAware.ZAware = true;

                pt.X = lstCollapsePillarsEntKeyPts[i].CoordinateX;
                pt.Y = lstCollapsePillarsEntKeyPts[i].CoordinateY;
                pt.Z = lstCollapsePillarsEntKeyPts[i].CoordinateZ;
                if (i == 0)
                {
                    pBezier.Start(pt);
                }
                else if (i == lstCollapsePillarsEntKeyPts.Count - 1)
                {
                    pBezier.AddPoint(pt);
                    pt = new PointClass();
                    var zZAware = (IZAware)pt;
                    zZAware.ZAware = true;
                    pt.X           = lstCollapsePillarsEntKeyPts[0].CoordinateX;
                    pt.Y           = lstCollapsePillarsEntKeyPts[0].CoordinateY;
                    pt.Z           = lstCollapsePillarsEntKeyPts[0].CoordinateZ;
                    pBezier.AddPoint(pt);
                    polyline = pBezier.Stop();
                }
                else
                {
                    pBezier.AddPoint(pt);
                }
            }
            //polyline = (IPolyline)geo;
            var pSegmentCollection = polyline as ISegmentCollection;

            if (pSegmentCollection != null)
            {
                for (int i = 0; i < pSegmentCollection.SegmentCount; i++)
                {
                    pt = new PointClass();
                    var mZAware = (IZAware)pt;
                    mZAware.ZAware = true;

                    pt.X = lstCollapsePillarsEntKeyPts[i].CoordinateX;
                    pt.Y = lstCollapsePillarsEntKeyPts[i].CoordinateY;
                    pt.Z = lstCollapsePillarsEntKeyPts[i].CoordinateZ;


                    IPoint pt1 = new PointClass();
                    mZAware        = (IZAware)pt1;
                    mZAware.ZAware = true;
                    if (i == pSegmentCollection.SegmentCount - 1)
                    {
                        pt1.X = lstCollapsePillarsEntKeyPts[0].CoordinateX;
                        pt1.Y = lstCollapsePillarsEntKeyPts[0].CoordinateY;
                        pt1.Z = lstCollapsePillarsEntKeyPts[0].CoordinateZ;

                        pSegmentCollection.Segment[i].FromPoint = pt;
                        pSegmentCollection.Segment[i].ToPoint   = pt1;
                    }
                    else
                    {
                        pt1.X = lstCollapsePillarsEntKeyPts[i + 1].CoordinateX;
                        pt1.Y = lstCollapsePillarsEntKeyPts[i + 1].CoordinateY;
                        pt1.Z = lstCollapsePillarsEntKeyPts[i + 1].CoordinateZ;

                        pSegmentCollection.Segment[i].FromPoint = pt;
                        pSegmentCollection.Segment[i].ToPoint   = pt1;
                    }
                }
            }
            polyline = pSegmentCollection as IPolyline;
            //polyline = DataEditCommon.PDFX(polyline, "Bezier");

            IPolygon pPolygon = DataEditCommon.PolylineToPolygon(polyline);
            var      list     = new List <ziduan>
            {
                new ziduan("COLLAPSE_PILLAR_NAME", lstCollapsePillarsEntKeyPts.First().CollapsePillars.CollapsePillarsName),
                new ziduan("BID", sCollapseId),
                radioBtnX.Checked ? new ziduan("XTYPE", "0") : new ziduan("XTYPE", "1")
            };
            IFeature pFeature = DataEditCommon.CreateNewFeature(pFeatureLayer, pPolygon, list);

            if (pFeature != null)
            {
                MyMapHelp.Jump(pFeature.Shape);
                DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
            }

            #region 暂时无用

            //string sTempFolderPath = System.Windows.Forms.Application.StartupPath + "\\TempFolder";

            /////1.将关键点坐标存储到临时文件中
            //string sPtsCoordinateTxtPath = sTempFolderPath + "\\PtsCoordinate.txt";
            //bool bIsWrite = WritePtsInfo2Txt(lstCollapsePillarsEntKeyPts, sPtsCoordinateTxtPath);
            //if (!bIsWrite) return;

            /////2.读取点坐标文件拟合生成陷落柱,仿照等值线
            /////步骤:点文件生成点要素层→转为Raster→提取等值线
            //Geoprocessor GP = new Geoprocessor();
            //string featureOut = sTempFolderPath + "\\KeyPts.shp";
            //DrawContours.ConvertASCIIDescretePoint2FeatureClass(GP, sPtsCoordinateTxtPath, featureOut);//点文件生成点要素层

            //string sRasterOut = sTempFolderPath + "\\Raster";
            //DrawContours.ConvertFeatureCls2Raster(GP, featureOut, sRasterOut);//要素层→Raster

            //string sR2Contour = sTempFolderPath + "\\Contour.shp";
            //double douElevation = 0.5;//等高距0.5
            //DrawContours.SplineRasterToContour(GP, sRasterOut, sR2Contour, douElevation);//提取等值线(即为拟合的陷落柱)

            /////3.复制生成的等值线(即为拟合的陷落柱)要素到陷落柱图层
            /////3.1 获得源图层
            //IFeatureLayer sourceFeaLayer = new FeatureLayerClass();
            //string sourcefeatureClassName = "Contour.shp";
            //IFeatureClass featureClass =PointsFit2Polyline.GetFeatureClassFromShapefileOnDisk(sTempFolderPath, sourcefeatureClassName);//获得等值线(即为拟合的陷落柱)图层

            //if (featureClass == null) return;
            //sourceFeaLayer.FeatureClass = featureClass;


            /////3.2 获得当前编辑图层(目标图层)
            //DrawSpecialCommon drawspecial = new DrawSpecialCommon();
            //string sLayerAliasName = LibCommon.LibLayerNames.DEFALUT_COLLAPSE_PILLAR;//“默认_陷落柱_1”图层
            //IFeatureLayer featureLayer = drawspecial.GetFeatureLayerByName(sLayerAliasName);
            //if (featureLayer == null)
            //{
            //    MessageBox.Show("未找到" + sLayerAliasName + "图层,无法绘制陷落柱图元。");
            //    return;
            //}

            /////3.3 复制要素
            //PointsFit2Polyline.CopyFeature(sourceFeaLayer, featureLayer, sCollapseID);

            #endregion
        }
示例#30
0
        /// <summary>
        ///     未见煤钻孔
        /// </summary>
        /// <param name="breholeEntity">钻孔实体</param>
        private void DrawZuanKong(Borehole breholeEntity)
        {
            ////1.获得当前编辑图层
            //DrawSpecialCommon drawspecial = new DrawSpecialCommon();
            //string sLayerAliasName = LibCommon.LibLayerNames.DEFALUT_BOREHOLE;//“默认_钻孔”图层
            //IFeatureLayer featureLayer = drawspecial.GetFeatureLayerByName(sLayerAliasName);
            //if (featureLayer == null)
            //{
            //    MessageBox.Show("未找到" + sLayerAliasName + "图层,无法绘制钻孔图元。");
            //    return;
            //}

            ////2.绘制图元
            //IPoint pt = new PointClass();
            //pt.X = breholeEntity.CoordinateX;
            //pt.Y = breholeEntity.CoordinateY;
            //pt.Z = breholeEntity.CoordinateZ;
            //if (pt.Z == double.NaN)
            //    pt.Z = 0;
            //GIS.SpecialGraphic.DrawZK2 drawZK2 = null;
            ////标注内容
            //string strH =breholeEntity.GroundElevation.ToString();//地面标高
            //string strName = breholeEntity.BoreholeNumber.ToString();//孔号(名称)

            //IFeature feature = featureLayer.FeatureClass.CreateFeature();
            //IGeometry geometry = pt;
            //DataEditCommon.ZMValue(feature, geometry);   //几何图形Z值处理
            ////drawspecial.ZMValue(feature, geometry);    //几何图形Z值处理
            //feature.Shape = pt;//要素形状
            ////要素ID字段赋值(对应属性表中BindingID)
            //int iFieldID = feature.Fields.FindField("ID");
            //feature.Value[iFieldID] = breholeEntity.BindingId.ToString();
            //feature.Store();//存储要素

            //string strValue = feature.get_Value(feature.Fields.FindField("OBJECTID")).ToString();
            //DataEditCommon.SpecialPointRenderer(featureLayer, "OBJECTID", strValue, drawZK2.m_Bitmap);

            /////3.显示钻孔图层
            //if (featureLayer.Visible == false)
            //    featureLayer.Visible = true;

            //IEnvelope envelop = feature.Shape.Envelope;
            //DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = envelop;
            //DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
            //DataEditCommon.g_pMyMapCtrl.ActiveView.Refresh();

            IPoint pt = new PointClass();

            pt.X = breholeEntity.CoordinateX;
            pt.Y = breholeEntity.CoordinateY;
            pt.Z = breholeEntity.CoordinateZ;
            if (double.IsNaN(pt.Z))
            {
                pt.Z = 0;
            }
            var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.DEFALUT_BOREHOLE);

            if (pLayer == null)
            {
                MessageBox.Show(@"未找到钻孔图层,无法绘制钻孔图元。");
                return;
            }
            var       pFeatureLayer = (IFeatureLayer)pLayer;
            IGeometry geometry      = pt;
            var       list          = new List <ziduan>
            {
                new ziduan(GIS_Const.FIELD_BID, breholeEntity.BindingId),
                new ziduan(GIS_Const.FIELD_BOREHOLE_NUMBER, breholeEntity.BoreholeNumber),
                new ziduan(GIS_Const.FIELD_ADD_TIME, DateTime.Now.ToString(CultureInfo.InvariantCulture)),
                new ziduan(GIS_Const.FIELD_GROUND_ELEVATION,
                           breholeEntity.GroundElevation.ToString(CultureInfo.InvariantCulture)),
                new ziduan(GIS_Const.FIELD_GROUND_FLOOR_ELEVATION, ""),
                new ziduan(GIS_Const.FIELD_THICKNESS, ""),
                new ziduan(GIS_Const.FIELD_TYPE, "1")
            };

            var pfeature = DataEditCommon.CreateNewFeature(pFeatureLayer, geometry, list);

            if (pfeature == null)
            {
                return;
            }
            MyMapHelp.Jump(pt);
            DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(
                (esriViewDrawPhase)34, null, null);
        }