static public void GetValleyAndRidgePts(IFeatureLayer fyr, IFeatureLayer newFeaPtLyr) { Dictionary <int, double> fPtAtTerlkList = new Dictionary <int, double>(); IFeatureClass fclass = fyr.FeatureClass; IFeatureCursor pfecur = fclass.Search(null, false); IFeature pFeature = pfecur.NextFeature(); while (pFeature != null) { fPtAtTerlkList = new Dictionary <int, double>(); IPointCollection ptCol = pFeature.Shape as IPointCollection; Dictionary <int, double> InitialCValuesSetted = new Dictionary <int, double>(); double C_1 = 0; for (int i = 0; i < ptCol.PointCount - 3; i++) { IPoint fristPt = ptCol.get_Point(i); IPoint secondPt = ptCol.get_Point(i + 1); IPoint thridPt = ptCol.get_Point(i + 2); ILine ply = new LineClass(); ply.FromPoint = fristPt; ply.ToPoint = secondPt; IPolyline ply1 = new PolylineClass(); ply1.FromPoint = secondPt; ply1.ToPoint = thridPt; double C = CalCurvature.GetCurvature(fristPt, secondPt, thridPt); if (C_1 == 0) { C_1 = ply.Angle; } double D = 0; if (C < 0) { D = -(Math.Abs(C) + Math.Abs(C_1)) / (ply.Length + ply1.Length); } else { D = (Math.Abs(C) + Math.Abs(C_1)) / (ply.Length + ply1.Length); } if (Math.Abs(D) > thresholdOfCurvature) { fPtAtTerlkList.Add(i + 1, D); } C_1 = C; } for (int j = 0; j < fPtAtTerlkList.Count; j++) { int index = fPtAtTerlkList.Keys.ElementAt(j); IPoint newPt = ptCol.get_Point(index); double curve = fPtAtTerlkList.Values.ElementAt(j); AttainFpts.CreateFPtByDictionary(newFeaPtLyr, pFeature.OID, newPt, index, curve); } pFeature = pfecur.NextFeature(); } }
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); } } }