/// <summary> /// Returns the network element information for the specified <paramref name="eid" />. /// </summary> /// <param name="eid">The eid.</param> /// <param name="elementType">Type of the element.</param> /// <returns>Returns a <see cref="IEIDInfo" /> representing the network element information</returns> protected IEIDInfo GetEIDInfo(int eid, esriElementType elementType) { if (elementType == esriElementType.esriETEdge) { if (_EdgesByEID.ContainsKey(eid)) { return(_EdgesByEID[eid]); } } else if (elementType == esriElementType.esriETJunction) { if (_JunctionsByEID.ContainsKey(eid)) { return(_JunctionsByEID[eid]); } } IEIDInfo eidInfo = this.GeometricNetwork.GetEIDInfo(eid, elementType); if (elementType == esriElementType.esriETEdge) { _EdgesByEID.Add(eid, eidInfo); } else if (elementType == esriElementType.esriETJunction) { _JunctionsByEID.Add(eid, eidInfo); } return(eidInfo); }
// // returns an enumeration of EIDs of the network elements of the given element type // private IEnumNetEID GetCurrentEIDs(esriElementType elementType) { INetwork net = GetCurrentNetwork(); IEnumNetEID eids = net.CreateNetBrowser(elementType); return(eids); }
/// <summary> /// Get IEnumNetEID from List of IEIDInfo /// </summary> /// <param name="eidInfos">list of IEIDInfo</param> /// <param name="elementType">element type of eid</param> /// <returns>object IEnumNetEID</returns> internal static IEnumNetEID GetEnumNetEID(List <IEIDInfo> eidInfos, esriElementType elementType) { IEnumNetEIDBuilderGEN enumNetEIDBuilder = new EnumNetEIDArrayClass(); enumNetEIDBuilder.ElementType = elementType; foreach (IEIDInfo eidInfo in eidInfos) { enumNetEIDBuilder.Add(eidInfo.EID); } return(enumNetEIDBuilder as IEnumNetEID); }
/// <summary> /// Gets the network element information for the specified feature. /// </summary> /// <param name="feature">The feature.</param> /// <param name="elementType">Type of the element.</param> /// <returns> /// Returns the <see cref="int" /> representing the network information. /// </returns> protected int GetEID(IFeature feature, out esriElementType elementType) { elementType = esriElementType.esriETNone; INetworkFeature networkFeature = feature as INetworkFeature; if (networkFeature == null) { return(-1); } return(networkFeature.GetEID(out elementType)); }
/// <summary> /// Builds the <see cref="IEnumNetEID" /> from the specified list of elements. /// </summary> /// <param name="source">The source.</param> /// <param name="elementType">Type of the element.</param> /// <param name="eids">The eids.</param> /// <returns> /// A <see cref="IEnumNetEID" /> from the list of elements. /// </returns> /// <exception cref="System.ArgumentNullException">eids</exception> public static IEnumNetEID CreateEnumNetEID(this IGeometricNetwork source, esriElementType elementType, List <int> eids) { if (source == null) { return(null); } if (eids == null) { throw new ArgumentNullException("eids"); } return(source.CreateEnumNetEID(elementType, eids.ToArray())); }
public IFeature GetEIDFeature(IGeometricNetwork geometricNetwork, int eid, esriElementType elementType) { int userClassId, userId, userSubId; bool isValid = ((INetElements)geometricNetwork.Network).IsValidElement(eid, elementType); ((INetElements)geometricNetwork.Network).QueryIDs(eid, elementType, out userClassId, out userId, out userSubId); if (!isValid) { return(null); } return(FindFeature(GetEnumFeatureClasses(geometricNetwork, esriFeatureType.esriFTSimpleEdge), userClassId, userId)); }
/// <summary> /// Gets the network element identifier for the network feature. /// </summary> /// <param name="source">The source.</param> /// <param name="elementType">Type of the element.</param> /// <returns> /// Returns a <see cref="int" /> representing the network element identifier. /// </returns> public static int GetEID(this INetworkFeature source, out esriElementType elementType) { IGeometricNetwork geometricNetwork = source.GeometricNetwork; INetwork network = geometricNetwork.Network; INetElements netElements = (INetElements)network; ISimpleJunctionFeature sjf = source as ISimpleJunctionFeature; elementType = sjf != null ? esriElementType.esriETJunction : esriElementType.esriETEdge; IFeature feature = (IFeature)source; int eid = netElements.GetEID(feature.Class.ObjectClassID, feature.OID, -1, elementType); return(eid); }
private bool _IsDisabled(int eid, esriElementType elementType, INetElements netElements) { // Check enabled field in Network Feature since it might not be in synch with network element enabled property (ESRI bug?) int classID, userID, subID; netElements.QueryIDs(eid, elementType, out classID, out userID, out subID); INetElementDescriptionEdit elementDescription = new NetElementDescriptionClass(); elementDescription.ElementType_2 = elementType; elementDescription.UserClassID_2 = classID; elementDescription.UserID_2 = userID; elementDescription.UserSubID_2 = subID; INetworkFeature netFeature = this.GeometricNetwork.get_NetworkFeature(elementDescription); bool enabled = _IsEnabled((IFeature)netFeature); return(!enabled); }
/// <summary> /// Builds the <see cref="IEnumNetEID" /> from the specified list of elements. /// </summary> /// <param name="source">The source.</param> /// <param name="elementType">Type of the element.</param> /// <param name="eids">The network element IDs.</param> /// <returns> /// A <see cref="IEnumNetEID" /> from the list of elements. /// </returns> /// <exception cref="System.ArgumentNullException">eids</exception> public static IEnumNetEID CreateEnumNetEID(this IGeometricNetwork source, esriElementType elementType, params int[] eids) { if (source == null) { return(null); } if (eids == null) { throw new ArgumentNullException("eids"); } IEnumNetEIDBuilderGEN builder = new EnumNetEIDArrayClass(); builder.ElementType = elementType; builder.Network = source.Network; builder.set_EIDs(ref eids); return((IEnumNetEID)builder); }
/// <summary> /// Returns the <see cref="IEIDInfo" /> for the specified network element. /// </summary> /// <param name="source">The source.</param> /// <param name="eid">The element ID.</param> /// <param name="elementType">Type of the element.</param> /// <param name="returnFeatures">if set to <c>true</c> if the created IEIDInfo should contain features.</param> /// <param name="returnGeometries">if set to <c>true</c> if the created EIDInfo should contain geometries.</param> /// <returns> /// Returns the <see cref="IEIDInfo" /> interface for the network element. /// </returns> public static IEIDInfo GetEIDInfo(this IGeometricNetwork source, int eid, esriElementType elementType, bool returnFeatures, bool returnGeometries) { if (source == null) { return(null); } IEnumNetEID enumNetEID = source.CreateEnumNetEID(elementType, eid); IEIDHelper eidHelper = new EIDHelperClass(); eidHelper.GeometricNetwork = source; eidHelper.ReturnFeatures = returnFeatures; eidHelper.ReturnGeometries = returnGeometries; IEnumEIDInfo enumEIDInfo = eidHelper.CreateEnumEIDInfo(enumNetEID); IEIDInfo eidInfo = enumEIDInfo.Next(); return(eidInfo); }
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); }
/// <summary> /// search the eid nearest from point /// </summary> /// <param name="geometricNetwork">geometric Network</param> /// <param name="searchTolerance">tolerance for search</param> /// <param name="point">point input</param> /// <param name="elementType">type of element</param> /// <returns>return eid</returns> internal static int GetEIDFromPoint(ESRI.ArcGIS.Geodatabase.IGeometricNetwork geometricNetwork, double searchTolerance, IPoint point, esriElementType elementType) { IEnumFeatureClass enumFeatureClassSimple = null; IEnumFeatureClass enumFeatureClassComlex = null; if (elementType == esriElementType.esriETEdge) { enumFeatureClassSimple = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleEdge); enumFeatureClassComlex = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexEdge); } else if (elementType == esriElementType.esriETJunction) { enumFeatureClassSimple = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleJunction); enumFeatureClassComlex = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexJunction); } double distance = double.PositiveInfinity; int featureClassID = -1; IGeometry featureGeometry = null; Helper.FindNearestDistance(enumFeatureClassSimple, point, searchTolerance, ref distance, ref featureClassID, ref featureGeometry); Helper.FindNearestDistance(enumFeatureClassComlex, point, searchTolerance, ref distance, ref featureClassID, ref featureGeometry); if (featureClassID == -1) { return(-1); } IProximityOperator proximityPoint = featureGeometry as IProximityOperator; IPoint p = proximityPoint.ReturnNearestPoint(point, esriSegmentExtension.esriNoExtension); if (elementType == esriElementType.esriETEdge) { return(geometricNetwork.get_EdgeElement(p)); } else if (elementType == esriElementType.esriETJunction) { return(geometricNetwork.get_JunctionElement(p)); } return(-1); }
private IEnumNetEID GetEnumNetEID(int eidToStartFrom, Dictionary<int, int> pathDictionary, INetwork network, IGeometricNetwork geomNet, esriElementType elemType) { IEnumNetEIDBuilder enumEIDBuilder = new EnumNetEIDArrayClass(); enumEIDBuilder.Network = network; enumEIDBuilder.ElementType = elemType; if (eidToStartFrom == -1)//Add all elements to the return dictionary { foreach (KeyValuePair<int, int> kvp in pathDictionary) { int eid = kvp.Key; //Only add to the builder if the element type (junction or edge) is of the type we are looking for if (((eid < 0) && elemType == esriElementType.esriETEdge) || ((eid > 0) && elemType == esriElementType.esriETJunction)) { enumEIDBuilder.Add(Math.Abs( eid)); } } } else { int eid = eidToStartFrom; while (eid != -99999999) // -99999999 means that there is no parent { if (((eid < 0) && elemType == esriElementType.esriETEdge) || ((eid > 0) && elemType == esriElementType.esriETJunction)) { enumEIDBuilder.Add(Math.Abs( eid)); } //Get the junction or edge that feeds this junction or edge eid = pathDictionary[eid]; } } return enumEIDBuilder as IEnumNetEID; }
// // returns an enumeration of EIDs of the network elements of the given element type // private IEnumNetEID GetCurrentEIDs(esriElementType elementType) { INetwork net = GetCurrentNetwork(); IEnumNetEID eids = net.CreateNetBrowser(elementType); return eids; }
/// <summary> /// Returns the <see cref="IEIDInfo" /> for the specified network feature. /// </summary> /// <param name="source">The source.</param> /// <param name="elementType">Type of the element.</param> /// <returns> /// Returns a <see cref="IEIDInfo" /> representing the network information. /// </returns> public static IEIDInfo GetEIDInfo(this INetworkFeature source, out esriElementType elementType) { int eid = source.GetEID(out elementType); return(source.GeometricNetwork.GetEIDInfo(eid, elementType)); }
public IEnumNetEID GetEIDsByOID(INetElements elements, int userId, int userClassID, esriElementType elementType) { return(elements.GetEIDs(userClassID, userId, elementType)); }
/// <summary> /// Returns the <see cref="IEIDInfo" /> for the specified network element. /// </summary> /// <param name="source">The source.</param> /// <param name="eid">The element ID.</param> /// <param name="elementType">Type of the element.</param> /// <returns> /// Returns the <see cref="IEIDInfo" /> interface for the network element. /// </returns> public static IEIDInfo GetEIDInfo(this IGeometricNetwork source, int eid, esriElementType elementType) { return(source.GetEIDInfo(eid, elementType, true, true)); }
/// <summary> /// search the eid nearest from point /// </summary> /// <param name="searchTolerance">tolerance for search</param> /// <param name="point">point input</param> /// <param name="elementType">type of element</param> /// <returns>return eid</returns> private int GetEIDFromPoint(double searchTolerance, IPoint point, esriElementType elementType) { return(Helper.GetEIDFromPoint(this.geometricNetwork, searchTolerance, point, elementType)); }