public static INetElementBarriers GetNetElementBarriers(esriElementType type) { INetElementBarriersGEN sgen = null; IList junBarriers = null; int num2; if (type == esriElementType.esriETJunction) { if (m_JunBarriers.Count == 0) { return(null); } junBarriers = m_JunBarriers; } else if (type == esriElementType.esriETEdge) { if (m_EdgeBarriers.Count == 0) { return(null); } junBarriers = m_EdgeBarriers; } if (junBarriers == null) { return(null); } sgen = new NetElementBarriersClass { ElementType = type, Network = m_pAnalystGN.Network }; IList list2 = new ArrayList(); IList list3 = new ArrayList(); IList list4 = null; for (num2 = 0; num2 < junBarriers.Count; num2++) { NetFlagWrap wrap = junBarriers[num2] as NetFlagWrap; int userClassID = wrap.NetFlag.UserClassID; int index = list2.IndexOf(userClassID); if (index == -1) { list2.Add(userClassID); list4 = new ArrayList(); list4.Add(wrap.NetFlag.UserID); list3.Add(list4); } else { list4 = list3[index] as IList; list4.Add(wrap.NetFlag.UserID); } } for (num2 = 0; num2 < list2.Count; num2++) { list4 = list3[num2] as IList; int[] array = new int[list4.Count]; list4.CopyTo(array, 0); sgen.SetBarriers((int)list2[num2], ref array); } return(sgen as INetElementBarriers); }
public static List <int> StreamTrace(IGeometricNetwork geometricNetwork, StartFlagEdge edge, List <int> disabledFeatureClassIds, StopperJunctions stoppers, bool isUpStream, int maxFeatureCount, ServerLogger logger) { esriFlowMethod direction = isUpStream ? esriFlowMethod.esriFMUpstream : esriFlowMethod.esriFMDownstream; if (null == geometricNetwork || null == edge || maxFeatureCount <= 0) { return(null); } ITraceFlowSolverGEN traceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolverGEN; INetSolver netSolver = traceFlowSolver as INetSolver; netSolver.SourceNetwork = geometricNetwork.Network; INetFlag netFlag = new EdgeFlagClass(); netFlag.UserClassID = edge.FeatureClassID; netFlag.UserID = edge.FeatureID; //no idea when to assign -1, when to do 0 netFlag.UserSubID = -1; traceFlowSolver.PutEdgeOrigins(new IEdgeFlag[1] { netFlag as IEdgeFlag }); if (null != disabledFeatureClassIds) { foreach (int il in disabledFeatureClassIds) { if (il > 0) { netSolver.DisableElementClass(il); } } } if (null != stoppers && null != stoppers.Stoppers && stoppers.Stoppers.Length > 0) { INetElementBarriersGEN netBarriersGEN = null; netBarriersGEN = new NetElementBarriersClass() as INetElementBarriersGEN; netBarriersGEN.ElementType = esriElementType.esriETJunction; netBarriersGEN.Network = geometricNetwork.Network; netBarriersGEN.SetBarriers(stoppers.FeatureClassID, stoppers.Stoppers); netSolver.set_ElementBarriers(esriElementType.esriETJunction, netBarriersGEN as INetElementBarriers); } IEnumNetEID junctionEIDs = null; IEnumNetEID edgeEIDs = null; traceFlowSolver.TraceIndeterminateFlow = false; try { traceFlowSolver.FindFlowElements(direction, esriFlowElements.esriFEEdges, out junctionEIDs, out edgeEIDs); if (null != edgeEIDs) { if (edgeEIDs.Count <= maxFeatureCount) { IEIDHelper eidHelper = new EIDHelperClass(); eidHelper.GeometricNetwork = geometricNetwork; eidHelper.ReturnGeometries = false; eidHelper.ReturnFeatures = true; //eidHelper.AddField("FType"); IEnumEIDInfo eidInfos = eidHelper.CreateEnumEIDInfo(edgeEIDs); eidInfos.Reset(); IEIDInfo eidInfo = null; List <int> ftrs = new List <int>(); //IFeature cadFtr = null; //int ftype; while ((eidInfo = eidInfos.Next()) != null) { ftrs.Add(eidInfo.Feature.OID); /*cadFtr = eidInfo.Feature; * if (null != cadFtr.get_Value(edgeTypeId) && int.TryParse(cadFtr.get_Value(edgeTypeId).ToString(), out ftype)) * { * if(460 == ftype || 558 == ftype) * ftrs.Add(cadFtr); * }*/ } return(ftrs); } } } catch (Exception e) { if (null != logger) { logger.LogMessage(ServerLogger.msgType.error, typeof(AOUtilities).Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, ErrorCode, e.Message); } } finally { ReleaseCOMObj(traceFlowSolver); } return(null); }