Beispiel #1
0
        static public List <double> MiddlenessValue(List <FeaPtInform> list)
        {
            //计算总长度
            double totalLength = 0;

            for (int i = 0; i < list.Count - 1; i++)
            {
                FeaPtInform fpt_1 = list[i];
                FeaPtInform fpt_2 = list[i + 1];
                totalLength += Math.Sqrt(Math.Pow(fpt_1.PtCoord.X - fpt_2.PtCoord.X, 2) + Math.Pow(fpt_1.PtCoord.Y - fpt_2.PtCoord.Y, 2));
            }
            double        averageLength = totalLength / 2;//中间长度
            double        len           = 0;
            List <double> midRateList   = new List <double>();

            for (int i = 0; i < list.Count - 1; i++)
            {
                FeaPtInform fpt_1 = list[i];
                FeaPtInform fpt_2 = list[i + 1];
                len += Math.Sqrt(Math.Pow(fpt_1.PtCoord.X - fpt_2.PtCoord.X, 2) + Math.Pow(fpt_1.PtCoord.Y - fpt_2.PtCoord.Y, 2));
                /////////中间率
                double midRate = CalMidRate(len, averageLength, totalLength);
                midRateList.Add(midRate);
            }
            midRateList.Insert(0, 0);
            return(midRateList);
        }
Beispiel #2
0
        static public void GetValleyOrRidgeFeaPtGroups(IFeatureLayer feaPtFyr)
        {
            SortFeaturePtsAndTerlks.GetFeaturePt(feaPtFyr);
            List <FeaPtInform> valleyOrRidgeList = new List <FeaPtInform>();
            FeaPtInform        fptInform_1       = new FeaPtInform();
            FeaPtInform        fptInform_2       = new FeaPtInform();
            double             dis = 0;

            for (int i = 0; i < SortFeaturePtsAndTerlks.sortedValleyPts.Count - 1; i++)
            {
                fptInform_1 = SortFeaturePtsAndTerlks.sortedValleyPts[i];
                fptInform_2 = SortFeaturePtsAndTerlks.sortedValleyPts[i + 1];
                dis         = Math.Sqrt(Math.Pow(fptInform_1.PtCoord.X - fptInform_2.PtCoord.X, 2) + Math.Pow(fptInform_1.PtCoord.Y - fptInform_2.PtCoord.Y, 2));
                if (fptInform_2.PtAtNumber - fptInform_1.PtAtNumber == 1 && fptInform_2.Elev == fptInform_1.Elev && fptInform_1.PtAtPlyOid == fptInform_2.PtAtPlyOid && dis < 27)
                {
                    valleyOrRidgeList.Add(fptInform_1);
                    if (i == SortFeaturePtsAndTerlks.sortedValleyPts.Count - 2)
                    {
                        valleyOrRidgeList.Add(SortFeaturePtsAndTerlks.sortedValleyPts[i + 1]);
                        allValleyFeaPtGroups.Add(valleyOrRidgeList);
                    }
                }
                else
                {
                    valleyOrRidgeList.Add(fptInform_1);
                    allValleyFeaPtGroups.Add(valleyOrRidgeList);
                    valleyOrRidgeList = new List <FeaPtInform>();
                }
            }
            valleyOrRidgeList = new List <FeaPtInform>();
            for (int i = 0; i < SortFeaturePtsAndTerlks.sortedRidgePts.Count - 1; i++)
            {
                fptInform_1 = SortFeaturePtsAndTerlks.sortedRidgePts[i];
                fptInform_2 = SortFeaturePtsAndTerlks.sortedRidgePts[i + 1];
                dis         = Math.Sqrt(Math.Pow(fptInform_1.PtCoord.X - fptInform_2.PtCoord.X, 2) + Math.Pow(fptInform_1.PtCoord.Y - fptInform_2.PtCoord.Y, 2));
                if (fptInform_2.PtAtNumber - fptInform_1.PtAtNumber == 1 && fptInform_2.Elev == fptInform_1.Elev && fptInform_1.PtAtPlyOid == fptInform_2.PtAtPlyOid && dis < 27)
                {
                    valleyOrRidgeList.Add(fptInform_1);
                    if (i == SortFeaturePtsAndTerlks.sortedRidgePts.Count - 2)
                    {
                        valleyOrRidgeList.Add(SortFeaturePtsAndTerlks.sortedRidgePts[i + 1]);
                        allRidgeFeaPtGroups.Add(valleyOrRidgeList);
                    }
                }
                else
                {
                    valleyOrRidgeList.Add(fptInform_1);
                    allRidgeFeaPtGroups.Add(valleyOrRidgeList);
                    valleyOrRidgeList = new List <FeaPtInform>();
                }
            }
        }
Beispiel #3
0
        static public double MaxCvalue(List <FeaPtInform> list)
        {
            double maxC = 0;

            for (int i = 0; i < list.Count; i++)
            {
                FeaPtInform fpt_1 = list[i];
                if (Math.Abs(fpt_1.CurvValues) > maxC)
                {
                    maxC = Math.Abs(fpt_1.CurvValues);
                }
            }
            return(maxC);
        }
Beispiel #4
0
        static public double MaxDistance(List <FeaPtInform> list, IPoint upPt)
        {
            double maxDis = 0;

            for (int i = 0; i < list.Count; i++)
            {
                FeaPtInform fpt      = list[i];
                ILine       linkLine = new LineClass();
                linkLine.FromPoint = upPt;
                linkLine.ToPoint   = fpt.PtCoord;
                if (linkLine.Length > maxDis)
                {
                    maxDis = linkLine.Length;
                }
            }
            return(maxDis);
        }
Beispiel #5
0
        static public double IntersectionAngle(FeaPtInform fpt, IPoint upPoint, ILine angleLine)
        {
            ILine linkLine = new LineClass();

            linkLine.FromPoint = upPoint;
            linkLine.ToPoint   = fpt.PtCoord;
            Point_T  fristFpt  = new Point_T(linkLine.FromPoint.X, linkLine.FromPoint.Y);
            Point_T  secondFpt = new Point_T(linkLine.ToPoint.X, linkLine.ToPoint.Y);
            Vector_T vec1      = new Vector_T(fristFpt, secondFpt);
            Point_T  frp       = new Point_T(angleLine.FromPoint.X, angleLine.FromPoint.Y);
            Point_T  tp        = new Point_T(angleLine.ToPoint.X, angleLine.ToPoint.Y);
            Vector_T vec2      = new Vector_T(frp, tp);

            double angle = Math.Abs(vec1.Angle(vec2));

            return(angle);
        }
Beispiel #6
0
        static public double MaxDeflecAngle(List <FeaPtInform> list, IPoint upPoint, ILine angleLine)
        {
            double maxAngle = 0;

            for (int i = 0; i < list.Count; i++)
            {
                FeaPtInform fpt      = list[i];
                ILine       linkLine = new LineClass();
                linkLine.FromPoint = upPoint;
                linkLine.ToPoint   = fpt.PtCoord;
                ////两向量的夹角
                double angle = IntersectionAngle(fpt, upPoint, angleLine);
                if (angle > maxAngle)
                {
                    maxAngle = angle;
                }
            }
            return(maxAngle);
        }
        static public IPoint CreateAngleBisectorPt(FeaPtInform fptClass, IFeatureLayer flyr, bool isValOrRige)
        {
            IConstructPoint  constructPt = new PointClass();
            IPointCollection ptCOl       = flyr.FeatureClass.GetFeature(fptClass.PtAtPlyOid).Shape as IPointCollection;

            if (isValOrRige == true)
            {
                constructPt.ConstructAngleBisector(ptCOl.get_Point(fptClass.PtAtNumber - 1), ptCOl.get_Point(fptClass.PtAtNumber), ptCOl.get_Point(fptClass.PtAtNumber + 1), 7.8, false);
            }
            else
            {
                constructPt.ConstructAngleBisector(ptCOl.get_Point(fptClass.PtAtNumber + 1), ptCOl.get_Point(fptClass.PtAtNumber), ptCOl.get_Point(fptClass.PtAtNumber - 1), 7.8, true);
            }
            IPoint newpt = new PointClass();

            newpt   = constructPt as IPoint;
            newpt.Z = 10;
            return(newpt);
        }
        static public List <IPolyline> CreatePerpendicularLine(FeaPtInform fptClass, IFeatureLayer plyFeatureLyr, bool isValOrRige)
        {
            IPoint pt1 = CreateAngleBisectorPt(fptClass, plyFeatureLyr, isValOrRige);
            ILine  AngleBisectorLine = new LineClass();

            AngleBisectorLine.FromPoint = fptClass.PtCoord;
            AngleBisectorLine.ToPoint   = pt1;

            IConstructPoint constructPt = new PointClass();
            double          m           = 100;

            if (isValOrRige == true)
            {
                m = 150;
            }
            constructPt.ConstructPerpendicular(AngleBisectorLine as ISegment, esriSegmentExtension.esriNoExtension, AngleBisectorLine.FromPoint, m, false);
            IPoint newpt      = constructPt as IPoint;
            ILine  beforeLine = new LineClass();

            beforeLine.FromPoint = fptClass.PtCoord;
            beforeLine.ToPoint   = newpt;
            IPolyline leftPly = new PolylineClass();

            leftPly.FromPoint = fptClass.PtCoord;
            leftPly.ToPoint   = newpt;

            IPolyline temperply = new PolylineClass();

            temperply = ExtendLineFun(beforeLine.FromPoint, beforeLine.Angle - Math.PI);

            IPolyline rightPly = new PolylineClass();

            rightPly.FromPoint = fptClass.PtCoord;
            rightPly.ToPoint   = temperply.ToPoint;
            List <IPolyline> buildPerpendicularLine = new List <IPolyline>();

            buildPerpendicularLine.Add(leftPly);
            buildPerpendicularLine.Add(rightPly);
            return(buildPerpendicularLine);
        }
Beispiel #9
0
        static public FeaPtInform GetOptiumPt(IFeatureLayer terlkFyr, List <FeaPtInform> list, FeaPtInform upPoint, ILine nline, bool isValOrRidge)
        {
            FeaPtInform temperFeaPt = new FeaPtInform();

            if (list.Count == 1)
            {
                temperFeaPt = list[0];
            }
            else if (list.Count == 2)
            {
                if (Math.Abs(list[0].CurvValues) > Math.Abs(list[1].CurvValues))
                {
                    temperFeaPt = list[0];
                }
                else
                {
                    temperFeaPt = list[1];
                }
            }
            else
            {
                double maxC = MaxCvalue(list);

                List <double> midRateList = MiddlenessValue(list);
                double        maxG        = 0;

                if (upPoint != null)
                {
                    IPoint ppt       = new PointClass();
                    ILine  angleLine = new LineClass();
                    if (upPoint.PtAtNumber != 0 && nline == null)
                    {
                        if (isValOrRidge == true)
                        {
                            ppt = PublicFunctionClass.CreateAngleBisectorPt(upPoint, terlkFyr, true);
                        }
                        else
                        {
                            ppt = PublicFunctionClass.CreateAngleBisectorPt(upPoint, terlkFyr, false);
                        }

                        angleLine.FromPoint = upPoint.PtCoord;
                        angleLine.ToPoint   = ppt;
                    }
                    else if (upPoint.PtAtNumber == 0 && nline != null)
                    {
                        angleLine.FromPoint = nline.FromPoint;
                        angleLine.ToPoint   = nline.ToPoint;
                    }

                    double maxAngle = MaxDeflecAngle(list, upPoint.PtCoord, angleLine);
                    double maxDis   = MaxDistance(list, upPoint.PtCoord);

                    for (int i = 0; i < list.Count; i++)
                    {
                        double mid = 0;
                        if (i == 0 || i == list.Count - 1)
                        {
                            mid = 0;
                        }
                        else
                        {
                            mid = midRateList[i];
                        }
                        FeaPtInform fpt_1 = list[i];
                        double      cRate = CalCurveOfRate(Math.Abs(fpt_1.CurvValues), maxC);

                        FeaPtInform fpt      = list[i];
                        ILine       linkLine = new LineClass();
                        linkLine.FromPoint = upPoint.PtCoord;
                        linkLine.ToPoint   = fpt.PtCoord;
                        double angle = IntersectionAngle(fpt, upPoint.PtCoord, angleLine);

                        double InnerAngle = CalAngleOfRate(angle, maxAngle);

                        double disR           = CalShortRate(linkLine.Length, maxDis);
                        double maxGravitation = GetExpectedStream(cRate, disR, InnerAngle, mid);
                        if (maxGravitation > maxG)
                        {
                            maxG        = maxGravitation;
                            temperFeaPt = fpt_1;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        double mid = 0;
                        if (i == 0 || i == list.Count - 1)
                        {
                            mid = 0;
                        }
                        else
                        {
                            mid = midRateList[i];
                        }
                        FeaPtInform fpt_1          = list[i];
                        double      cRate          = CalCurveOfRate(Math.Abs(fpt_1.CurvValues), maxC);//曲率比率
                        double      maxGravitation = GetExpectedStream(cRate, 0, 0, mid);
                        if (maxGravitation > maxG)
                        {
                            maxG        = maxGravitation;
                            temperFeaPt = fpt_1;
                        }
                    }
                }
            }
            return(temperFeaPt);
        }
        static public IPolyline intelligentSearchMethod(IFeatureLayer terlkFyr, FeaPtInform fptInfo, IPolyline leftPly, IPolyline rightPly, IGeometry geometry, bool isValOrRidge)
        {
            #region  xx
            isZearo = 0;
            ptList  = new List <IPoint>();
            FeaPtInform newFptClass = new FeaPtInform();
            fristPt = fptInfo.PtCoord;
            ptList.Add(fptInfo.PtCoord);

            IPointCollection leftPtCol  = leftPly as IPointCollection;
            IPointCollection rightPtCol = rightPly as IPointCollection;
            IPoint           angPt      = PublicFunctionClass.CreateAngleBisectorPt(fptInfo, terlkFyr, isValOrRidge);
            ptList.Add(angPt);
            secondPt          = angPt;
            newLine.FromPoint = fristPt;
            newLine.ToPoint   = secondPt;

            double l = 100; double r = 100;
            Dictionary <IPoint, double> leftDic  = ReturnMinDistancePt(leftPly, secondPt);
            Dictionary <IPoint, double> rightDic = ReturnMinDistancePt(rightPly, secondPt);
            l = leftDic.Values.ElementAt(0);
            r = rightDic.Values.ElementAt(0);
            double          h                    = (l + r) / 2;
            IConstructPoint extendPt             = new PointClass();
            extendPt.ConstructAngleDistance(secondPt, newLine.Angle, h);
            IPoint nePt = new PointClass();
            nePt = extendPt as IPoint;
            newLine.FromPoint = secondPt;
            newLine.ToPoint   = nePt;
            Dictionary <IPoint, double> dic = new Dictionary <IPoint, double>();
            while (true)
            {
                if (isZearo == 0)
                {
                    fristPt  = secondPt;
                    secondPt = nePt;
                }
                else
                {
                    fristPt  = newLine.FromPoint;
                    secondPt = newLine.ToPoint;
                }
                if (isZearo != 0)
                {
                    if (geometry.GeometryType == esriGeometryType.esriGeometryPoint)
                    {
                        ITopologicalOperator pTopoOper   = newLine.ToPoint as ITopologicalOperator;
                        IPolygon             pBufferPoly = pTopoOper.Buffer(50) as IPolygon;
                        IRelationalOperator  relatOper   = pBufferPoly as IRelationalOperator;
                        if (relatOper.Contains(geometry) == true)
                        {
                            FeaPtInform fpt = new FeaPtInform();
                            fpt.PtCoord   = newLine.ToPoint;
                            fpt.PtCoord.Z = 10;
                            ptList.Add(fpt.PtCoord);
                            feapt = ChooseOptimalFeaPt.GetOptiumPt(terlkFyr, fptList, fpt, newLine, isValOrRidge);
                            ptList.Add(feapt.PtCoord);
                            IPolyline ply = CreatePly(ptList);
                            return(ply);
                        }
                    }
                    else if (geometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        IPolyline ppy = new PolylineClass();
                        ppy.FromPoint = newLine.FromPoint;
                        ppy.ToPoint   = newLine.ToPoint;
                        ITopologicalOperator topo = ppy as ITopologicalOperator;
                        IGeometry            pgeo = topo.Intersect(geometry, esriGeometryDimension.esriGeometry0Dimension);
                        if (pgeo.IsEmpty == false)
                        {
                            IPointCollection ptcol = pgeo as IPointCollection;
                            IPoint           pt    = ptcol.get_Point(0);
                            pt.Z = 10;
                            ptList.Add(pt);
                            IPolyline ply = CreatePly(ptList);
                            return(ply);
                        }
                    }
                }
                K        = newLine.Angle;
                l        = 100; r = 100;
                leftDic  = ReturnMinDistancePt(leftPly, secondPt);
                rightDic = ReturnMinDistancePt(rightPly, secondPt);
                l        = leftDic.Values.ElementAt(0);
                r        = rightDic.Values.ElementAt(0);
                double diff = Math.Abs(l - r);
                leNew = diff;
                if (dic.ContainsKey(secondPt) == false)
                {
                    dic.Add(secondPt, diff);
                }
                if (diff < 0.03 || isZearo > 15)
                {
                    if (isZearo > 15)
                    {
                        var dicSd = from objDic in dic orderby objDic.Value ascending select objDic;

                        foreach (KeyValuePair <IPoint, double> keyv in dicSd)
                        {
                            secondPt = keyv.Key; break;
                        }
                    }

                    h          = (l + r) / 2;
                    secondPt.Z = 10;
                    ptList.Add(secondPt);
                    newFptClass         = new FeaPtInform();
                    newFptClass.PtCoord = secondPt;

                    extendPt = new PointClass();
                    extendPt.ConstructAngleDistance(secondPt, newLine.Angle, h);
                    IPoint newPt = extendPt as IPoint;
                    newLine.FromPoint = secondPt;;
                    newLine.ToPoint   = newPt;
                    fptInfo           = newFptClass;
                    K              = newLine.Angle;
                    leOld          = 0;
                    leNew          = 0;
                    startStep      = 0;
                    adjustiveAngle = 5;
                    dic            = new Dictionary <IPoint, double>();
                    isZearo        = 1;
                }
                else
                {
                    if (startStep == 0)
                    {
                        if (l > r)
                        {
                            adjustiveAngle = -adjustiveAngle;
                            direction      = 0;
                        }
                        else
                        {
                            adjustiveAngle = 5;
                            direction      = 1;
                        }
                        IPoint adjustivePt = new PointClass();
                        adjustivePt.X       = newLine.FromPoint.X + h * Math.Cos(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                        adjustivePt.Y       = newLine.FromPoint.Y + h * Math.Sin(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                        leOld               = leNew;
                        newLine.FromPoint   = fristPt;;
                        newLine.ToPoint     = adjustivePt;
                        newFptClass         = new FeaPtInform();
                        newFptClass.PtCoord = fristPt;
                        newFptClass.Elev    = fptInfo.Elev;
                        fptInfo             = newFptClass;
                        startStep           = 1;
                        isZearo++;
                    }
                    else if (startStep == 1)
                    {
                        if (leNew < leOld)
                        {
                            if (direction == 0)
                            {
                                if (adjustiveAngle > 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                double a = adjustiveAngle;
                                adjustiveAngle = a; direction = 0;
                            }
                            else if (direction == 1)
                            {
                                if (adjustiveAngle < 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                double a = adjustiveAngle;
                                adjustiveAngle = a; direction = 1;
                            }
                            IPoint adjustivePt = new PointClass();
                            adjustivePt.X       = newLine.FromPoint.X + h * Math.Cos(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            adjustivePt.Y       = newLine.FromPoint.Y + h * Math.Sin(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            leOld               = leNew;
                            newLine.FromPoint   = fristPt;;
                            newLine.ToPoint     = adjustivePt;
                            newFptClass         = new FeaPtInform();
                            newFptClass.PtCoord = fristPt;
                            newFptClass.Elev    = fptInfo.Elev;
                            fptInfo             = newFptClass;
                            startStep           = 1;
                        }
                        else if (leNew > leOld)
                        {
                            if (direction == 0)
                            {
                                if (adjustiveAngle < 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                adjustiveAngle = adjustiveAngle / 2;
                                direction      = 1;
                            }
                            else if (direction == 1)
                            {
                                if (adjustiveAngle > 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                adjustiveAngle = adjustiveAngle / 2;
                                direction      = 0;
                            }
                            IPoint adjustivePt = new PointClass();
                            adjustivePt.X       = newLine.FromPoint.X + h * Math.Cos(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            adjustivePt.Y       = newLine.FromPoint.Y + h * Math.Sin(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            leOld               = leNew;
                            newLine.FromPoint   = fristPt;;
                            newLine.ToPoint     = adjustivePt;
                            newFptClass         = new FeaPtInform();
                            newFptClass.PtCoord = fristPt;
                            newFptClass.Elev    = fptInfo.Elev;
                            fptInfo             = newFptClass;
                            startStep           = 1;
                        }
                        else if (leNew == leOld)
                        {
                            extendPt = new PointClass();
                            extendPt.ConstructAngleDistance(secondPt, newLine.Angle, h);
                            IPoint newPt = extendPt as IPoint;
                            newLine.FromPoint   = secondPt;;
                            newLine.ToPoint     = newPt;
                            newFptClass         = new FeaPtInform();
                            newFptClass.PtCoord = secondPt;
                            newFptClass.Elev    = fptInfo.Elev;
                            fptInfo             = newFptClass;
                            K              = newLine.Angle;
                            leOld          = 0;
                            leNew          = 0;
                            startStep      = 0;
                            adjustiveAngle = 5;
                        }
                        isZearo++;
                    }
                }
            }
            #endregion
        }
Beispiel #11
0
        static public IPolyline intelligentSearchMethod(IFeatureLayer terlkFyr, FeaPtInform fptInfo, IPolyline leftPly, IPolyline rightPly, IGeometry geometry, int isSaddOrGeneral)
        {
            ptList = new List <IPoint>();
            FeaPtInform newFptClass = new FeaPtInform();

            fristPt = fptInfo.PtCoord;
            if (isSaddOrGeneral == 0)
            {
                ptList.Add(fptInfo.PtCoord);
                IPointCollection terlkPtc    = terlkFyr.FeatureClass.GetFeature(fptInfo.PtAtPlyOid).Shape as IPointCollection;
                IConstructPoint  constructPt = new PointClass();
                constructPt.ConstructAngleBisector(terlkPtc.get_Point(fptInfo.PtAtNumber - 1), fptInfo.PtCoord, terlkPtc.get_Point(fptInfo.PtAtNumber + 1), 6.45, false);
                IPoint newPt = new PointClass();
                newPt    = constructPt as IPoint;
                secondPt = newPt;
                newPt.Z  = 10;
                ptList.Add(newPt);
                newFptClass.PtCoord = newPt;
                newFptClass.Elev    = fptInfo.Elev;
                fptInfo             = newFptClass;
            }
            else
            {
                ptList.Add(fptInfo.PtCoord);

                IPointCollection leftPtCol  = leftPly as IPointCollection;
                IPointCollection rightPtCol = rightPly as IPointCollection;
                for (int i = 0; i < leftPtCol.PointCount - 3; i++)
                {
                    int                  p    = 0;
                    IPolyline            ply1 = CreateAngleBisector(leftPtCol.get_Point(i), leftPtCol.get_Point(i + 1), leftPtCol.get_Point(i + 2));
                    ITopologicalOperator topo = ply1 as ITopologicalOperator;
                    for (int j = i; j < rightPtCol.PointCount - 3; j++)
                    {
                        IPolyline ply2 = CreateAngleBisector(rightPtCol.get_Point(j), rightPtCol.get_Point(j + 1), rightPtCol.get_Point(j + 2));
                        IGeometry pGeo = topo.Intersect(ply2, esriGeometryDimension.esriGeometry0Dimension);
                        if (pGeo.IsEmpty == false)
                        {
                            IPointCollection ptc      = pGeo as IPointCollection;
                            IPoint           pt       = ptc.get_Point(0);
                            double           midLen   = Length(pt, fptInfo.PtCoord);
                            double           leftLen  = Length(pt, leftPtCol.get_Point(i + 1));
                            double           rightLen = Length(pt, rightPtCol.get_Point(j + 1));
                            if (Math.Abs(midLen - leftLen) < 1 && Math.Abs(midLen - rightLen) < 1)
                            {
                                pt.Z = 10;
                                ptList.Add(pt);
                                secondPt            = pt;
                                newFptClass.PtCoord = pt;
                                newFptClass.Elev    = fptInfo.Elev;
                                fptInfo             = newFptClass;
                                p = 1;
                                break;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    if (p == 1)
                    {
                        break;
                    }
                }
            }
            newLine.FromPoint = fristPt;
            newLine.ToPoint   = secondPt;

            double l = 100; double r = 100;
            Dictionary <IPoint, double> leftDic  = ReturnMinDistancePt(leftPly, secondPt);
            Dictionary <IPoint, double> rightDic = ReturnMinDistancePt(rightPly, secondPt);

            l = leftDic.Values.ElementAt(0);
            r = rightDic.Values.ElementAt(0);
            double          h                    = (l + r) / 6.0;
            IConstructPoint extendPt             = new PointClass();

            extendPt.ConstructAngleDistance(secondPt, newLine.Angle, h);
            IPoint nePt = new PointClass();

            nePt = extendPt as IPoint;
            int m = 0;

            newLine.FromPoint = secondPt;
            newLine.ToPoint   = nePt;
            Dictionary <IPoint, double> dic = new Dictionary <IPoint, double>();

            while (true)
            {
                if (m == 0)
                {
                    fristPt  = secondPt;
                    secondPt = nePt;
                }
                else
                {
                    fristPt  = newLine.FromPoint;
                    secondPt = newLine.ToPoint;
                }
                if (m != 0)
                {
                    if (isSaddOrGeneral == 0 && geometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        IPolyline ppy = new PolylineClass();
                        ppy.FromPoint = newLine.FromPoint;
                        ppy.ToPoint   = newLine.ToPoint;
                        ITopologicalOperator topo = ppy as ITopologicalOperator;
                        IGeometry            pgeo = topo.Intersect(geometry, esriGeometryDimension.esriGeometry0Dimension);
                        if (pgeo.IsEmpty == false)
                        {
                            IPointCollection ptcol = pgeo as IPointCollection;
                            IPoint           pt    = ptcol.get_Point(0);
                            pt.Z = 10;
                            ptList.Add(pt);
                            IPolyline ply = CreatePly(ptList);
                            return(ply);
                        }
                    }
                    else if (isSaddOrGeneral == 0 && geometry.GeometryType == esriGeometryType.esriGeometryPoint)
                    {
                        ITopologicalOperator pTopoOper   = newLine.ToPoint as ITopologicalOperator;
                        IPolygon             pBufferPoly = pTopoOper.Buffer(30) as IPolygon;
                        IRelationalOperator  relatOper   = pBufferPoly as IRelationalOperator;
                        if (relatOper.Contains(geometry) == true)
                        {
                            IPoint ppt = geometry as IPoint;
                            ptList.Add(ppt);
                            IPolyline ply = CreatePly(ptList);
                            return(ply);
                        }
                    }
                    else if (isSaddOrGeneral == 1 && geometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        IPolyline ppy = new PolylineClass();
                        ppy.FromPoint = newLine.FromPoint;
                        ppy.ToPoint   = newLine.ToPoint;
                        ITopologicalOperator topo = ppy as ITopologicalOperator;
                        IGeometry            pgeo = topo.Intersect(geometry, esriGeometryDimension.esriGeometry0Dimension);
                        if (pgeo.IsEmpty == false)
                        {
                            IPointCollection ptcol = pgeo as IPointCollection;
                            IPoint           pt    = ptcol.get_Point(0);
                            pt.Z = 10;
                            ptList.Add(pt);
                            IPolyline ply = CreatePly(ptList);
                            return(ply);
                        }
                    }
                }
                K        = newLine.Angle;
                l        = 100; r = 100;
                leftDic  = ReturnMinDistancePt(leftPly, secondPt);
                rightDic = ReturnMinDistancePt(rightPly, secondPt);
                l        = leftDic.Values.ElementAt(0);
                r        = rightDic.Values.ElementAt(0);
                double diff = Math.Abs(l - r);
                leNew = diff;
                if (dic.ContainsKey(secondPt) == false)
                {
                    dic.Add(secondPt, diff);
                }

                if (diff < 0.03 || m > 15)
                {
                    if (m > 15)
                    {
                        var dicSd = from objDic in dic orderby objDic.Value ascending select objDic;

                        foreach (KeyValuePair <IPoint, double> keyv in dicSd)
                        {
                            secondPt = keyv.Key; break;
                        }
                    }
                    h          = (l + r) / 6.0;
                    secondPt.Z = 10;
                    ptList.Add(secondPt);
                    newFptClass         = new FeaPtInform();
                    newFptClass.PtCoord = secondPt;

                    extendPt = new PointClass();
                    extendPt.ConstructAngleDistance(secondPt, newLine.Angle, h);
                    IPoint newPt = extendPt as IPoint;
                    newLine.FromPoint = secondPt;;
                    newLine.ToPoint   = newPt;
                    fptInfo           = newFptClass;
                    K              = newLine.Angle;
                    leOld          = 0;
                    leNew          = 0;
                    startStep      = 0;
                    adjustiveAngle = 5;
                    dic            = new Dictionary <IPoint, double>();
                    m              = 1;
                }
                else
                {
                    if (startStep == 0)
                    {
                        if (l > r)
                        {
                            adjustiveAngle = -adjustiveAngle;
                            direction      = 0;
                        }
                        else
                        {
                            adjustiveAngle = 5;
                            direction      = 1;
                        }
                        IPoint adjustivePt = new PointClass();
                        adjustivePt.X       = newLine.FromPoint.X + h * Math.Cos(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                        adjustivePt.Y       = newLine.FromPoint.Y + h * Math.Sin(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                        leOld               = leNew;
                        newLine.FromPoint   = fristPt;;
                        newLine.ToPoint     = adjustivePt;
                        newFptClass         = new FeaPtInform();
                        newFptClass.PtCoord = fristPt;
                        newFptClass.Elev    = fptInfo.Elev;
                        fptInfo             = newFptClass;
                        startStep           = 1;
                        m++;
                    }
                    else if (startStep == 1)
                    {
                        if (leNew < leOld)
                        {
                            if (direction == 0)
                            {
                                if (adjustiveAngle > 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                double a = adjustiveAngle;
                                adjustiveAngle = a; direction = 0;
                            }
                            else if (direction == 1)
                            {
                                if (adjustiveAngle < 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                double a = adjustiveAngle;
                                adjustiveAngle = a; direction = 1;
                            }
                            IPoint adjustivePt = new PointClass();
                            adjustivePt.X       = newLine.FromPoint.X + h * Math.Cos(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            adjustivePt.Y       = newLine.FromPoint.Y + h * Math.Sin(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            leOld               = leNew;
                            newLine.FromPoint   = fristPt;;
                            newLine.ToPoint     = adjustivePt;
                            newFptClass         = new FeaPtInform();
                            newFptClass.PtCoord = fristPt;
                            newFptClass.Elev    = fptInfo.Elev;
                            fptInfo             = newFptClass;
                            startStep           = 1;
                        }
                        else if (leNew > leOld)
                        {
                            if (direction == 0)
                            {
                                if (adjustiveAngle < 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                adjustiveAngle = adjustiveAngle / 2;
                                direction      = 1;
                            }
                            else if (direction == 1)
                            {
                                if (adjustiveAngle > 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                adjustiveAngle = adjustiveAngle / 2;
                                direction      = 0;
                            }
                            IPoint adjustivePt = new PointClass();
                            adjustivePt.X       = newLine.FromPoint.X + h * Math.Cos(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            adjustivePt.Y       = newLine.FromPoint.Y + h * Math.Sin(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            leOld               = leNew;
                            newLine.FromPoint   = fristPt;;
                            newLine.ToPoint     = adjustivePt;
                            newFptClass         = new FeaPtInform();
                            newFptClass.PtCoord = fristPt;
                            newFptClass.Elev    = fptInfo.Elev;
                            fptInfo             = newFptClass;
                            startStep           = 1;
                        }
                        else if (leNew == leOld)
                        {
                            extendPt = new PointClass();
                            extendPt.ConstructAngleDistance(secondPt, newLine.Angle, h);
                            IPoint newPt = extendPt as IPoint;
                            newLine.FromPoint   = secondPt;;
                            newLine.ToPoint     = newPt;
                            newFptClass         = new FeaPtInform();
                            newFptClass.PtCoord = secondPt;
                            newFptClass.Elev    = fptInfo.Elev;
                            fptInfo             = newFptClass;
                            K              = newLine.Angle;
                            leOld          = 0;
                            leNew          = 0;
                            startStep      = 0;
                            adjustiveAngle = 5;
                        }
                    }
                    m++;
                }
            }
        }