예제 #1
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);
        }
예제 #2
0
        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
        }