private void InitializePipeServer() { ServerPipeConfig = new PipeConfig(); ServerPipe = new IViewPipeServer(ServerPipeConfig); ServerPipe.ClientConnectedEvent += ServerPipe_ClientConnectedEvent; ServerPipe.ClientShutdownEvent += ServerPipe_ClientShutdownEvent; ServerPipe.ClientReceiveEvent += ServerPipe_ClientReceiveEvent; ServerPipe.ClientSendEvent += ServerPipe_ClientSendEvent; ServerPipe.ClientExceptionEvent += ServerPipe_ClientExceptionEvent; }
static void Main(string[] args) { PipeCinfig = new PipeConfig(1024 * 100, 1); ServerPipe = new IViewPipeServer(PipeCinfig); ServerPipe.PipeConnectedEvent += SetOnPipeConnected; ServerPipe.PipeReceivedEvent += SetOnPipeReceived; ServerPipe.PipeSentEvent += SetOnPipeSent; ServerPipe.PipeClosedEvent += SetOnPipeClosed; ServerPipe.PipeExceptionEvent += SetOnPipeException; ServerPipe.PacketManager = CreatePacketManager(); StartPipeline(); Console.ReadKey(); }
private static PipeConfig CreatePipeConfig() { Config = new PipeConfig(BUFFER_SIZE, MAX_PIPES); return(Config); }
//!在这儿进行修改,将对高程埋深数据存储在不同位置进行统一处理 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); }
public override void GetSelectedData() { this.method_3(); IMap map = this.m_context.FocusMap; ITopologicalOperator topologicalOperator = (ITopologicalOperator)this.m_pBaseLine; IGeometry geometry = topologicalOperator.Buffer(0.0); map.ClearSelection(); ISelectionEnvironment selectionEnvironment = new SelectionEnvironment(); map.SelectByShape(geometry, selectionEnvironment, false); IEnumFeature enumFeature = (IEnumFeature)map.FeatureSelection; IFeature feature = enumFeature.Next(); while (feature != null) { if (feature.FeatureType == esriFeatureType.esriFTSimpleEdge) { 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; IPointToEID pntEID = new PointToEIDClass(); pntEID.GeometricNetwork = pNetworkClass.GeometricNetwork; pntEID.SourceMap = m_context.FocusMap; pntEID.SnapTolerance = CommonHelper.ConvertPixelsToMapUnits(m_context.ActiveView, 5.0); double percent; int edgeID; IPoint location; pntEID.GetNearestEdge(newCenter, out edgeID, out location, out percent); if (percent == 0) { feature = enumFeature.Next(); continue; } int userClassID, userID, userSubID; network.QueryIDs(edgeID, esriElementType.esriETEdge, out userClassID, out userID, out userSubID); if (pClass.FeatureClassID == userClassID) { feature = 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) { feature = pClass2.GetFeature(userID); break; } } } } } string smpClassName = CommonUtils.GetSmpClassName(feature.Class.AliasName); IMAware mWAware = feature.Shape as IMAware; bool isMUsing = mWAware.MAware; IBasicLayerInfo lineConfig = PipeConfig.GetBasicLayerInfo(feature.Class.AliasName) as IBasicLayerInfo; if (lineConfig == null && !smpClassName.ToUpper().Contains("JT_JT_L") && !smpClassName.ToUpper().Contains("SY_ZX_L") && !smpClassName.ToUpper().Contains("ZB_LD_R")) { feature = enumFeature.Next(); } else { IGeometry shape = feature.Shape; if (shape.GeometryType != esriGeometryType.esriGeometryPolyline && shape.GeometryType != esriGeometryType.esriGeometryPolygon) { feature = enumFeature.Next(); } else { IPolyline polyline; if (shape.GeometryType == esriGeometryType.esriGeometryPolygon) { polyline = this.PolygonToPolyline((IPolygon)shape); } else { polyline = (IPolyline)shape; } GPoints gPoints = null; if (isMUsing) { gPoints = this.CalculateIntersections(this.m_pBaseLine, polyline); } else { gPoints = this.CalculateIntersections(this.m_pBaseLine, feature, lineConfig); } //string text = "管线性质"; string text = lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GDXZ); string bstrDatasetName = ""; int num = feature.Fields.FindField(text); if (num != -1) { object obj = feature.get_Value(num); if (obj == null || Convert.IsDBNull(obj)) { bstrDatasetName = ""; } else { bstrDatasetName = obj.ToString(); } } if (gPoints == null) { feature = enumFeature.Next(); } else { int num2 = gPoints.Size(); for (int i = 0; i < num2; i++) { GPoint gPoint = gPoints[i]; PipePoint pipePoint = new PipePoint(); if (smpClassName.ToUpper().Contains("JT_JT_L")) { pipePoint.PointType = PipePoint.SectionPointType.sptRoadBorder; } else if (smpClassName.ToUpper().Contains("SY_ZX_L")) { pipePoint.PointType = PipePoint.SectionPointType.sptMidRoadLine; } else if (smpClassName.ToUpper().Contains("ZB_LD_R")) { pipePoint.PointType = PipePoint.SectionPointType.sptMidGreen; } else { pipePoint.PointType = PipePoint.SectionPointType.sptPipe; } pipePoint.x = gPoint.X; pipePoint.y = gPoint.Y; pipePoint.z = gPoint.Z; pipePoint.m = gPoint.M; pipePoint.bstrDatasetName = bstrDatasetName; // int num3 = feature.Fields.FindField(base.PipeConfig.get_Material()); int num3 = feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GXCZ)); if (num3 == -1) { pipePoint.strMaterial = ""; } else { object obj2 = feature.get_Value(num3); if (obj2 != null) { pipePoint.strMaterial = feature.get_Value(num3).ToString(); } else { pipePoint.strMaterial = ""; } } // num3 = feature.Fields.FindField(base.PipeConfig.get_Diameter()); num3 = feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GJ)); string text2; if (num3 != -1 && feature.get_Value(num3) != null) { text2 = feature.get_Value(num3).ToString(); } else { text2 = ""; } num3 = feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.DMCC)); string text3; if (num3 != -1 && feature.get_Value(num3) != null) { text3 = feature.get_Value(num3).ToString(); } else { text3 = ""; } if (text2 != "") { pipePoint.strPipeWidthHeight = text2; } if (text3 != "") { pipePoint.strPipeWidthHeight = text3; } Color featureColor = CommonUtils.GetFeatureColor(map, feature.Class.AliasName, feature); pipePoint.Red = (int)featureColor.R; pipePoint.Green = (int)featureColor.G; pipePoint.Blue = (int)featureColor.B; this.m_arrPipePoints.Add(pipePoint); } feature = enumFeature.Next(); } } } } map.ClearSelection(); IPointCollection pointCollection = (IPointCollection)this.m_pBaseLine; int pointCount = pointCollection.PointCount; if (pointCount != 0) { for (int j = 0; j < pointCount; j++) { IPoint point = pointCollection.get_Point(j); double x = point.X; double y = point.Y; PipePoint pipePoint2 = new PipePoint(); pipePoint2.x = x; pipePoint2.y = y; pipePoint2.PointType = PipePoint.SectionPointType.sptDrawPoint; this.m_arrPipePoints.Add(pipePoint2); } this.fEswZsmwIx((PipePoint)this.m_arrPipePoints[this.m_arrPipePoints.Count - 2]); this.method_1(); if (this.method_2()) { this.method_5(this.m_arrPipePointsDraw, this.m_arrPipePoints); this.method_4(); this.method_7(this.m_arrPipePointsDraw); } } }