Exemplo n.º 1
0
        static public List <FeaPtInform> RidgePtSort(List <FeaPtInform> ridgePtList)
        {
            List <FeaPtInform> RList = new List <FeaPtInform>();

            for (int i = 0; i < ridgePtList.Count - 1; i++)
            {
                FeaPtInform fClass = new FeaPtInform();
                for (int j = 0; j < ridgePtList.Count - 1; j++)
                {
                    if (ridgePtList[j + 1].Elev == ridgePtList[j].Elev && ridgePtList[j + 1].PtAtPlyOid == ridgePtList[j].PtAtPlyOid && ridgePtList[j].PtAtNumber > ridgePtList[j + 1].PtAtNumber)
                    {
                        fClass             = ridgePtList[j + 1];
                        ridgePtList[j + 1] = ridgePtList[j];
                        ridgePtList[j]     = fClass;
                    }
                    else if (ridgePtList[j + 1].Elev > ridgePtList[j].Elev)
                    {
                        fClass             = ridgePtList[j + 1];
                        ridgePtList[j + 1] = ridgePtList[j];
                        ridgePtList[j]     = fClass;
                    }
                }
            }
            return(RList = ridgePtList);
        }
Exemplo n.º 2
0
        static private List <FeaPtInform> valleyPtSort(List <FeaPtInform> valPtList)
        {
            List <FeaPtInform> featList1 = new List <FeaPtInform>();

            for (int i = 0; i < valPtList.Count - 1; i++)
            {
                FeaPtInform fClass = new FeaPtInform();
                for (int j = 0; j < valPtList.Count - 1; j++)
                {
                    if (valPtList[j + 1].Elev == valPtList[j].Elev && valPtList[j + 1].PtAtPlyOid == valPtList[j].PtAtPlyOid && valPtList[j].PtAtNumber > valPtList[j + 1].PtAtNumber)
                    {
                        fClass           = valPtList[j + 1];
                        valPtList[j + 1] = valPtList[j];
                        valPtList[j]     = fClass;
                    }
                    else if (valPtList[j + 1].Elev < valPtList[j].Elev)
                    {
                        fClass           = valPtList[j + 1];
                        valPtList[j + 1] = valPtList[j];
                        valPtList[j]     = fClass;
                    }
                }
            }
            return(featList1 = valPtList);
        }
Exemplo n.º 3
0
        static public void SurplesFptsByDCE(IFeatureLayer feaPtFyr, IFeatureLayer terlkFyr, IFeatureLayer newFeaPtFyr)
        {
            SortFeaturePtsAndTerlks.GetFeaturePt(feaPtFyr);
            HowToDelete(SortFeaturePtsAndTerlks.sortedValleyPts, terlkFyr, newFeaPtFyr);
            HowToDelete(SortFeaturePtsAndTerlks.sortedRidgePts, terlkFyr, newFeaPtFyr);
            for (int i = 0; i < SortFeaturePtsAndTerlks.sortedPeakPts.Count; i++)
            {
                FeaPtInform fpt = SortFeaturePtsAndTerlks.sortedPeakPts[i];

                AttainFpts.CreateFeaturePt(newFeaPtFyr, fpt.PtAtPlyOid, fpt.PtCoord, fpt.PtAtNumber, 0, 0);
            }
            for (int i = 0; i < SortFeaturePtsAndTerlks.sortedSaddlePts.Count; i++)
            {
                FeaPtInform fpt = SortFeaturePtsAndTerlks.sortedSaddlePts[i];
                AttainFpts.CreateFeaturePt(newFeaPtFyr, fpt.PtAtPlyOid, fpt.PtCoord, fpt.PtAtNumber, 2, 0);
            }
        }
Exemplo n.º 4
0
        static private List <FeaPtInform> PeakOrSaddlePtSort(List <FeaPtInform> PeakPtList)
        {
            List <FeaPtInform> RList = new List <FeaPtInform>();

            for (int i = 0; i < PeakPtList.Count - 1; i++)
            {
                FeaPtInform fClass = new FeaPtInform();
                for (int j = 0; j < PeakPtList.Count - 1; j++)
                {
                    if (PeakPtList[j + 1].Elev < PeakPtList[j].Elev)
                    {
                        fClass            = PeakPtList[j + 1];
                        PeakPtList[j + 1] = PeakPtList[j];
                        PeakPtList[j]     = fClass;
                    }
                }
            }
            return(RList = PeakPtList);
        }
Exemplo n.º 5
0
        static private double DCEFun(FeaPtInform fpt, IFeatureLayer terlkFyr)
        {
            IFeature         feature = terlkFyr.FeatureClass.GetFeature(fpt.PtAtPlyOid);
            IPointCollection ptCol   = feature.Shape as IPointCollection;
            IPoint           pt1     = ptCol.get_Point(fpt.PtAtNumber - 1);
            IPoint           pt2     = ptCol.get_Point(fpt.PtAtNumber);
            IPoint           pt3     = ptCol.get_Point(fpt.PtAtNumber + 1);
            ILine            ply     = new LineClass();

            ply.FromPoint = pt1;
            ply.ToPoint   = pt2;
            IPolyline ply1 = new PolylineClass();

            ply1.FromPoint = pt2;
            ply1.ToPoint   = pt3;
            double turnAngle = CalCurvature.GetCurvature(pt1, pt2, pt3);
            double dce       = Math.Abs(turnAngle) * ply.Length * ply1.Length / (ply.Length + ply1.Length);

            return(dce);
        }
Exemplo n.º 6
0
        static public void GetFeaturePt(IFeatureLayer feaPtFyr)
        {
            List <FeaPtInform> valleyPtList  = new List <FeaPtInform>();
            List <FeaPtInform> ridgePtList   = new List <FeaPtInform>();
            List <FeaPtInform> peakPtList    = new List <FeaPtInform>();
            List <FeaPtInform> saddlePtList  = new List <FeaPtInform>();
            FeaPtInform        peakPtClass   = null;
            FeaPtInform        ridgePtClass  = null;
            FeaPtInform        valleyPtClass = null;
            FeaPtInform        saddlePtClass = null;
            IFeatureClass      ptFClass      = feaPtFyr.FeatureClass;
            IFeatureCursor     ptFCursor     = ptFClass.Search(null, false);
            IFeature           ptFeature     = ptFCursor.NextFeature();

            while (ptFeature != null)
            {
                int markIndex = ptFeature.Fields.FindField("Mark");
                int mark      = (int)ptFeature.get_Value(markIndex);

                int    zIndex = ptFeature.Fields.FindField("Elev");
                double z      = (double)ptFeature.get_Value(zIndex);
                z = Math.Round(z, 0);

                int   pNumberIndex = ptFeature.Fields.FindField("WhereAtcou");
                Int32 number       = (Int32)ptFeature.get_Value(pNumberIndex);

                int   oid    = ptFeature.Fields.FindField("TerlkFID");
                Int32 lineID = (Int32)ptFeature.get_Value(oid);

                int    curveIndex = ptFeature.Fields.FindField("Curve");
                double curve      = (double)ptFeature.get_Value(curveIndex);
                IPoint pt         = new PointClass();
                pt = ptFeature.Shape as IPoint;
                if (mark == 1)
                {
                    ridgePtClass            = new FeaPtInform();
                    ridgePtClass.Elev       = z;
                    ridgePtClass.PtAtPlyOid = lineID;
                    ridgePtClass.PtAtNumber = number;
                    ridgePtClass.PtCoord    = pt;
                    ridgePtClass.CurvValues = curve;
                    ridgePtClass.Mark       = mark;
                    ridgePtList.Add(ridgePtClass);
                }
                else if (mark == -1)
                {
                    valleyPtClass            = new FeaPtInform();
                    valleyPtClass.Elev       = z;
                    valleyPtClass.PtAtPlyOid = lineID;
                    valleyPtClass.PtAtNumber = number;
                    valleyPtClass.PtCoord    = pt;
                    valleyPtClass.CurvValues = curve;
                    valleyPtClass.Mark       = mark;
                    valleyPtList.Add(valleyPtClass);
                }
                else if (mark == 0)
                {
                    peakPtClass            = new FeaPtInform();
                    peakPtClass.Elev       = Math.Round(z, 1);
                    peakPtClass.PtAtPlyOid = lineID;
                    peakPtClass.PtCoord    = pt;
                    peakPtClass.Mark       = mark;
                    peakPtList.Add(peakPtClass);
                }
                else if (mark == 2)
                {
                    saddlePtClass         = new FeaPtInform();
                    saddlePtClass.PtCoord = pt;
                    saddlePtClass.Mark    = mark;
                    saddlePtClass.Elev    = Math.Round(z, 1);;
                    saddlePtList.Add(saddlePtClass);
                }
                ptFeature = ptFCursor.NextFeature();
            }
            sortedValleyPts = valleyPtSort(valleyPtList);
            sortedRidgePts  = RidgePtSort(ridgePtList);
            sortedPeakPts   = PeakOrSaddlePtSort(peakPtList);
            sortedSaddlePts = PeakOrSaddlePtSort(saddlePtList);
        }
Exemplo n.º 7
0
        static private void HowToDelete(List <FeaPtInform> vaOrRiPtList, IFeatureLayer terlkFyr, IFeatureLayer newFeaPtFyr)
        {
            List <FeaPtInform>         valleyOrRidgeList = new List <FeaPtInform>();
            List <List <FeaPtInform> > groups            = new List <List <FeaPtInform> >();

            for (int i = 0; i < vaOrRiPtList.Count - 1; i++)
            {
                double      dce         = 0;
                FeaPtInform fptInform_1 = vaOrRiPtList[i];
                FeaPtInform fptInform_2 = vaOrRiPtList[i + 1];
                double      D           = 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 && D < 27)
                {
                    valleyOrRidgeList.Add(fptInform_1);
                    if (i == vaOrRiPtList.Count - 2)
                    {
                        valleyOrRidgeList.Add(vaOrRiPtList[i + 1]);
                        groups.Add(valleyOrRidgeList);
                        if (valleyOrRidgeList.Count < 3)
                        {
                            if (valleyOrRidgeList.Count == 1)
                            {
                                FeaPtInform fpt = valleyOrRidgeList[0];
                                dce = DCEFun(fpt, terlkFyr);
                                if (dce < onePtThreshold)
                                {
                                    groups.Remove(valleyOrRidgeList);
                                }
                            }
                            else
                            {
                                for (int j = 0; j < valleyOrRidgeList.Count; j++)
                                {
                                    dce += DCEFun(valleyOrRidgeList[j], terlkFyr);
                                }
                                if (Math.Abs(dce) < TwoPtThreshold)
                                {
                                    groups.Remove(valleyOrRidgeList);
                                }
                            }
                        }
                    }
                }
                else
                {
                    valleyOrRidgeList.Add(fptInform_1);
                    groups.Add(valleyOrRidgeList);
                    if (valleyOrRidgeList.Count < 3)
                    {
                        if (valleyOrRidgeList.Count == 1)
                        {
                            FeaPtInform fpt = valleyOrRidgeList[0];
                            dce = DCEFun(fpt, terlkFyr);
                            if (dce < onePtThreshold)
                            {
                                groups.Remove(valleyOrRidgeList);
                            }
                        }
                        else
                        {
                            for (int j = 0; j < valleyOrRidgeList.Count; j++)
                            {
                                dce += DCEFun(valleyOrRidgeList[j], terlkFyr);
                            }
                            if (Math.Abs(dce) < TwoPtThreshold)
                            {
                                groups.Remove(valleyOrRidgeList);
                            }
                        }
                    }
                    valleyOrRidgeList = new List <FeaPtInform>();
                }
            }
            for (int i = 0; i < groups.Count; i++)
            {
                List <FeaPtInform> list = groups[i];
                for (int j = 0; j < list.Count; j++)
                {
                    FeaPtInform fpt = list[j];
                    AttainFpts.CreateFPtByDictionary(newFeaPtFyr, fpt.PtAtPlyOid, fpt.PtCoord, fpt.PtAtNumber, fpt.CurvValues);
                }
            }
        }
Exemplo n.º 8
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), 3, false);
                IPoint newPt = new PointClass();
                newPt    = constructPt as IPoint;
                secondPt = newPt;
                newPt.Z  = 30;
                ptList.Add(newPt);
                newFptClass.PtCoord = newPt;
                newFptClass.Elev    = fptInfo.Elev;
                fptInfo             = newFptClass;
            }
            else
            {
                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 (midLen > leftLen && midLen > rightLen)
                            {
                                pt.Z = 30;
                                ptList.Add(pt);
                                secondPt            = pt;
                                newFptClass.PtCoord = pt;
                                newFptClass.Elev    = fptInfo.Elev;
                                fptInfo             = newFptClass;
                                p = 1;
                                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.esriGeometryPoint)///表示鞍部
                    {
                        ITopologicalOperator pTopoOper   = newLine.ToPoint as ITopologicalOperator;
                        IPolygon             pBufferPoly = pTopoOper.Buffer(30) as IPolygon;
                        IRelationalOperator  relatOper   = pBufferPoly as IRelationalOperator;
                        if (relatOper.Contains(geometry) == true)
                        {
                            ptList.Add(geometry as IPoint);
                            IPolyline ply = CreatePly(ptList);
                            return(ply);
                        }
                    }
                    else if (isSaddOrGeneral == 1 && 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)
                        {
                            ptList.Add(geometry as IPoint);
                            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 = 30;
                            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.05 || 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 = 30;
                    if (ptList.Contains(secondPt) == false)
                    {
                        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;
                    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;
                    }
                    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)//原有方向向右偏,则以1/2的角度向左偏
                            {
                                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++;
                }
            }
        }