protected override void OnUpdate() { // by default, disable the command Enabled = false; // if there is not a current edit session, then disable the command if (m_editorExt.EditState != esriEditState.esriStateEditing) { return; } // otherwise, check to see if the flow direction is properly set for each edge EID IUtilityNetwork utilNet = GetCurrentNetwork() as IUtilityNetwork; IEnumNetEID edgeEIDs = GetCurrentEIDs(esriElementType.esriETEdge); edgeEIDs.Reset(); for (int i = 0; i < edgeEIDs.Count; i++) { int edgeEID = edgeEIDs.Next(); esriFlowDirection flowDir = utilNet.GetFlowDirection(edgeEID); if (flowDir != esriFlowDirection.esriFDWithFlow) { // enable the command if the flow direction is not with the digitized direction Enabled = true; // we can return right now, since only one edge needs to have // incorrect flow direction in order to enable the command return; } } }
protected override void OnClick() { // get the current network IUtilityNetwork utilNet = GetCurrentNetwork() as IUtilityNetwork; // create an edit operation enabling an undo for this operation m_editorExt.StartOperation(); // get a list of the current EIDs for edges in the network IEnumNetEID edgeEIDs = GetCurrentEIDs(esriElementType.esriETEdge); // set the flow direction for each edge in the network edgeEIDs.Reset(); for (int i = 0; i < edgeEIDs.Count; i++) { int edgeEID = edgeEIDs.Next(); utilNet.SetFlowDirection(edgeEID, esriFlowDirection.esriFDWithFlow); } // stop the edit operation, specifying a name for this operation m_editorExt.StopOperation("Set Flow Direction"); // refresh the display to update the flow direction arrows IActiveView mapView = ArcMap.Document.ActiveView; mapView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void method_6(IGeometricNetwork geometricNetwork) { INetwork network = geometricNetwork.Network; IUtilityNetwork utilityNetwork = (IUtilityNetwork)network; IEnumNetEID enumNetEID = network.CreateNetBrowser((esriElementType)2); IEIDHelper eIDHelperClass = new EIDHelper(); eIDHelperClass.GeometricNetwork = (geometricNetwork); eIDHelperClass.DisplayEnvelope = (null); eIDHelperClass.OutputSpatialReference = (null); eIDHelperClass.ReturnFeatures = (false); eIDHelperClass.ReturnGeometries = (true); eIDHelperClass.PartialComplexEdgeGeometry = (true); IEnumEIDInfo enumEIDInfo = eIDHelperClass.CreateEnumEIDInfo(enumNetEID); enumEIDInfo.Reset(); long num = (long)enumEIDInfo.Count; int num2 = 0; while ((long)num2 < num) { IEIDInfo iEIDInfo = enumEIDInfo.Next(); int eID = iEIDInfo.EID; IGeometry geometry = iEIDInfo.Geometry; esriFlowDirection esriFlowDirection = this.method_7(geometry); utilityNetwork.SetFlowDirection(eID, esriFlowDirection); num2++; } }
private void method_4(INetwork network) { IUtilityNetwork utilityNetwork = (IUtilityNetwork)network; IEnumNetEID enumNetEID = network.CreateNetBrowser((esriElementType)2); enumNetEID.Reset(); long num = (long)enumNetEID.Count; int num2 = 0; while ((long)num2 < num) { int num3 = enumNetEID.Next(); utilityNetwork.SetFlowDirection(num3, (esriFlowDirection)1); num2++; } }
private void method_5(IGeometricNetwork geometricNetwork) { INetwork network = geometricNetwork.Network; IUtilityNetwork utilityNetwork = (IUtilityNetwork)network; IEnumNetEID enumNetEID = network.CreateNetBrowser((esriElementType)2); IEIDHelper eIDHelperClass = new EIDHelper(); eIDHelperClass.GeometricNetwork = (geometricNetwork); eIDHelperClass.DisplayEnvelope = (null); eIDHelperClass.OutputSpatialReference = (null); eIDHelperClass.ReturnFeatures = (true); eIDHelperClass.ReturnGeometries = (true); eIDHelperClass.PartialComplexEdgeGeometry = (true); IEnumEIDInfo enumEIDInfo = eIDHelperClass.CreateEnumEIDInfo(enumNetEID); enumEIDInfo.Reset(); long num = (long)enumEIDInfo.Count; int num2 = 0; while ((long)num2 < num) { IEIDInfo iEIDInfo = enumEIDInfo.Next(); int eID = iEIDInfo.EID; IFeature feature = iEIDInfo.Feature; int num3 = feature.Fields.FindField("流向"); if (num3 < 0) { utilityNetwork.SetFlowDirection(eID, (esriFlowDirection)1); } if (Convert.ToBoolean(feature.get_Value(num3))) { utilityNetwork.SetFlowDirection(eID, (esriFlowDirection)2); } else { utilityNetwork.SetFlowDirection(eID, (esriFlowDirection)1); } num2++; } }
public void GetFlow(IMap pMap) { int num4; this.m_pPointcol = new MultipointClass(); this.m_eFlowDirection.Clear(); this.m_angle.Clear(); INetwork network = NetworkAnalyst.m_pAnalystGN.Network; IUtilityNetwork network2 = network as IUtilityNetwork; IEnumNetEID netEIDs = network.CreateNetBrowser(esriElementType.esriETEdge); IEnumNetEID teid2 = network.CreateNetBrowser(esriElementType.esriETJunction); netEIDs.Reset(); int count = netEIDs.Count; int num2 = teid2.Count; IEIDHelper helper = new EIDHelperClass { GeometricNetwork = NetworkAnalyst.m_pAnalystGN, OutputSpatialReference = pMap.SpatialReference, ReturnGeometries = true, ReturnFeatures = true }; IEnumEIDInfo info = helper.CreateEnumEIDInfo(teid2); int num3 = info.Count; teid2.Reset(); info.Reset(); IPointCollection points = new MultipointClass(); object before = Missing.Value; for (num4 = 0; num4 < num2; num4++) { IPoint inPoint = info.Next().Geometry as IPoint; points.AddPoint(inPoint, ref before, ref before); } info = null; info = helper.CreateEnumEIDInfo(netEIDs); num3 = info.Count; netEIDs.Reset(); info.Reset(); IList list = new ArrayList(); ILine line = new LineClass(); IList list2 = new ArrayList(); int num5 = 0; for (num4 = 0; num4 < count; num4++) { int edgeEID = netEIDs.Next(); this.m_eFlowDirection.Add(network2.GetFlowDirection(edgeEID)); IEIDInfo info2 = info.Next(); IGeometry geometry = info2.Geometry; IEdgeFeature feature = info2.Feature as IEdgeFeature; IPointCollection points2 = geometry as IPointCollection; int pointCount = points2.PointCount; IPoint other = new PointClass(); IPoint[] pointArray = new IPoint[pointCount]; IRelationalOperator @operator = points as IRelationalOperator; IPointCollection points3 = new MultipointClass(); int num8 = 0; for (int i = 0; i < pointCount; i++) { other = points2.get_Point(i); if (@operator.Contains(other)) { IPoint point3 = points2.get_Point(i); points3.AddPoint(point3, ref before, ref before); pointArray[i] = point3; } else { pointArray[i] = null; } } IPoint[] pointArray2 = new IPoint[pointCount]; num8 = points3.PointCount; int index = -1; if (num5 < (points3.PointCount - 1)) { for (int j = 0; j < pointCount; j++) { if (pointArray[j] != null) { index++; } if (index == num5) { index = j; break; } } IPoint point4 = new PointClass(); pointArray2[index] = pointArray[index]; pointArray2[index + 1] = points2.get_Point(index + 1); point4.X = (pointArray2[index].X + pointArray2[index + 1].X) / 2.0; point4.Y = (pointArray2[index].Y + pointArray2[index + 1].Y) / 2.0; this.m_pPointcol.AddPoint(point4, ref before, ref before); line.FromPoint = pointArray2[index]; line.ToPoint = pointArray2[index + 1]; this.m_angle.Add(line.Angle); num5++; if (num5 == (num8 - 1)) { num5 = 0; } } } this.ShowFlow(pMap as IActiveView); }