Esempio n. 1
0
        /// <summary>
        /// 用基于弯曲的Morphing方法进行处理
        /// </summary>
        /// <param name="pParameterInitialize">参数</param>
        /// <param name="pParameterVariableFrom">有关大比例尺折线的参数变量,主要储存了大比例尺线要素、文件保存时的名字、大比例尺图层和极小值</param>
        /// <param name="pParameterVariableTo">有关小比例尺折线的参数变量,主要储存了:小比例尺线要素、文件保存时的名字、小比例尺图层和极小值</param>
        /// <param name="ParameterThreshold">阈值参数,主要储存了:大、小比例尺线要素长度,弯曲基线比阈值范围</param>
        /// <remarks>创建约束三角网时,已使用外包多边形作为约束边</remarks>
        public LinkedList <CCorrSegment> DWByMPBBSL(CParameterInitialize pParameterInitialize, CParameterVariable pParameterVariableFrom, CParameterVariable pParameterVariableTo, CParameterThreshold ParameterThreshold)
        {
            CPolyline frcpl = pParameterVariableFrom.CPolyline;

            frcpl.SetPolyline();
            CPolyline tocpl = pParameterVariableTo.CPolyline;

            tocpl.SetPolyline();

            List <CPoint> frchcptlt = _Triangulator.CreateConvexHullEdgeLt2(frcpl, pParameterVariableFrom.dblVerySmall);
            CPolyline     frchcpl   = new CPolyline(0, frchcptlt); //大比例尺折线外包多边形线段

            frchcpl.SetPolyline();

            List <CPoint> tochcptlt = _Triangulator.CreateConvexHullEdgeLt2(tocpl, pParameterVariableFrom.dblVerySmall);
            CPolyline     tochcpl   = new CPolyline(0, tochcptlt); //小比例尺折线外包多边形线段

            tochcpl.SetPolyline();

            //添加约束数据生成图层,以便于利用AE中的功能(ct:constraint)
            List <CPolyline> frctcpllt = new List <CPolyline>(); frctcpllt.Add(frcpl); frctcpllt.Add(frchcpl);
            List <CPolyline> toctcpllt = new List <CPolyline>(); toctcpllt.Add(tocpl); toctcpllt.Add(tochcpl);
            IFeatureLayer    pBSFLayer = CHelpFunc.SaveCPlLt(frctcpllt, "frctcpllt", pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl);
            IFeatureLayer    pSSFLayer = CHelpFunc.SaveCPlLt(toctcpllt, "toctcpllt", pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl);

            pParameterVariableFrom.pFeatureLayer = pBSFLayer;
            pParameterVariableTo.pFeatureLayer   = pSSFLayer;

            //建立CDT并获取弯曲森林
            CBendForest FromLeftBendForest  = new CBendForest();
            CBendForest FromRightBendForest = new CBendForest();

            GetBendForest(pParameterVariableFrom, ref FromLeftBendForest, ref FromRightBendForest, pParameterInitialize);

            CBendForest ToLeftBendForest  = new CBendForest();
            CBendForest ToRightBendForest = new CBendForest();

            GetBendForest(pParameterVariableTo, ref ToLeftBendForest, ref ToRightBendForest, pParameterInitialize);



            //弯曲树匹配,寻找对应独立弯曲
            List <CCorrespondBend> IndependCorrespondBendLt = new List <CCorrespondBend>();

            IndependCorrespondBendLt.AddRange(BendTreeMatch(FromLeftBendForest, ToLeftBendForest, ParameterThreshold));
            IndependCorrespondBendLt.AddRange(BendTreeMatch(FromRightBendForest, ToRightBendForest, ParameterThreshold));

            //弯曲匹配,寻找对应弯曲
            List <CCorrespondBend> CorrespondBendLt = BendMatch(IndependCorrespondBendLt, ParameterThreshold);

            //提取对应线段
            LinkedList <CCorrSegment> CorrespondSegmentLk = CHelpFunc.DetectCorrespondSegment(frcpl, tocpl, CorrespondBendLt);

            //CHelpFunc.PreviousWorkCSeLt(ref CorrespondSegmentLk);

            return(CorrespondSegmentLk);
        }
Esempio n. 2
0
        /// <summary>
        /// 显示并返回单个插值线段
        /// </summary>
        /// <param name="pDataRecords">数据记录</param>
        /// <param name="dblProp">差值参数</param>
        /// <returns>插值线段</returns>
        public static CPolyline DisplayInterpolation(CDataRecords pDataRecords, double dblProp)
        {
            if (dblProp < 0 || dblProp > 1)
            {
                MessageBox.Show("请输入正确参数!");
                return(null);
            }
            List <CPoint> CResultPtLt = pDataRecords.ParameterResult.CResultPtLt;
            CPolyline     cpl         = CGeoFunc.GetTargetcpl(CResultPtLt, dblProp);

            cpl.SetPolyline();
            // 清除绘画痕迹
            IMapControl4       m_mapControl = pDataRecords.ParameterInitialize.m_mapControl;
            IGraphicsContainer pGra         = m_mapControl.Map as IGraphicsContainer;

            pGra.DeleteAllElements();
            //m_mapControl.ActiveView.Refresh();   //由于在下一步“ViewPolyline”中有刷新的命令,此语句可省略
            ViewPolyline(m_mapControl, cpl);  //显示生成的线段
            return(cpl);
        }
        private void DWIntersect(CPolyline pBSCpl, ref List <CPoint> cptlt, double dblIgnorableDis)
        {
            IPointCollection4 pCol = new PolylineClass();

            for (int i = 0; i < cptlt.Count; i++)
            {
                cptlt[i].SetPoint();
                pCol.AddPoint(cptlt[i].pPoint);
            }
            IPolyline5 ipl = pCol as IPolyline5;

            pBSCpl.SetPolyline();
            IRelationalOperator pRel = pBSCpl.pPolyline as IRelationalOperator;
            bool isCrosses           = pRel.Crosses(ipl);

            if (isCrosses == true)
            {
                ITopologicalOperator pTop          = pBSCpl.pPolyline as ITopologicalOperator;
                IGeometry            pGeoIntersect = pTop.Intersect(ipl, esriGeometryDimension.esriGeometry0Dimension);
                IPointCollection4    pColIntersect = pGeoIntersect as IPointCollection4;

                double dblMaxDis = 0;
                for (int j = 0; j < pColIntersect.PointCount; j++)
                {
                    double dblDis = CGeoFunc.CalDistanceFromStartPoint(ipl, pColIntersect.get_Point(j), false);
                    if (dblDis > dblMaxDis)
                    {
                        dblMaxDis = dblDis;
                    }
                }

                ICurve pSubCurve;
                ipl.GetSubcurve(dblMaxDis, ipl.Length, false, out pSubCurve);
                //IPolyline5 Cutipl = pSubCurve as IPolyline5;
                IPointCollection4 iplCutCol = pSubCurve as IPointCollection4;

                //the new first segment
                IPointCollection4 pSegCol = new PolylineClass();
                pSegCol.AddPoint(ipl.FromPoint, _Missing, _Missing);
                pSegCol.AddPoint(iplCutCol.get_Point(1), _Missing, _Missing);
                IPolyline5 seg = pSegCol as IPolyline5;
                bool       isCrossesSeg;

                int intIndex = 0;
                while (intIndex < iplCutCol.PointCount - 1)
                {
                    intIndex++;
                    pSegCol.UpdatePoint(1, iplCutCol.get_Point(intIndex));
                    isCrossesSeg = pRel.Crosses(seg);
                    if (isCrossesSeg == false)
                    {
                        iplCutCol.RemovePoints(1, intIndex - 1);
                        iplCutCol.UpdatePoint(0, ipl.FromPoint);
                        break;
                    }
                    if (seg.Length >= dblIgnorableDis)
                    {
                        double dblOriginalIntersectionDis  = CGeoFunc.CalDistanceFromStartPoint(pBSCpl.pPolyline, pCol.get_Point(0), false);
                        double dblRealisticIntersectionDis = CGeoFunc.CalDistanceFromStartPoint(pBSCpl.pPolyline, iplCutCol.get_Point(0), false);

                        IPointCollection4 pColBSCpl = pBSCpl.pPolyline as IPointCollection4;
                        double            dblSumDis = 0;
                        for (int i = 0; i < pColBSCpl.PointCount - 1; i++)
                        {
                            double dblDis = CGeoFunc.CalDis(pColBSCpl.get_Point(i), pColBSCpl.get_Point(i + 1));
                            dblSumDis += dblDis;
                            if (dblSumDis >= dblRealisticIntersectionDis)
                            {
                                double dblDisPre   = Math.Abs(dblSumDis - dblDis - dblOriginalIntersectionDis);
                                double dblDisNext  = Math.Abs(dblSumDis - dblOriginalIntersectionDis);
                                IPoint intersectpt = new PointClass();
                                if (dblDisPre <= dblDisNext)
                                {
                                    intersectpt = pColBSCpl.get_Point(i);
                                }
                                else
                                {
                                    intersectpt = pColBSCpl.get_Point(i + 1);
                                }
                                iplCutCol.UpdatePoint(0, intersectpt);
                                break;
                            }
                        }
                        break;
                    }
                }
                cptlt = CHelpFunc.GetCptEbByICol(iplCutCol).ToList();
            }
        }