public override void OpenSectionFile(string strFileName) { XmlReader xmlReader = XmlReader.Create(strFileName); xmlReader.ReadToFollowing("VerSectionAnalyse"); string attribute = xmlReader.GetAttribute("SectionType"); if (attribute != "VerSectionType") { MessageBox.Show("不是纵断面保存文件!"); } else { this.m_pSectionDisp.Title = xmlReader.GetAttribute("Title"); this.m_pSectionDisp.RoadName = xmlReader.GetAttribute("RoadName"); this.m_pSectionDisp.SectionNo = xmlReader.GetAttribute("SectionNo"); xmlReader.ReadToFollowing("PipeLines"); int num = Convert.ToInt32(xmlReader.GetAttribute("PipeLineCount")); this.arrayList_1.Clear(); for (int i = 0; i < num; i++) { xmlReader.ReadToFollowing("PipeLine"); PipeLine pipeLine = new PipeLine(); pipeLine.DatasetName = xmlReader.GetAttribute("DatasetName"); pipeLine.ID = Convert.ToInt32(xmlReader.GetAttribute("ID")); pipeLine.Material = xmlReader.GetAttribute("Material"); pipeLine.PipeWidthHeight = xmlReader.GetAttribute("PipeWidthAndHeight"); pipeLine.Red = Convert.ToInt32(xmlReader.GetAttribute("Red")); pipeLine.Green = Convert.ToInt32(xmlReader.GetAttribute("Green")); pipeLine.Blue = Convert.ToInt32(xmlReader.GetAttribute("Blue")); int num2 = Convert.ToInt32(xmlReader.GetAttribute("PointCount")); for (int j = 0; j < num2; j++) { xmlReader.ReadToFollowing("Point"); pipeLine.PushBack(new GPoint { X = (double)Convert.ToSingle(xmlReader.GetAttribute("X")), Y = (double)Convert.ToSingle(xmlReader.GetAttribute("Y")), Z = (double)Convert.ToSingle(xmlReader.GetAttribute("Z")), M = (double)Convert.ToSingle(xmlReader.GetAttribute("M")) }); } this.arrayList_1.Add(pipeLine); } xmlReader.ReadToFollowing("PipePoints"); int num3 = Convert.ToInt32(xmlReader.GetAttribute("PipePointCount")); this.arrayList_2.Clear(); for (int k = 0; k < num3; k++) { xmlReader.ReadToFollowing("PipePoint"); PipePoint pipePoint = new PipePoint(); pipePoint.x = (double)Convert.ToSingle(xmlReader.GetAttribute("X")); pipePoint.y = (double)Convert.ToSingle(xmlReader.GetAttribute("Y")); pipePoint.z = (double)Convert.ToSingle(xmlReader.GetAttribute("Z")); pipePoint.m = (double)Convert.ToSingle(xmlReader.GetAttribute("M")); pipePoint.bstrDatasetName = xmlReader.GetAttribute("DatasetName"); pipePoint.nID = Convert.ToInt32(xmlReader.GetAttribute("ID")); pipePoint.bstrPointKind = xmlReader.GetAttribute("PipePointKind"); pipePoint.Red = Convert.ToInt32(xmlReader.GetAttribute("Red")); pipePoint.Green = Convert.ToInt32(xmlReader.GetAttribute("Green")); pipePoint.Blue = Convert.ToInt32(xmlReader.GetAttribute("Blue")); this.arrayList_2.Add(pipePoint); } this.method_4(this.arrayList_3, this.arrayList_1); this.method_5(this.arrayList_4, this.arrayList_2); this.method_6(); this.method_7(this.arrayList_3); base.Paint(); } }
//!在这儿进行修改,将对高程埋深数据存储在不同位置进行统一处理 private void method_2() { IMap map = m_context.FocusMap; IEnumFeature enumFeature = (IEnumFeature)map.FeatureSelection; IFeature feature = enumFeature.Next(); bool isMUsing = false; int qdgcIndex = -1; int qdmsIndex = -1; int zdgcIndex = -1; int zdmsIndex = -1; if (feature == null) { return; } if (feature.FeatureType != esriFeatureType.esriFTSimpleEdge) { return; } this.arrayList_1.Clear(); this.arrayList_2.Clear(); int num = 0; while (feature != null) { IPolyline egLine = feature.Shape as IPolyline; IPoint newCenter = new PointClass(); egLine.QueryPoint(esriSegmentExtension.esriNoExtension, 0.01, true, newCenter); IEdgeFeature pEgFeature = feature as IEdgeFeature; IFeatureClass pClass = feature.Class as IFeatureClass; INetworkClass pNetworkClass = pClass as INetworkClass; INetElements network = pNetworkClass.GeometricNetwork.Network as INetElements; IEnumFeature enumFeatures = pNetworkClass.GeometricNetwork.SearchForNetworkFeature(newCenter, esriFeatureType.esriFTSimpleEdge); ISimpleEdgeFeature simpleEdgeFeature = enumFeatures.Next() as ISimpleEdgeFeature; IFeature realFeature = null; int userClassID, userID, userSubID; network.QueryIDs(simpleEdgeFeature.EID, esriElementType.esriETEdge, out userClassID, out userID, out userSubID); if (pClass.FeatureClassID == userClassID) { realFeature = pClass.GetFeature(userID); } else { IEnumDataset dses = pNetworkClass.FeatureDataset.Subsets; dses.Reset(); IDataset ds = dses.Next(); while (ds != null) { if (ds is IFeatureClass) { IFeatureClass pClass2 = ds as IFeatureClass; if (pClass2.FeatureClassID == userClassID) { realFeature = pClass2.GetFeature(userID); break; } } } } IMAware mAware = realFeature.Shape as IMAware; isMUsing = mAware.MAware; IFeatureLayer pLayer = MapHelper.GetLayerByFeature(map as IBasicMap, realFeature); IBasicLayerInfo lineConfig = PipeConfig.GetBasicLayerInfo(realFeature.Class.AliasName) as IBasicLayerInfo; if (!isMUsing) { qdgcIndex = realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.QDGC)); qdmsIndex = realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.QDMS)); zdgcIndex = realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.ZDGC)); zdmsIndex = realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.ZDMS)); } PipeLine pipeLine = new PipeLine(); IPolyline polyline = (IPolyline)feature.Shape; IPointCollection pointCollection = (IPointCollection)polyline; int pointCount = pointCollection.PointCount; pipeLine.Clear(); if (isMUsing) { for (int i = 0; i < pointCount; i++) { IPoint point = new ESRI.ArcGIS.Geometry.Point(); if (((SortInfo)this.arrayList_0[num]).bRightDirection) { point = pointCollection.get_Point(i); } else { point = pointCollection.get_Point(pointCount - i - 1); } if (double.IsNaN(point.M)) { pipeLine.PushBack(point.X, point.Y, point.Z, point.Z + 1.0); } else { pipeLine.PushBack(point.X, point.Y, point.Z - point.M, point.Z); } } } else { double height = 0; double qdgc = GetDoubleValue(realFeature, qdgcIndex, out height); double zdgc = GetDoubleValue(realFeature, zdgcIndex, out height); double qdms = GetDoubleValue(realFeature, qdmsIndex, out height); double zdms = GetDoubleValue(realFeature, zdmsIndex, out height); if (qdms == 0) { qdms = 1; } if (zdms == 0) { zdms = 1; } IPoint startPoint = pointCollection.Point[0]; IPoint endPoint = pointCollection.Point[pointCollection.PointCount - 1]; pipeLine.PushBack(startPoint.X, startPoint.Y, qdgc - qdms, qdgc); pipeLine.PushBack(endPoint.X, endPoint.Y, zdgc - zdms, zdgc); } //string text = "管线性质"; string text = lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GDXZ) == "" ? "管线性质" : lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GDXZ); int num2 = realFeature.Fields.FindField(text); string text2 = ""; if (num2 != -1) { object obj = realFeature.get_Value(num2); if (obj == null || Convert.IsDBNull(obj)) { text2 = ""; } else { text2 = obj.ToString(); } } pipeLine.ID = Convert.ToInt32(realFeature.get_Value(0).ToString()); pipeLine.DatasetName = text2; int num3 = realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GXCZ)); pipeLine.Material = num3 == -1 ? "" : realFeature.get_Value(num3).ToString(); //管径 num3 = realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GJ)); string text3 = num3 == -1 ? "" : realFeature.get_Value(num3).ToString(); //断面尺寸 num3 = feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.DMCC)); string text4 = num3 == -1 ? "" : realFeature.get_Value(num3).ToString(); Color featureColor = CommonUtils.GetFeatureColor(map, realFeature.Class.AliasName, realFeature); pipeLine.Red = (int)featureColor.R; pipeLine.Green = (int)featureColor.G; pipeLine.Blue = (int)featureColor.B; if (text3 != "") { pipeLine.PipeWidthHeight = text3; } if (text4 != "") { pipeLine.PipeWidthHeight = text4; } if (pipeLine.PipeWidthHeight == null) { pipeLine.PipeWidthHeight = ""; } this.arrayList_1.Add(pipeLine); IFeature feature2 = (IFeature)((IEdgeFeature)realFeature).FromJunctionFeature; IFeature feature3 = (IFeature)((IEdgeFeature)realFeature).ToJunctionFeature; IFeature feature4; if (num == 0) { PipePoint pipePoint = new PipePoint(); if (((SortInfo)this.arrayList_0[num]).bRightDirection) { feature4 = feature2; } else { feature4 = feature3; } pipePoint.nID = Convert.ToInt32(feature4.get_Value(0)); pipePoint.nAtPipeSegID = pipeLine.ID; pipePoint.bstrDatasetName = text2; IBasicLayerInfo pointConfig = PipeConfig.GetBasicLayerInfo(feature4.Class.AliasName) as IBasicLayerInfo; num3 = feature4.Fields.FindField(pointConfig.GetFieldName(PipeConfigWordHelper.PointWords.FSW)); if (num3 == -1) { pipePoint.bstrPointKind = ""; } else { pipePoint.bstrPointKind = feature4.get_Value(num3).ToString(); } Color featureColor2 = CommonUtils.GetFeatureColor(map, feature4.Class.AliasName, feature4); pipePoint.Red = (int)featureColor2.R; pipePoint.Green = (int)featureColor2.G; pipePoint.Blue = (int)featureColor2.B; this.arrayList_2.Add(pipePoint); } PipePoint pipePoint2 = new PipePoint(); if (((SortInfo)this.arrayList_0[num]).bRightDirection) { feature4 = feature3; } else { feature4 = feature2; } pipePoint2.nID = Convert.ToInt32(feature4.get_Value(0)); pipePoint2.nAtPipeSegID = pipeLine.ID; pipePoint2.bstrDatasetName = text2; IBasicLayerInfo pointConfig3 = PipeConfig.GetBasicLayerInfo(feature4.Class.AliasName) as IBasicLayerInfo; num3 = feature4.Fields.FindField(pointConfig3.GetFieldName(PipeConfigWordHelper.PointWords.FSW)); if (num3 == -1) { pipePoint2.bstrPointKind = ""; } else { pipePoint2.bstrPointKind = feature4.get_Value(num3).ToString(); } Color featureColor3 = CommonUtils.GetFeatureColor(map, feature4.Class.AliasName, feature4); pipePoint2.Red = (int)featureColor3.R; pipePoint2.Green = (int)featureColor3.G; pipePoint2.Blue = (int)featureColor3.B; this.arrayList_2.Add(pipePoint2); feature = enumFeature.Next(); num++; } this.method_3(this.arrayList_2, this.arrayList_1); this.method_4(this.arrayList_3, this.arrayList_1); this.method_5(this.arrayList_4, this.arrayList_2); this.method_6(); this.method_7(this.arrayList_3); }