Beispiel #1
0
        private void showFlowDirection(IFeatureClass featureclass, IUtilityNetworkGEN UtilityNetworkGEN)
        {
            try
            {
                //获取要素类的ID号
                INetElements netElement = UtilityNetworkGEN as INetElements;
                //获取流向
                esriFlowDirection flowDirection = new ESRI.ArcGIS.Geodatabase.esriFlowDirection();
                //定义当前要素的EID
                int            currentEID = -1;
                IFeatureCursor pCursor    = featureclass.Search(null, false);
                IFeature       pfte       = pCursor.NextFeature();
                while (pfte != null)
                {
                    currentEID    = netElement.GetEID(featureclass.FeatureClassID, pfte.OID, 0, esriElementType.esriETEdge);
                    flowDirection = UtilityNetworkGEN.GetFlowDirection(currentEID);

                    //绘制流向
                    DrawFlowDirection(pfte, Mapcontrol, flowDirection);
                    pfte = pCursor.NextFeature();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }
        /// <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);
        }
        public static StopperJunctions GetStoppersEID(NetworkContext ctx, string junctionFeatureClassAliasName)
        {
            StopperJunctions stoppers = null;

            if (null != ctx && null != ctx.GeometricNetwork && false == string.IsNullOrEmpty(junctionFeatureClassAliasName))
            {
                IFeatureClass junctionFeatureClass = ctx.GetJunctionFeatureClassIdByAliasName(junctionFeatureClassAliasName);
                INetElements  netElements          = ctx.GeometricNetwork.Network as INetElements;
                if (null != junctionFeatureClass && null != netElements)
                {
                    int ftrCnt = junctionFeatureClass.FeatureCount(null);
                    if (ftrCnt > 0)
                    {
                        int[] arr = new int[ftrCnt];
                        for (int i = 0; i < ftrCnt; ++i)
                        {
                            arr[i] = netElements.GetEID(junctionFeatureClass.FeatureClassID, i + 1, -1, esriElementType.esriETJunction);
                        }
                        stoppers = new StopperJunctions(junctionFeatureClass, arr);
                    }
                }
            }
            return(stoppers);
        }