Esempio n. 1
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);
            }
        }
        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
        }
        /// <summary>
        /// 绘制推断断层
        /// </summary>
        /// <params name="title">文字</params>
        /// <params name="bid"></params>
        /// <params name="listptS">上盘坐标集合</params>
        /// <params name="listptX">下盘坐标集合</params>
        /// <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;
            }
        }
        /// <summary>
        /// �ж��ߵķ����������ʱ�룬ת����˳ʱ��
        /// </summary>
        /// <params name="pPolyline"></params>
        /// <params name="type">"Bezier,Line"</params>
        /// <returns></returns>
        public static IPolyline PDFX(IPolyline pPolyline, string type)
        {
            IPolyline rPolyline = pPolyline;
            IGeometry geo = null;
            IPointCollection pPointCollection = (IPointCollection)pPolyline;
            double s = 0;
            for (int i = 0; i < pPointCollection.PointCount - 1; i++)
            {
                s += (pPointCollection.get_Point(i + 1).X - pPointCollection.get_Point(i).X) * (pPointCollection.get_Point(i + 1).Y - pPointCollection.get_Point(i).Y) * 0.5;
            }

            if (s < 0)
            {
                if (type == "Bezier")
                {
                    INewBezierCurveFeedback pBezier = new NewBezierCurveFeedbackClass();
                    for (int i = pPointCollection.PointCount - 1; i > -1; i--)
                    {
                        if (i == pPointCollection.PointCount - 1)
                        {
                            pBezier.Start(pPointCollection.get_Point(i));
                        }
                        else if (i == 0)
                        {
                            pBezier.AddPoint(pPointCollection.get_Point(i));
                            geo = pBezier.Stop();
                        }
                        else
                            pBezier.AddPoint(pPointCollection.get_Point(i));
                    }
                    rPolyline = (IPolyline)geo;
                }
                else
                {
                    IPointCollection rPointCollection = new PolylineClass();
                    for (int i = pPointCollection.PointCount - 1; i > -1; i--)
                    {
                        rPointCollection.AddPoint(pPointCollection.get_Point(i));
                    }
                    rPolyline = (IPolyline)rPointCollection;
                }
                rPolyline.SpatialReference = pPolyline.SpatialReference;

                ISegmentCollection pSegmentCollection = rPolyline as ISegmentCollection;
                for (int i = 0; i < pSegmentCollection.SegmentCount; i++)
                {
                    IPoint pt = new PointClass();
                    IZAware mZAware = (IZAware)pt;
                    mZAware.ZAware = true;

                    pt.X = pPointCollection.get_Point(pSegmentCollection.SegmentCount - i).X;
                    pt.Y = pPointCollection.get_Point(pSegmentCollection.SegmentCount - i).Y;
                    pt.Z = pPointCollection.get_Point(pSegmentCollection.SegmentCount - i).Z;

                    IPoint pt1 = new PointClass();
                    mZAware = (IZAware)pt1;
                    mZAware.ZAware = true;
                    if (i == pSegmentCollection.SegmentCount - 1)
                    {

                        pt1.X = pPointCollection.get_Point(0).X;
                        pt1.Y = pPointCollection.get_Point(0).Y;
                        pt1.Z = pPointCollection.get_Point(0).Z;

                        pSegmentCollection.get_Segment(i).FromPoint = pt;
                        pSegmentCollection.get_Segment(i).ToPoint = pt1;
                    }
                    else
                    {
                        pt1.X = pPointCollection.get_Point(pSegmentCollection.SegmentCount - 1 - i).X;
                        pt1.Y = pPointCollection.get_Point(pSegmentCollection.SegmentCount - 1 - i).Y;
                        pt1.Z = pPointCollection.get_Point(pSegmentCollection.SegmentCount - 1 - i).Z;

                        pSegmentCollection.get_Segment(i).FromPoint = pt;
                        pSegmentCollection.get_Segment(i).ToPoint = pt1;
                    }
                }
                rPolyline = pSegmentCollection as IPolyline;
            }

            return rPolyline;
        }
        private void DrawXlz(List<CollapsePillarPoint> 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].coordinate_x;
                pt.Y = lstCollapsePillarsEntKeyPts[i].coordinate_y;
                pt.Z = lstCollapsePillarsEntKeyPts[i].coordinate_z;
                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].coordinate_x;
                    pt.Y = lstCollapsePillarsEntKeyPts[0].coordinate_y;
                    pt.Z = lstCollapsePillarsEntKeyPts[0].coordinate_z;
                    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].coordinate_x;
                    pt.Y = lstCollapsePillarsEntKeyPts[i].coordinate_y;
                    pt.Z = lstCollapsePillarsEntKeyPts[i].coordinate_z;

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

                        pSegmentCollection.Segment[i].FromPoint = pt;
                        pSegmentCollection.Segment[i].ToPoint = pt1;
                    }
                    else
                    {
                        pt1.X = lstCollapsePillarsEntKeyPts[i + 1].coordinate_x;
                        pt1.Y = lstCollapsePillarsEntKeyPts[i + 1].coordinate_y;
                        pt1.Z = lstCollapsePillarsEntKeyPts[i + 1].coordinate_z;

                        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().collapse_pillar.name),
                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
        }