Пример #1
0
        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
        }
Пример #2
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);
            }
        }