Exemple #1
0
        private void FlowDiretionBtn_Click(object sender, EventArgs e)
        {
            if (m_GeometryNetwork == null)
            {
                return;
            }
            INetwork network = m_GeometryNetwork.Network;
            //获取描述网络流向的接口
            IUtilityNetworkGEN utilityNetworkGEN = network as IUtilityNetworkGEN;
            //获取线要素类
            //建立线要素类字典
            Dictionary <IFeatureClass, string> dic = new Dictionary <IFeatureClass, string>();

            for (int i = 0; i < this.Mapcontrol.LayerCount; i++)
            {
                IFeatureLayer Lyr = this.Mapcontrol.get_Layer(i) as IFeatureLayer;
                if (Lyr == null)
                {
                    continue;
                }
                if (Lyr.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                {
                    if (!dic.ContainsValue(Lyr.FeatureClass.AliasName))
                    {
                        dic.Add(Lyr.FeatureClass, Lyr.FeatureClass.AliasName);
                    }
                }
            }
            //遍历字典
            foreach (KeyValuePair <IFeatureClass, string> key in dic)
            {
                showFlowDirection(key.Key, utilityNetworkGEN);
            }
            this.Mapcontrol.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, this.Mapcontrol.FullExtent);
        }
Exemple #2
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;
            }
        }