/// <summary>
        /// 设置障碍点
        /// </summary>
        /// <param name="pNetSolver"></param>
        /// <param name="breakPoints"></param>
        /// <param name="pGeometricNet"></param>
        /// <param name="pDisc"></param>
        private void SetBarries(INetSolver pNetSolver, List <IPoint> breakPoints, IGeometricNetwork pGeometricNet, double pDisc)
        {
            INetwork     pNetwork     = pGeometricNet.Network;
            INetElements pNetElements = pNetwork as INetElements;
            IPointToEID  pPointToEID  = new PointToEIDClass();

            pPointToEID.GeometricNetwork = pGeometricNet;
            pPointToEID.SnapTolerance    = pDisc;
            ISelectionSetBarriers barriers = new SelectionSetBarriersClass();

            foreach (var point in breakPoints)
            {
                //寻找障碍点最近的线要素,从而添加爆管线
                int    nearEdgeID;
                IPoint outIpoint;
                double precent;
                pPointToEID.GetNearestEdge(point, out nearEdgeID, out outIpoint, out precent);
                int userClassID;
                int userID;
                int userSubID;
                //查询相关ID
                pNetElements.QueryIDs(nearEdgeID, esriElementType.esriETJunction, out userClassID, out userID, out userSubID);
                //添加障碍点
                barriers.Add(userClassID, userID);
            }
            pNetSolver.SelectionSetBarriers = barriers;
        }
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;
            }
        }
Exemple #3
0
        private void DrawTraceRsult(IEnumNetEID JunctionEIDs, IEnumNetEID EdgEIDs)
        {
            if (JunctionBarrierEIDs == null || EdgEIDs == null)
            {
                return;
            }
            INetElements netElements = m_GeometryNetwork.Network as INetElements;
            int          userClssID  = -1;
            int          userID      = -1;
            int          userSubID   = -1;
            int          eid         = -1;
            //
            IFeatureClass fteClss;
            IFeature      feature;
            //设置管点和管线显示的Symbol
            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();

            simpleMarkerSymbol.Color = Method.Getcolor(255, 0, 0);
            simpleMarkerSymbol.Size  = 6;
            simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();

            simpleLineSymbol.Color = Method.Getcolor(255, 0, 0);
            simpleLineSymbol.Width = 2;
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            IElement element;

            //获取管点结果
            for (int i = 0; i < JunctionEIDs.Count; i++)
            {
                eid = JunctionEIDs.Next();
                netElements.QueryIDs(eid, esriElementType.esriETJunction, out userClssID, out userID, out userSubID);
                fteClss = GetFteClssByID(userClssID, this.Mapcontrol.Map);
                if (fteClss != null)
                {
                    feature          = fteClss.GetFeature(userID);
                    element          = new MarkerElementClass();
                    element.Geometry = feature.Shape;
                    ((IMarkerElement)element).Symbol   = simpleMarkerSymbol;
                    ((IElementProperties)element).Name = "Result";
                    this.Mapcontrol.ActiveView.GraphicsContainer.AddElement(element, 0);
                }
            }
            //获取管线结果
            for (int j = 0; j < EdgEIDs.Count; j++)
            {
                eid = EdgEIDs.Next();
                netElements.QueryIDs(eid, esriElementType.esriETEdge, out userClssID, out userID, out userSubID);
                fteClss = GetFteClssByID(userClssID, this.Mapcontrol.Map);
                if (fteClss != null)
                {
                    feature          = fteClss.GetFeature(userID);
                    element          = new LineElementClass();
                    element.Geometry = feature.Shape;
                    ((ILineElement )element).Symbol    = simpleLineSymbol;
                    ((IElementProperties)element).Name = "Result";
                    this.Mapcontrol.ActiveView.GraphicsContainer.AddElement(element, 0);
                }
            }
        }
Exemple #4
0
 //解决路径
 public void SolvePath(string WeightName)
 {
     try
     {
         int    intEdgeUserClassID;
         int    intEdgeUserID;
         int    intEdgeUserSubID;
         int    intEdgeID;
         IPoint ipFoundEdgePoint;
         double dblEdgePercent;
         ITraceFlowSolverGEN ipTraceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolverGEN;
         INetSolver          ipNetSolver       = ipTraceFlowSolver as INetSolver;
         INetwork            ipNetwork         = m_ipGeometricNetwork.Network;
         ipNetSolver.SourceNetwork = ipNetwork;
         INetElements ipNetElements = ipNetwork as INetElements;
         int          intCount      = m_ipPoints.PointCount;//这里的points有值吗?
         //定义一个边线旗数组
         IEdgeFlag[] pEdgeFlagList = new EdgeFlagClass[intCount];
         for (int i = 0; i < intCount; i++)
         {
             INetFlag ipNetFlag   = new EdgeFlagClass() as INetFlag;
             IPoint   ipEdgePoint = m_ipPoints.get_Point(i);
             //查找输入点的最近的边线
             m_ipPointToEID.GetNearestEdge(ipEdgePoint, out intEdgeID, out ipFoundEdgePoint, out dblEdgePercent);
             ipNetElements.QueryIDs(intEdgeID, esriElementType.esriETEdge, out intEdgeUserClassID, out intEdgeUserID, out intEdgeUserSubID);
             ipNetFlag.UserClassID = intEdgeUserClassID;
             ipNetFlag.UserID      = intEdgeUserID;
             ipNetFlag.UserSubID   = intEdgeUserSubID;
             IEdgeFlag pTemp = (IEdgeFlag)(ipNetFlag as IEdgeFlag);
             pEdgeFlagList[i] = pTemp;
         }
         ipTraceFlowSolver.PutEdgeOrigins(ref pEdgeFlagList);
         INetSchema        ipNetSchema        = ipNetwork as INetSchema;
         INetWeight        ipNetWeight        = ipNetSchema.get_WeightByName(WeightName);
         INetSolverWeights ipNetSolverWeights = ipTraceFlowSolver as INetSolverWeights;
         ipNetSolverWeights.FromToEdgeWeight = ipNetWeight; //开始边线的权重
         ipNetSolverWeights.ToFromEdgeWeight = ipNetWeight; //终止边线的权重
         object[] vaRes = new object[intCount - 1];
         //通过findpath得到边线和交汇点的集合
         ipTraceFlowSolver.FindPath(esriFlowMethod.esriFMConnected,
                                    esriShortestPathObjFn.esriSPObjFnMinSum,
                                    out m_ipEnumNetEID_Junctions, out m_ipEnumNetEID_Edges, intCount - 1, ref vaRes);
         //计算元素成本
         m_dblPathCost = 0;
         for (int i = 0; i < vaRes.Length; i++)
         {
             double m_Va = (double)vaRes[i];//我修改过
             m_dblPathCost = m_dblPathCost + m_Va;
         }
         m_ipPolyline = null;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Exemple #5
0
        private void InitBrokePoint()
        {
            int userClassID;
            int userID;
            int userSubID;
            IFeatureClassContainer featureDataset =
                (IFeatureClassContainer)this._nearestEdgeInfo.GeometricNetwork.FeatureDataset;
            IFeatureClass pointClass = null;
            IFeatureClass lineClass  = null;
            int           num3       = 0;


            pointClass = _pipeLayer.GetLayers(enumPipelineDataType.Point)[0].FeatureClass;
            lineClass  = _pipeLayer.GetLayers(enumPipelineDataType.Line)[0].FeatureClass;
            this._networkInfo.LayerLine =
                MapHelper.FindFeatureLayerByFCName(m_iApp.FocusMap as IBasicMap, ((IDataset)lineClass).Name, false) as
                IFeatureLayer;
            this._networkInfo.LayerPoint =
                MapHelper.FindFeatureLayerByFCName(m_iApp.FocusMap as IBasicMap, ((IDataset)pointClass).Name, false) as
                IFeatureLayer;
            INetElements network = (INetElements)this._nearestEdgeInfo.GeometricNetwork.Network;

            network.QueryIDs(this._nearestEdgeInfo.EdgeID, esriElementType.esriETEdge, out userClassID, out userID,
                             out userSubID);
            this._networkInfo.LineFeature = lineClass.GetFeature(userID);
            Label label = this.lblPickPipeInfo;

            string[] name = new string[]
            { this._networkInfo.LayerLine.Name, ",", lineClass.OIDFieldName, "=", userID.ToString() };
            label.Text = string.Concat(name);
            string.Format("\r\n爆管点位置({0:f2},{1:f2},{2:f2})", this._nearestEdgeInfo.Location.X,
                          this._nearestEdgeInfo.Location.Y, this._nearestEdgeInfo.Location.Z);

            //初始化下拉菜单

            cmbDomainValues.Items.Clear();
            IBasicLayerInfo pLayerInfo = _pipeLayer.GetLayers(enumPipelineDataType.Point)[0];
            IYTField        pField     = pLayerInfo.GetField(PipeConfigWordHelper.PointWords.FSW);

            this.label1.Text = pField.Name;
            if (!string.IsNullOrEmpty(pField.DomainValues))
            {
                string[] domianValues = pField.DomainValues.Split('/');
                foreach (var onePair in domianValues)
                {
                    cmbDomainValues.Items.Add(onePair);
                }
            }
            if (this.listFieldValues.Items.Count == 0)
            {
                this.listFieldValues.Items.Add("阀门");
                this.listFieldValues.Items.Add("阀门井");
            }
        }
Exemple #6
0
        private Dictionary <IPoint, int> _ExtractUpstreamPipeEnds()
        {
            int iInletClassID = _inletClass.FeatureClassID;

            INetwork     network     = _geometricNetwork.Network;
            INetElements netElements = network as INetElements;
            INetTopology netTopology = network as INetTopology;

            Dictionary <IPoint, int> endPoints = new Dictionary <IPoint, int>();

            IEnumNetEID netEnum = network.CreateNetBrowser(esriElementType.esriETJunction);
            int         junctionCount = netEnum.Count;
            int         classId, userId, subId, edgeId;
            bool        towardJunction;
            int         junctionId = -1;

            for (int j = 0; j < junctionCount; j++)
            {
                junctionId = netEnum.Next();

                netElements.QueryIDs(junctionId, esriElementType.esriETJunction, out classId, out userId, out subId);

                if (classId != iInletClassID)
                {
                    bool disabled = false;
                    if (_excludeDisabled)
                    {
                        disabled = _IsDisabled(junctionId, esriElementType.esriETJunction, netElements);
                    }

                    if (!(_excludeDisabled && disabled))
                    {
                        int  edgeCount     = netTopology.GetAdjacentEdgeCount(junctionId);
                        bool isUpstreamEnd = edgeCount > 0; // initializing only (zero edge count always excluded)
                        for (int e = 0; e < edgeCount; e++)
                        {
                            netTopology.GetAdjacentEdge(junctionId, e, out edgeId, out towardJunction);
                            if (towardJunction)
                            {
                                isUpstreamEnd = false;
                                break;
                            }
                        }
                        if (isUpstreamEnd)
                        {
                            endPoints.Add(_geometricNetwork.get_GeometryForJunctionEID(junctionId) as IPoint, junctionId);
                        }
                    }
                }
            }

            return(endPoints);
        }
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            base.OnMouseDown(Button, Shift, X, Y);
            if (Button != 1)
            {
                return;
            }
            //获取坐标点
            IPoint inPoint = new PointClass();

            inPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            IMap map = m_hookHelper.FocusMap;

            //查询与坐标点最近的管点
            IPointToEID pointToEID = new PointToEIDClass();

            //
            if (geomretyNetwork == null)
            {
                return;
            }
            pointToEID.GeometricNetwork = geomretyNetwork;
            pointToEID.SourceMap        = map;
            pointToEID.SnapTolerance    = 10;
            IPoint outPoint           = new PointClass();
            int    nearestJunctionEID = -1;

            pointToEID.GetNearestJunction(inPoint, out nearestJunctionEID, out outPoint);
            if (outPoint == null || outPoint.IsEmpty)
            {
                return;
            }
            //获取管点标识并加入列表
            INetElements netElemnts = geomretyNetwork.Network  as INetElements;

            int UserClassID = 0;
            int UserID      = 0;
            int UserSubID   = 0;

            netElemnts.QueryIDs(nearestJunctionEID, esriElementType.esriETJunction, out UserClassID, out UserID, out UserSubID);

            //设置并添加管点标识
            INetFlag netFlag = new JunctionFlagClass() as INetFlag;

            netFlag.UserClassID = UserClassID;
            netFlag.UserID      = UserID;
            netFlag.UserSubID   = UserSubID;
            //
            listJunctionFlags.Add(netFlag as IJunctionFlag);
            //绘制点要素
            DrawElement(outPoint);
        }
Exemple #8
0
        private void InitSpatial(int lnversionid)
        {
            //reference layers
            pFeatureworkspace = Utility.GetWorkspaceForVersion(lnversionid) as IFeatureWorkspace;            //GlobalSettings.UserWorkspace as IFeatureWorkspace;
            HarvestUnits      = pFeatureworkspace.OpenFeatureClass(GlobalSettings.Settings.HarvestUnitFeatureClassName);
            RoadEdge          = pFeatureworkspace.OpenFeatureClass(GlobalSettings.Settings.RoadFeatureClassName);
            RMAPsites         = pFeatureworkspace.OpenFeatureClass(GlobalSettings.Settings.DeliveryPointFeatureClassName);

            //network
            INetworkWorkspace NetWS = Utility.GetWorkspaceForVersion(lnversionid) as INetworkWorkspace;            //GlobalSettings.UserWorkspace as INetworkWorkspace;

            roadNet         = NetWS.OpenNetwork(GlobalSettings.Settings.RoadNetworkName, esriNetworkType.esriNTStreetNetwork, esriNetworkAccess.esriNAReadOnly);
            RoadNetElements = roadNet as INetElements;
        }
Exemple #9
0
        public void SolvePath(string WeightName)
        {
            int num;
            ITraceFlowSolver solver  = (ITraceFlowSolver) new TraceFlowSolverClass();
            INetSolver       solver2 = (INetSolver)solver;
            INetwork         network = this.m_ipGeometricNetwork.Network;

            solver2.SourceNetwork = network;
            INetElements elements = (INetElements)network;

            IEdgeFlag[] edgeOrigins = new IEdgeFlag[this.m_ipPoints.PointCount + 1];
            for (num = 0; num < this.m_ipPoints.PointCount; num++)
            {
                IPoint   point;
                int      num2;
                double   num3;
                int      num4;
                int      num5;
                int      num6;
                INetFlag flag       = new EdgeFlagClass();
                IPoint   inputPoint = this.m_ipPoints.get_Point(num);
                this.m_ipPointToEID.GetNearestEdge(inputPoint, out num2, out point, out num3);
                elements.QueryIDs(num2, esriElementType.esriETEdge, out num4, out num5, out num6);
                flag.UserClassID = num4;
                flag.UserID      = num5;
                flag.UserSubID   = num6;
                edgeOrigins[num] = (IEdgeFlag)flag;
            }
            (solver as ITraceFlowSolverGEN).PutEdgeOrigins(ref edgeOrigins);
            try
            {
                INetSolverWeights weights = (INetSolverWeights)solver;
                weights.JunctionWeight   = this.JunctionWeight;
                weights.FromToEdgeWeight = this.FromToEdgeWeight;
                weights.ToFromEdgeWeight = this.ToFromEdgeWeight;
            }
            catch
            {
            }
            object[] segmentCosts = new object[this.m_ipPoints.PointCount];
            (solver as ITraceFlowSolverGEN).FindPath(esriFlowMethod.esriFMConnected,
                                                     esriShortestPathObjFn.esriSPObjFnMinSum, out this.m_ipEnumNetEID_Junctions,
                                                     out this.m_ipEnumNetEID_Edges, this.m_ipPoints.PointCount - 1, ref segmentCosts);
            this.m_dblPathCost = 0.0;
            for (num = 0; num < segmentCosts.Length; num++)
            {
                this.m_dblPathCost += (double)segmentCosts[num];
            }
            this.m_ipPolyline = null;
        }
        /// <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);
        }
        /// <summary>
        /// 最短路径分析
        /// </summary>
        /// <param name="pMap"></param>
        /// <param name="pGeometricNet"></param>
        /// <param name="pCollection"></param>
        /// <param name="weightName"></param>
        /// <param name="pDisc"></param>
        /// <returns></returns>
        public static IPolyline DistanceFun(IMap pMap, IGeometricNetwork pGeometricNet, IPointCollection pCollection, string weightName, double pDisc)
        {
            //几何网络分析接口
            ITraceFlowSolverGEN pTraceFlowGen = new TraceFlowSolverClass() as ITraceFlowSolverGEN;
            INetSolver          pNetSolver    = pTraceFlowGen as INetSolver;
            //获取网络
            INetwork pNetwork = pGeometricNet.Network;

            //设置该网络为几何分析处理网络
            pNetSolver.SourceNetwork = pNetwork;
            //网络元素
            INetElements pNetElements = pNetwork as INetElements;

            //根据输入点建立旗帜数组
            IJunctionFlag[] pJunctionFlags = GetJunctionFlags(pMap, pGeometricNet, pCollection, pDisc);
            //将旗帜数组添加到处理类中
            pTraceFlowGen.PutJunctionOrigins(ref pJunctionFlags);
            //设置边线的权重 可以考虑使用点权重
            SetWeight(weightName, pTraceFlowGen, pNetwork);
            //获取边线和交汇点的集合
            IEnumNetEID junctionEIDs;
            IEnumNetEID netEIDS;

            object[] pRec = new object[pCollection.PointCount - 1];
            pTraceFlowGen.FindPath(esriFlowMethod.esriFMConnected, esriShortestPathObjFn.esriSPObjFnMinSum, out junctionEIDs, out netEIDS, pCollection.PointCount - 1, ref pRec);
            //获取最短路径
            IPolyline           pPolyline           = new PolylineClass();
            IGeometryCollection pGeometryCollection = pPolyline as IGeometryCollection;
            ISpatialReference   pSpatialReference   = pMap.SpatialReference;
            IEIDHelper          pEIDHelper          = new EIDHelperClass();

            pEIDHelper.GeometricNetwork       = pGeometricNet;
            pEIDHelper.OutputSpatialReference = pSpatialReference;
            pEIDHelper.ReturnGeometries       = true;
            IEnumEIDInfo pEnumEIDInfo = pEIDHelper.CreateEnumEIDInfo(netEIDS);
            int          Count        = pEnumEIDInfo.Count;

            pEnumEIDInfo.Reset();
            for (int i = 0; i < Count; i++)
            {
                IEIDInfo  pEIDInfo  = pEnumEIDInfo.Next();
                IGeometry pGeometry = pEIDInfo.Geometry;
                pGeometryCollection.AddGeometryCollection(pGeometry as IGeometryCollection);
            }
            return(pPolyline);
        }
Exemple #12
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }
            IPoint inPoint = new PointClass();

            inPoint = this.m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            IMap map = this.m_hookHelper.FocusMap;

            //查询与点最近的EID
            IPointToEID pointToEID = new PointToEIDClass();

            pointToEID.GeometricNetwork = geometricNetwork;
            pointToEID.SourceMap        = map;
            pointToEID.SnapTolerance    = 10;

            IPoint outPoint      = new PointClass();
            int    nearestEdgeID = -1;
            double percent       = -1;

            pointToEID.GetNearestEdge(inPoint, out nearestEdgeID, out outPoint, out percent);

            if (outPoint == null || outPoint.IsEmpty)
            {
                return;
            }
            //获取与点最邻近的边
            INetElements netElments = geometricNetwork.Network as INetElements;
            int          userClSSID = 0;
            int          userID     = 0;
            int          userSubID  = 0;

            netElments.QueryIDs(nearestEdgeID, esriElementType.esriETEdge, out userClSSID, out userID, out userSubID);
            INetFlag netFlag = new EdgeFlagClass() as INetFlag;

            netFlag.UserClassID = userClSSID;
            netFlag.UserID      = userID;
            netFlag.UserSubID   = userSubID;
            //添加管线标识
            listEdgeFlag.Add(netFlag as IEdgeFlag);

            //绘制点所在的边
            DrawElement(outPoint);
        }
Exemple #13
0
        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);
        }
Exemple #14
0
        public void GetSortInfos(ArrayList pSortInfos)
        {
            pSortInfos.Clear();
            IMap         map         = m_context.FocusMap;
            IEnumFeature enumFeature = (IEnumFeature)map.FeatureSelection;
            IFeature     feature     = enumFeature.Next();

            if (feature != null)
            {
                do
                {
                    if (feature.FeatureType == esriFeatureType.esriFTSimpleEdge)
                    {
                        IPolyline egLine    = feature.Shape as IPolyline;
                        IPoint    newCenter = new PointClass();
                        egLine.QueryPoint(esriSegmentExtension.esriNoExtension, 0.01, true, newCenter);
                        IEdgeFeature  pEgFeature    = feature as IEdgeFeature;
                        IFeatureClass pClass        = feature.Class as IFeatureClass;
                        INetworkClass pNetworkClass = pClass as INetworkClass;
                        INetElements  network       = pNetworkClass.GeometricNetwork.Network as INetElements;
                        IEnumFeature  enumFeatures  = pNetworkClass.GeometricNetwork.SearchForNetworkFeature(newCenter,
                                                                                                             esriFeatureType.esriFTSimpleEdge);

                        IEdgeFeature       edgeFeature     = (IEdgeFeature)enumFeatures.Next();
                        ISimpleEdgeFeature simpedgeFeature = (ISimpleEdgeFeature)edgeFeature;
                        pSortInfos.Add(new SortInfo
                        {
                            SmID    = simpedgeFeature.EID,
                            SmFNode = edgeFeature.FromJunctionEID,
                            SmTNode = edgeFeature.ToJunctionEID
                        });
                    }
                    //IEdgeFeature edgeFeature = (IEdgeFeature) feature;
                    //pSortInfos.Add(new SortInfo
                    //{
                    //    SmID = Convert.ToInt32(feature.get_Value(0).ToString()),
                    //    SmFNode = edgeFeature.FromJunctionEID,
                    //    SmTNode = edgeFeature.ToJunctionEID
                    //});
                    feature = enumFeature.Next();
                } while (feature != null);
            }
        }
Exemple #15
0
 private void btnStartAnalysis_Click(object obj, EventArgs eventArgs)
 {
     if (this._nearestEdgeInfo.GeometricNetwork != null)
     {
         this._networkInfo.arrayList_1.Clear();
         this._networkInfo.arrayList_0.Clear();
         INetElements     netElements     = (INetElements)this._nearestEdgeInfo.GeometricNetwork.Network;
         ITraceFlowSolver traceFlowSolver = this.GetTraceFlowSolver();
         IEnumNetEID      junctionEIDs;
         IEnumNetEID      edgeEIDs;
         traceFlowSolver.FindFlowEndElements(this.GetFindMethod(), esriFlowElements.esriFEJunctions,
                                             out junctionEIDs, out edgeEIDs);
         int num;
         int num2;
         int num3;
         for (int i = junctionEIDs.Next(); i > 0; i = junctionEIDs.Next())
         {
             netElements.QueryIDs(i, (esriElementType)1, out num, out num2, out num3);
             IFeature feature = this._networkInfo.LayerPoint.FeatureClass.GetFeature(num2);
             int      num4    = feature.Fields.FindField(this.label1.Text);
             if (num4 == -1)
             {
                 return;
             }
             if (this.listFieldValues.Items.IndexOf(feature.get_Value(num4)) != -1)
             {
                 this._networkInfo.arrayList_0.Add(feature);
             }
         }
         traceFlowSolver.FindFlowElements(this.GetFindMethod(), esriFlowElements.esriFEEdges, out junctionEIDs,
                                          out edgeEIDs);
         for (int i = edgeEIDs.Next(); i > 0; i = edgeEIDs.Next())
         {
             netElements.QueryIDs(i, esriElementType.esriETEdge, out num, out num2, out num3);
             IFeature feature2 = this._networkInfo.LayerLine.FeatureClass.GetFeature(num2);
             this._networkInfo.arrayList_1.Add(feature2);
         }
         m_iApp.FocusMap.ClearSelection();
         this.CreateResultElements();
         this.CreateBlockElements();
         this.FillResultToTreeView();
     }
 }
Exemple #16
0
        public ITraceFlowSolver GetTraceFlowSolver()
        {
            INetElements netElements = (INetElements)this._nearestEdgeInfo.GeometricNetwork.Network;
            int          userClassID = 0;
            int          userID      = 0;
            int          userSubID   = 0;

            netElements.QueryIDs(this._nearestEdgeInfo.EdgeID, esriElementType.esriETEdge, out userClassID, out userID,
                                 out userSubID);
            IEdgeFlag edgeFlag = new EdgeFlag();

            ((INetFlag)edgeFlag).UserClassID = (userClassID);
            ((INetFlag)edgeFlag).UserID      = (userID);
            ((INetFlag)edgeFlag).UserSubID   = (userSubID);
            ITraceFlowSolver traceFlowSolver = (ITraceFlowSolver) new TraceFlowSolver();

            ((INetSolver)traceFlowSolver).SourceNetwork        = (this._nearestEdgeInfo.GeometricNetwork.Network);
            ((INetSolver)traceFlowSolver).SelectionSetBarriers = (this.GetSelectionSetBarries());
            traceFlowSolver.PutEdgeOrigins(1, ref edgeFlag);
            return(traceFlowSolver);
        }
Exemple #17
0
        public void PickThroughValve(IPoint _pMousePoint)
        {
            IPointToEID pointToEIDClass = new PointToEID();

            pointToEIDClass.GeometricNetwork = (this._nearestEdgeInfo.GeometricNetwork);
            pointToEIDClass.SourceMap        = (m_iApp.FocusMap);
            pointToEIDClass.SnapTolerance    = (m_iApp.ActiveView.Extent.Width / 200.0);
            int    junctionEID = 0;
            IPoint location    = null;

            pointToEIDClass.GetNearestJunction(_pMousePoint, out junctionEID, out location);
            if (location != null)
            {
                INetElements netElements = (INetElements)this._nearestEdgeInfo.GeometricNetwork.Network;
                int          userClassID;
                int          userID;
                int          userSubID;
                netElements.QueryIDs(junctionEID, esriElementType.esriETJunction, out userClassID, out userID,
                                     out userSubID);
                IFeature feature = this._networkInfo.LayerPoint.FeatureClass.GetFeature(userID);
                this.listOutBarriers.Items.Add(feature.OID.ToString());
            }
        }
        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);
        }
        /// <summary>
        /// 根据输入点建立旗帜数组
        /// </summary>
        /// <param name="pGeometricNet"></param>
        /// <param name="pCollection"></param>
        /// <param name="pDisc"></param>
        /// <param name="pNetElements"></param>
        /// <returns></returns>
        private static IJunctionFlag[] GetJunctionFlags(IMap pMap, IGeometricNetwork pGeometricNet, IPointCollection pCollection, double pDisc)
        {
            INetElements pNetElements = pGeometricNet.Network as INetElements;
            int          pCount       = pCollection.PointCount;

            IJunctionFlag[] pJunctionFlags = new JunctionFlagClass[pCount];
            IPointToEID     pPointToEID    = new PointToEIDClass();

            pPointToEID.SourceMap        = pMap;
            pPointToEID.GeometricNetwork = pGeometricNet;
            //从输入点找最近节点的距离阈值
            pPointToEID.SnapTolerance = pDisc;
            for (int i = 0; i < pCount; i++)
            {
                INetFlag pNetFlag   = new JunctionFlagClass();
                IPoint   pEdgePoint = pCollection.get_Point(i);
                #region 查找输入点最近的节点的ID
                int    nearestJunctionID;
                IPoint locationPoint;
                int    userClassID;
                int    userID;
                int    userSubID;
                pPointToEID.GetNearestJunction(pEdgePoint, out nearestJunctionID, out locationPoint);
                pNetElements.QueryIDs(nearestJunctionID, esriElementType.esriETJunction, out userClassID, out userID, out userSubID);
                #endregion
                //设置网络旗帜的节点的ID
                pNetFlag.UserClassID = userClassID;
                pNetFlag.UserID      = userID;
                pNetFlag.UserSubID   = userSubID;
                //节点旗帜
                IJunctionFlag pJuncF = pNetFlag as IJunctionFlag;
                //添加
                pJunctionFlags[i] = pJuncF;
            }
            return(pJunctionFlags);
        }
Exemple #20
0
        private void SolvePath(string weightName)
        {
            //创建ITraceFlowSolverGEN
            ITraceFlowSolverGEN pTraceFlowSolverGEN = new TraceFlowSolverClass();
            INetSolver          pNetSolver          = pTraceFlowSolverGEN as INetSolver;
            //初始化用于路径计算的Network
            INetwork pNetWork = mGeometricNetwork.Network;

            pNetSolver.SourceNetwork = pNetWork;

            //获取分析经过的点的个数
            int intCount = mPointCollectionNet.PointCount;

            if (intCount < 1)
            {
                return;
            }


            INetFlag pNetFlag;

            //用于存储路径计算得到的边
            IEdgeFlag[] pEdgeFlags = new IEdgeFlag[intCount];


            IPoint pEdgePoint = new PointClass();
            int    intEdgeEID;
            IPoint pFoundEdgePoint;
            double dblEdgePercent;

            //用于获取几何网络元素的UserID, UserClassID,UserSubID
            INetElements pNetElements = pNetWork as INetElements;
            int          intEdgeUserClassID;
            int          intEdgeUserID;
            int          intEdgeUserSubID;

            for (int i = 0; i < intCount; i++)
            {
                pNetFlag = new EdgeFlagClass();
                //获取用户点击点
                pEdgePoint = mPointCollectionNet.get_Point(i);
                //获取距离用户点击点最近的边
                mPointToEID.GetNearestEdge(pEdgePoint, out intEdgeEID, out pFoundEdgePoint, out dblEdgePercent);
                if (intEdgeEID <= 0)
                {
                    continue;
                }
                //根据得到的边查询对应的几何网络中的元素UserID, UserClassID,UserSubID
                pNetElements.QueryIDs(intEdgeEID, esriElementType.esriETEdge,
                                      out intEdgeUserClassID, out intEdgeUserID, out intEdgeUserSubID);
                if (intEdgeUserClassID <= 0 || intEdgeUserID <= 0)
                {
                    continue;
                }

                pNetFlag.UserClassID = intEdgeUserClassID;
                pNetFlag.UserID      = intEdgeUserID;
                pNetFlag.UserSubID   = intEdgeUserSubID;
                pEdgeFlags[i]        = pNetFlag as IEdgeFlag;
            }
            //设置路径求解的边
            pTraceFlowSolverGEN.PutEdgeOrigins(ref pEdgeFlags);

            //路径计算权重
            INetSchema pNetSchema = pNetWork as INetSchema;
            INetWeight pNetWeight = pNetSchema.get_WeightByName(weightName);

            if (pNetWeight == null)
            {
                return;
            }

            //设置权重,这里双向的权重设为一致
            INetSolverWeights pNetSolverWeights = pTraceFlowSolverGEN as INetSolverWeights;

            pNetSolverWeights.ToFromEdgeWeight = pNetWeight;
            pNetSolverWeights.FromToEdgeWeight = pNetWeight;

            object[] arrResults = new object[intCount - 1];
            //执行路径计算
            pTraceFlowSolverGEN.FindPath(esriFlowMethod.esriFMConnected, esriShortestPathObjFn.esriSPObjFnMinSum,
                                         out mEnumNetEID_Junctions, out mEnumNetEID_Edges, intCount - 1, ref arrResults);

            //获取路径计算总代价(cost)
            mdblPathCost = 0;
            for (int i = 0; i < intCount - 1; i++)
            {
                mdblPathCost += (double)arrResults[i];
            }
        }
		private void InitSpatial(int lnversionid)
		{
			//reference layers
			pFeatureworkspace = Utility.GetWorkspaceForVersion(lnversionid) as IFeatureWorkspace;//GlobalSettings.UserWorkspace as IFeatureWorkspace;
			HarvestUnits = pFeatureworkspace.OpenFeatureClass(GlobalSettings.Settings.HarvestUnitFeatureClassName);
			RoadEdge = pFeatureworkspace.OpenFeatureClass(GlobalSettings.Settings.RoadFeatureClassName);
			RMAPsites = pFeatureworkspace.OpenFeatureClass(GlobalSettings.Settings.DeliveryPointFeatureClassName);

			//network
			INetworkWorkspace NetWS = Utility.GetWorkspaceForVersion(lnversionid) as INetworkWorkspace;//GlobalSettings.UserWorkspace as INetworkWorkspace;
			roadNet = NetWS.OpenNetwork(GlobalSettings.Settings.RoadNetworkName, esriNetworkType.esriNTStreetNetwork, esriNetworkAccess.esriNAReadOnly);
			RoadNetElements = roadNet as INetElements;
		}
Exemple #22
0
 public IEnumNetEID GetEIDsByOID(INetElements elements, int userId, int userClassID, esriElementType elementType)
 {
     return(elements.GetEIDs(userClassID, userId, elementType));
 }
Exemple #23
0
        private void SetButton_Click(object obj, EventArgs eventArgs)
        {
            int count  = this.listJunctionFlag.Count;
            int count2 = this.listEdgeFlag.Count;
            int count3 = this.listJunctionBarrier.Count;
            int count4 = this.listEdgeBarrier.Count;

            if (count < 1 && count2 < 1)
            {
                MessageBox.Show("请用户选择要分析的点或线!");
            }
            else
            {
                IEdgeFlag[]     array        = new EdgeFlag[count2];
                IJunctionFlag[] array2       = new JunctionFlag[count];
                INetwork        network      = null;
                INetworkClass   networkClass = null;
                if (count > 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        IFeature feature = this.listJunctionFlag[i];
                        networkClass = (feature.Class as INetworkClass);
                        network      = networkClass.GeometricNetwork.Network;
                        INetElements           netElements           = network as INetElements;
                        INetFlag               netFlag               = new JunctionFlag() as INetFlag;
                        ISimpleJunctionFeature simpleJunctionFeature = feature as ISimpleJunctionFeature;
                        int userClassID;
                        int userID;
                        int userSubID;
                        netElements.QueryIDs(simpleJunctionFeature.EID, (esriElementType)1, out userClassID, out userID,
                                             out userSubID);
                        netFlag.UserClassID = (userClassID);
                        netFlag.UserID      = (userID);
                        netFlag.UserSubID   = (userSubID);
                        IJunctionFlag junctionFlag = netFlag as IJunctionFlag;
                        array2[i] = junctionFlag;
                    }
                }
                if (count2 > 0)
                {
                    for (int j = 0; j < count2; j++)
                    {
                        IFeature feature2 = this.listEdgeFlag[j];
                        networkClass = (feature2.Class as INetworkClass);
                        network      = networkClass.GeometricNetwork.Network;
                        INetElements       netElements2      = network as INetElements;
                        INetFlag           netFlag2          = new EdgeFlag() as INetFlag;
                        ISimpleEdgeFeature simpleEdgeFeature = feature2 as ISimpleEdgeFeature;
                        int userClassID2;
                        int userID2;
                        int userSubID2;
                        netElements2.QueryIDs(simpleEdgeFeature.EID, (esriElementType)2, out userClassID2, out userID2,
                                              out userSubID2);
                        netFlag2.UserClassID = (userClassID2);
                        netFlag2.UserID      = (userID2);
                        netFlag2.UserSubID   = (userSubID2);
                        IEdgeFlag edgeFlag = netFlag2 as IEdgeFlag;
                        array[j] = edgeFlag;
                    }
                }
                ITraceFlowSolverGEN    traceFlowSolverGEN    = new TraceFlowSolver() as ITraceFlowSolverGEN;
                INetSolver             netSolver             = traceFlowSolverGEN as INetSolver;
                INetElementBarriersGEN netElementBarriersGEN = new NetElementBarriers();
                netElementBarriersGEN.Network     = (network);
                netElementBarriersGEN.ElementType = (esriElementType)(1);
                int[] array3 = new int[count3];
                int   num    = 0;
                if (count3 > 0)
                {
                    for (int k = 0; k < count3; k++)
                    {
                        IFeature feature3 = this.listJunctionBarrier[k];
                        networkClass = (feature3.Class as INetworkClass);
                        network      = networkClass.GeometricNetwork.Network;
                        INetElements netElements3 = network as INetElements;
                        new EdgeFlag();
                        ISimpleJunctionFeature simpleJunctionFeature2 = feature3 as ISimpleJunctionFeature;
                        int num2;
                        int num3;
                        netElements3.QueryIDs(simpleJunctionFeature2.EID, (esriElementType)1, out num, out num2,
                                              out num3);
                        array3[k] = num2;
                    }
                    netElementBarriersGEN.SetBarriers(num, ref array3);
                    netSolver.set_ElementBarriers((esriElementType)1, (INetElementBarriers)netElementBarriersGEN);
                }
                INetElementBarriersGEN netElementBarriersGEN2 = new NetElementBarriers();
                netElementBarriersGEN2.Network     = (network);
                netElementBarriersGEN2.ElementType = (esriElementType)(2);
                int[] array4 = new int[count4];
                if (count4 > 0)
                {
                    for (int l = 0; l < count4; l++)
                    {
                        IFeature feature4 = this.listEdgeBarrier[l];
                        networkClass = (feature4.Class as INetworkClass);
                        network      = networkClass.GeometricNetwork.Network;
                        INetElements netElements4 = network as INetElements;
                        new EdgeFlag();
                        ISimpleEdgeFeature simpleEdgeFeature2 = feature4 as ISimpleEdgeFeature;
                        int num4;
                        int num5;
                        netElements4.QueryIDs(simpleEdgeFeature2.EID, (esriElementType)2, out num, out num4, out num5);
                        array4[l] = num4;
                    }
                    netElementBarriersGEN2.SetBarriers(num, ref array4);
                    netSolver.set_ElementBarriers((esriElementType)2, (INetElementBarriers)netElementBarriersGEN2);
                }
                netSolver.SourceNetwork = (network);
                if (count > 0)
                {
                    traceFlowSolverGEN.PutJunctionOrigins(ref array2);
                }
                if (count2 > 0)
                {
                    traceFlowSolverGEN.PutEdgeOrigins(ref array);
                }
                IEnumNetEID enumNetEID  = null;
                IEnumNetEID enumNetEID2 = null;
                object[]    array5      = new object[1];
                if (this.WayCom.SelectedIndex == 0)
                {
                    traceFlowSolverGEN.FindSource(0, (esriShortestPathObjFn)1, out enumNetEID, out enumNetEID2,
                                                  count + count2, ref array5);
                }
                if (this.WayCom.SelectedIndex == 1)
                {
                    traceFlowSolverGEN.FindSource((esriFlowMethod)1, (esriShortestPathObjFn)1, out enumNetEID,
                                                  out enumNetEID2, count + count2, ref array5);
                }
                IPolyline           polyline           = new Polyline() as IPolyline;
                IGeometryCollection geometryCollection = polyline as IGeometryCollection;
                ISpatialReference   spatialReference   = this.m_iApp.FocusMap.SpatialReference;
                IEIDHelper          iEIDHelper         = new EIDHelper();
                iEIDHelper.GeometricNetwork       = (networkClass.GeometricNetwork);
                iEIDHelper.OutputSpatialReference = (spatialReference);
                iEIDHelper.ReturnGeometries       = (true);
                iEIDHelper.ReturnFeatures         = (true);
                int selectedIndex = this.LayerCom.SelectedIndex;
                if (selectedIndex >= 0 && this.MapControl != null)
                {
                    this.LayerCom.SelectedItem.ToString();
                    IFeatureLayer ifeatureLayer_ = ((TrackingAnalyForm.LayerInfo) this.LayerCom.SelectedItem)._layer;
                    if (ifeatureLayer_ != null)
                    {
                        IFeatureSelection featureSelection = (IFeatureSelection)ifeatureLayer_;
                        featureSelection.Clear();
                        if (enumNetEID2 != null)
                        {
                            IEnumEIDInfo enumEIDInfo = iEIDHelper.CreateEnumEIDInfo(enumNetEID2);
                            int          count5      = enumEIDInfo.Count;
                            enumEIDInfo.Reset();
                            for (int m = 0; m < count5; m++)
                            {
                                IEIDInfo iEIDInfo = enumEIDInfo.Next();
                                featureSelection.Add(iEIDInfo.Feature);
                                IGeometry geometry = iEIDInfo.Geometry;
                                geometryCollection.AddGeometryCollection(geometry as IGeometryCollection);
                            }
                        }
                        featureSelection.SelectionSet.Refresh();
                        IActiveView activeView = this.m_iApp.ActiveView;
                        activeView.Refresh();
                        CMapOperator.ShowFeatureWithWink(this.m_iApp.ActiveView.ScreenDisplay, polyline);
                    }
                }
            }
        }
Exemple #24
0
        /// <summary>
        /// Set Flags Geometric Network
        /// </summary>
        protected void SetFlagsGeometricNetwork()
        {
            //// edge Flags
            List <INetFlag> edgeFlagList = new List <INetFlag>();

            this.flagNotFound = new List <IGeometry>();

            if (this.EdgeFlags.Count > 0)
            {
                foreach (IPoint point in this.EdgeFlags)
                {
                    int eid = this.GetEIDFromPoint(this.Tolerance, point, esriElementType.esriETEdge);

                    if (eid < 1)
                    {
                        this.flagNotFound.Add(point);
                        continue;
                    }

                    INetElements netElements = this.geometricNetwork.Network as INetElements;
                    int          featureClassID, featureID, subID;
                    netElements.QueryIDs(eid, esriElementType.esriETEdge, out featureClassID, out featureID, out subID);

                    INetFlag netFlag = new EdgeFlagClass();
                    netFlag.UserClassID = featureClassID;
                    netFlag.UserID      = featureID;
                    netFlag.UserSubID   = subID;
                    edgeFlagList.Add(netFlag);
                }

                this.edgeFlags = new IEdgeFlag[edgeFlagList.Count];
                edgeFlagList.Each((i, index) =>
                {
                    this.edgeFlags[index] = i as IEdgeFlag;
                });
            }

            //// junction Flags
            List <INetFlag> junctionFlagList = new List <INetFlag>();

            if (this.JunctionFlags.Count > 0)
            {
                foreach (IPoint point in this.JunctionFlags)
                {
                    int eid = this.GetEIDFromPoint(this.Tolerance, point, esriElementType.esriETJunction);

                    if (eid < 1)
                    {
                        this.flagNotFound.Add(point);
                        continue;
                    }

                    INetElements netElements = this.geometricNetwork.Network as INetElements;
                    int          featureClassID, featureID, subID;
                    netElements.QueryIDs(eid, esriElementType.esriETJunction, out featureClassID, out featureID, out subID);

                    INetFlag netFlag = new JunctionFlagClass();
                    netFlag.UserClassID = featureClassID;
                    netFlag.UserID      = featureID;
                    netFlag.UserSubID   = subID;
                    junctionFlagList.Add(netFlag);
                }

                this.junctionFlags = new IJunctionFlag[junctionFlagList.Count];
                junctionFlagList.Each((i, index) =>
                {
                    this.junctionFlags[index] = i as JunctionFlag;
                });
            }
        }
        private void StartAnalysis(IFeature feature)
        {
            if (feature.FeatureType != esriFeatureType.esriFTSimpleJunction)
            {
                MessageService.Current.Warn("请选择管线点");
                return;
            }
            if (!_pipelineConfig.IsPipelineLayer(feature.Class.AliasName, enumPipelineDataType.Point))
            {
                MessageService.Current.Warn("请选择管线点");
                return;
            }
            double snapDist = CommonUtils.ConvertPixelsToMapUnits(_context.ActiveView,
                                                                  _context.Config.SnapTolerance);
            IBasicLayerInfo lineConfig =
                _plugin.PipeConfig.GetBasicLayerInfo(feature.Class as IFeatureClass) as IBasicLayerInfo;

            if (this._startPoint == null && _startEid == 0)
            {
                //开始记录起始点
                IPipelineLayer oldLayer = _pipelineConfig.GetPipelineLayer(feature.Class.AliasName,
                                                                           enumPipelineDataType.Point);
                if (oldLayer == null)
                {
                    MessageService.Current.Warn("你选择的图层不是合法的管线图层!");
                    return;
                }
                List <IBasicLayerInfo> basicInfos = oldLayer.GetLayers(enumPipelineDataType.Junction);

                IFeatureClass featureClass = basicInfos.Count > 0 ? basicInfos[0].FeatureClass : null;
                if (featureClass == null)
                {
                    MessageService.Current.Warn("管线图层没有构建网络图层!");
                    return;
                }
                INetworkClass networkClass = featureClass as INetworkClass;
                _geometricNetwork = networkClass.GeometricNetwork;
                IPointToEID pnToEid = new PointToEIDClass();
                pnToEid.GeometricNetwork = _geometricNetwork;
                pnToEid.SnapTolerance    = snapDist;
                pnToEid.SourceMap        = _context.FocusMap;
                pnToEid.GetNearestJunction(feature.Shape as IPoint, out _startEid, out _startPoint);
                return;
            }
            IPipelineLayer newLayer = _pipelineConfig.GetPipelineLayer(feature.Class.AliasName,
                                                                       enumPipelineDataType.Point);

            if (newLayer == null)
            {
                MessageService.Current.Warn("你选择的图层不是合法的管线图层!");
                return;
            }
            List <IBasicLayerInfo> basicInfos1 = newLayer.GetLayers(enumPipelineDataType.Junction);

            IFeatureClass featureClass2 = basicInfos1.Count > 0 ? basicInfos1[0].FeatureClass : null;

            if (featureClass2 == null)
            {
                MessageService.Current.Warn("第二个管线图层没有构建网络图层!");
                return;
            }
            INetworkClass networkClass2 = featureClass2 as INetworkClass;

            if (networkClass2.GeometricNetwork != _geometricNetwork)
            {
                if (MessageService.Current.Ask("两个点位属于不同的网络图层,使用第二个网络图层作为分析图层吗?") == false)
                {
                    return;
                }
                _geometricNetwork = networkClass2.GeometricNetwork;
                IPointToEID pnToEid = new PointToEIDClass();
                pnToEid.GeometricNetwork = _geometricNetwork;
                pnToEid.SnapTolerance    = snapDist;
                pnToEid.SourceMap        = _context.FocusMap;
                pnToEid.GetNearestJunction(feature.Shape as IPoint, out _startEid, out _startPoint);
                return;
            }

            try
            {
                IPointToEID pntEid = new PointToEIDClass();
                pntEid.GeometricNetwork = _geometricNetwork;
                pntEid.SourceMap        = _context.FocusMap;
                pntEid.SnapTolerance    = snapDist;

                pntEid.GetNearestJunction(feature.Shape as IPoint, out _endEid, out _endPoint);
                if (_endEid < 1)
                {
                    MessageService.Current.Warn("未能找到第二个分析点!");
                    return;
                }
                if (_startEid == _endEid)
                {
                    MessageService.Current.Warn("起点终点为同一个点!");
                    return;
                }

                INetElements  netElements  = _geometricNetwork.Network as INetElements;
                INetworkClass networkClass = feature.Class as INetworkClass;

                IJunctionFlag[] array   = new JunctionFlag[2];
                INetFlag        netFlag = new JunctionFlag() as INetFlag;

                int userClassID;
                int userID;
                int userSubID;
                netElements.QueryIDs(_endEid, esriElementType.esriETJunction, out userClassID, out userID, out userSubID);
                netFlag.UserClassID = (userClassID);
                netFlag.UserID      = (userID);
                netFlag.UserSubID   = (userSubID);
                IJunctionFlag value = netFlag as IJunctionFlag;
                array.SetValue(value, 0);
                INetFlag netFlag2 = new JunctionFlag() as INetFlag;
                netElements.QueryIDs(_startEid, esriElementType.esriETJunction, out userClassID,
                                     out userID, out userSubID);
                netFlag2.UserClassID = (userClassID);
                netFlag2.UserID      = (userID);
                netFlag2.UserSubID   = (userSubID);
                value = (netFlag2 as IJunctionFlag);
                array.SetValue(value, 1);
                ITraceFlowSolverGEN traceFlowSolverGEN = new TraceFlowSolver() as ITraceFlowSolverGEN;
                INetSolver          netSolver          = traceFlowSolverGEN as INetSolver;
                netSolver.SourceNetwork = _geometricNetwork.Network;
                traceFlowSolverGEN.PutJunctionOrigins(ref array);
                object[]    array2 = new object[1];
                IEnumNetEID enumNetEID;
                IEnumNetEID enumNetEID2;
                traceFlowSolverGEN.FindPath((esriFlowMethod)2, (esriShortestPathObjFn)1, out enumNetEID,
                                            out enumNetEID2, 1, ref array2);
                if (this.ipolyline_0 == null)
                {
                    this.ipolyline_0 = new Polyline() as IPolyline;
                }
                IGeometryCollection geometryCollection = this.ipolyline_0 as IGeometryCollection;
                geometryCollection.RemoveGeometries(0, geometryCollection.GeometryCount);
                if (enumNetEID2.Count <= 0)
                {
                    this.ifeature_0 = null;
                    MessageBox.Show("两点之间不存在路径可以连通!");
                }
                else
                {
                    ShowShortObjectForm showShortObjectForm = new ShowShortObjectForm(_context);
                    showShortObjectForm.pApp = _context;
                    ISpatialReference spatialReference = _context.FocusMap.SpatialReference;
                    IEIDHelper        eIDHelperClass   = new EIDHelper();
                    eIDHelperClass.GeometricNetwork       = (networkClass.GeometricNetwork);
                    eIDHelperClass.OutputSpatialReference = (spatialReference);
                    eIDHelperClass.ReturnGeometries       = (true);
                    eIDHelperClass.ReturnFeatures         = (true);
                    IEnumEIDInfo enumEIDInfo = eIDHelperClass.CreateEnumEIDInfo(enumNetEID2);
                    int          count       = enumEIDInfo.Count;
                    enumEIDInfo.Reset();
                    for (int i = 0; i < count; i++)
                    {
                        IEIDInfo  iEIDInfo = enumEIDInfo.Next();
                        IGeometry geometry = iEIDInfo.Geometry;
                        if (i == 0)
                        {
                            showShortObjectForm.AddPipeName(this.string_0);
                        }
                        showShortObjectForm.AddFeature(iEIDInfo.Feature);
                        geometryCollection.AddGeometryCollection(geometry as IGeometryCollection);
                    }
                    showShortObjectForm.AddShortPath(this.ipolyline_0);
                    showShortObjectForm.AddLenght(this.ipolyline_0.Length);
                    this.ifeature_2 = feature;
                    EsriUtils.ZoomToGeometry(this.ipolyline_0, _context.MapControl.Map, 1.3);
                    FlashUtility.FlashGeometry(this.ipolyline_0, _context.MapControl);
                    this.ifeature_0   = null;
                    _startEid         = 0;
                    _startPoint       = null;
                    _geometricNetwork = null;
                    showShortObjectForm.Show();
                }
            }
            catch (Exception ex)
            {
                this.ifeature_0 = null;
                MessageBox.Show(ex.Message);
            }
        }
Exemple #26
0
        public void GetBaseLine(IPoint point)
        {
            string str;
            string str1;
            string str2;

            this.timer_0.Stop();
            this.dataGridView1.Rows.Clear();
            IMap     map     = this.m_app.FocusMap;
            IFeature feature = ((IEnumFeature)map.FeatureSelection).Next();

            if (feature == null ? true : feature.FeatureType != esriFeatureType.esriFTSimpleEdge)
            {
                this.m_commonDistAls.m_pBaseLine = null;
                this.btAnalyse.Enabled           = false;
                this.m_app.FocusMap.ClearSelection();
                this.m_app.ActiveView.Refresh();
                //this.tbPipeWidthOrHeight.Text = "";
                return;
            }
            IFeatureLayer pLayer =
                CommonUtils.GetLayerByFeatureClassName(m_app.FocusMap, ((IDataset)feature.Class).Name) as IFeatureLayer;
            IPipelineLayer  pipeLayer = m_config.GetPipelineLayer(feature.Class as IFeatureClass);
            IBasicLayerInfo pipeLine  = m_config.GetBasicLayerInfo(feature.Class as IFeatureClass);

            if (pipeLine == null)
            {
                this.m_commonDistAls.m_pBaseLine = null;
                this.btAnalyse.Enabled           = false;
                this.m_app.FocusMap.ClearSelection();
                this.m_app.ActiveView.Refresh();
                return;
            }
            List <IBasicLayerInfo> basicInfos      = pipeLayer.GetLayers(enumPipelineDataType.Junction);
            IFeatureClass          junFeatureClass = basicInfos.Count > 0 ? basicInfos[0].FeatureClass : null;
            //需要重新获取边信息
            IGeometricNetwork      geometricNetwork = ((INetworkClass)junFeatureClass).GeometricNetwork;
            IFeatureClassContainer featureDataset   = geometricNetwork.FeatureDataset as IFeatureClassContainer;
            IPointToEID            pointToEIDClass  = new PointToEID();

            pointToEIDClass.SourceMap        = (m_app.FocusMap);
            pointToEIDClass.GeometricNetwork = (geometricNetwork);
            pointToEIDClass.SnapTolerance    = (m_app.ActiveView.Extent.Width / 200.0);
            int    edgeID   = 0;
            IPoint location = null;
            double percent  = 0;

            pointToEIDClass.GetNearestEdge(point, out edgeID, out location, out percent);
            if (edgeID == 0)
            {
                return;
            }

            int          userClassID;
            int          userID;
            int          userSubID;
            INetElements network = geometricNetwork.Network as INetElements;

            network.QueryIDs(edgeID, esriElementType.esriETEdge, out userClassID, out userID, out userSubID);
            IFeatureClass lineClass   = featureDataset.ClassByID[userClassID] as IFeatureClass;
            IFeature      lineFeature = lineClass.GetFeature(userID);
            IGeometry     shape       = lineFeature.Shape;

            if (shape.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                this.ipolyline_0 = CommonUtils.GetPolylineDeepCopy((IPolyline)shape);
                this.m_commonDistAls.m_pFeature     = feature;
                this.m_commonDistAls.m_pBaseLine    = this.ipolyline_0;
                this.m_commonDistAls.m_strLayerName = feature.Class.AliasName;
                //int num = feature.Fields.FindField("埋设方式");
                int num = lineFeature.Fields.FindField(pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.MSFS));
                str = (num == -1 ? "" : this.GetDBObjectValue(lineFeature.get_Value(num)));
                this.m_commonDistAls.m_strBuryKind = str;
                int num1 = lineFeature.Fields.FindField(pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.GJ));
                str1 = (num1 == -1 ? "" : this.GetDBObjectValue(lineFeature.get_Value(num1)));
                num1 = feature.Fields.FindField(pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.DMCC));
                str2 = (num1 == -1 ? "" : lineFeature.get_Value(num1).ToString());
                string str3 = "";
                if (str1 != "")
                {
                    str3 = str1;
                }
                if (str2 != "")
                {
                    str3 = str2;
                }
                this.m_commonDistAls.m_dDiameter = this.m_commonDistAls.GetDiameterFromString(str3.Trim());
                IEdgeFeature edgeFeature = (IEdgeFeature)lineFeature;
                this.m_commonDistAls.m_nBaseLineFromID = edgeFeature.FromJunctionEID;
                this.m_commonDistAls.m_nBaseLineToID   = edgeFeature.ToJunctionEID;
                this.btAnalyse.Enabled             = this.m_commonDistAls.m_pBaseLine != null;
                this.chitAnalyse_0.PipeLayer_Class = lineFeature.Class as IFeatureClass;
                this.chitAnalyse_0.BaseLine_OID    = lineFeature.OID;
                _baseLayerInfo = pipeLine;
            }
            else
            {
                MessageBox.Show("所选择的管线多于一条,或者不是管线!");
            }
        }
Exemple #27
0
        // Uses Geometric Network to find connected edges which determine desired rotation of point

        public Nullable <double> GetRotationUsingConnectedEdges(IFeature inFeature)
        {
            Nullable <double> rotationAngle = null;

            if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                try
                {
                    double         diameter       = 0;
                    List <double>  angles         = new List <double>();
                    List <double>  diameters      = new List <double>();
                    List <Boolean> flipDirections = new List <Boolean>();

                    IPoint                 pnt     = (ESRI.ArcGIS.Geometry.IPoint)inFeature.Shape;
                    INetworkFeature        netFeat = (INetworkFeature)inFeature;
                    ISimpleJunctionFeature simpleJunctionFeature = (ISimpleJunctionFeature)netFeat;
                    INetworkClass          netClass    = (INetworkClass)inFeature.Class;
                    IGeometricNetwork      geomNetwork = (IGeometricNetwork)netClass.GeometricNetwork;
                    INetwork               network     = (INetwork)geomNetwork.Network;
                    INetElements           netElements = (INetElements)network;

                    IFeatureClass      fc;
                    IFeature           feat;
                    IGeometry          geometry;
                    IPolyline          polyline;
                    ISegmentCollection segmentCollection;
                    ISegmentCollection segColTest;
                    ISegment           testSegment;
                    IEnumSegment       enumSegment;
                    System.Object      edgeWeight;
                    Boolean            edgeOrient;
                    int    partIndex    = 0;
                    int    segmentIndex = 0;
                    int    edgesCount;
                    int    edgeEID;
                    int    classId; int userId; int subId;
                    int    posField; double angle;
                    object Missing = Type.Missing;

                    IPoint toPoint;
                    ITopologicalOperator topoOp;
                    IPolygon             poly;
                    IRelationalOperator  relOp;

                    IForwardStarGEN forwardStar = (IForwardStarGEN)network.CreateForwardStar(false, null, null, null, null);
                    forwardStar.FindAdjacent(0, simpleJunctionFeature.EID, out edgesCount);


                    for (int i = 0; i < edgesCount; i++)
                    {
                        forwardStar.QueryAdjacentEdge(i, out edgeEID, out edgeOrient, out edgeWeight);
                        geometry = geomNetwork.get_GeometryForEdgeEID(edgeEID);
                        polyline = (IPolyline5)geometry;

                        //Special case for reducer
                        if (m_useDiameter & (edgesCount == 2))
                        {
                            netElements.QueryIDs(edgeEID, esriElementType.esriETEdge, out classId, out userId, out subId);
                            fc       = GetFeatureClassByClassId(classId, geomNetwork);
                            feat     = fc.GetFeature(userId);
                            posField = GetFieldPosition(m_diameterFieldName, feat);
                            if (posField > -1)
                            {
                                diameter = (double)feat.get_Value(posField);
                            }
                        }

                        //given line and point, return angles of all touching segments
                        segmentCollection = (ISegmentCollection)polyline;
                        enumSegment       = (IEnumSegment)segmentCollection.EnumSegments;
                        enumSegment.Next(out testSegment, ref partIndex, ref segmentIndex);

                        while (testSegment != null)
                        {
                            angle   = GetAngleOfSegment(testSegment);
                            toPoint = testSegment.ToPoint;
                            topoOp  = toPoint as ITopologicalOperator;
                            poly    = topoOp.Buffer(0.01) as IPolygon;

                            //ML: 20090617 Added test for segment touching point to be rotated
                            segColTest = new PolylineClass();
                            segColTest.AddSegment(testSegment, ref Missing, ref Missing);
                            relOp = segColTest as IRelationalOperator;

                            if (relOp.Touches(pnt))
                            {
                                relOp = poly as IRelationalOperator;
                                flipDirections.Add(relOp.Contains(pnt));
                                diameters.Add(diameter);
                                angles.Add(angle);
                            }
                            enumSegment.Next(out testSegment, ref partIndex, ref segmentIndex);
                        }

                        ///end of possible function returning list of angles
                    }
                    switch (angles.Count)
                    {
                    case 0:
                        break;

                    case 1:
                        // End cap or plug fitting or simliar.
                        rotationAngle = angles[0];
                        if (flipDirections[0])
                        {
                            rotationAngle += 180;
                        }
                        break;

                    case 2:
                        if (m_useDiameter & (diameters[0] < diameters[1]))
                        {
                            rotationAngle = angles[0];
                            if (flipDirections[0])
                            {
                                rotationAngle += 180;
                            }
                        }
                        else if (m_useDiameter & (diameters[0] >= diameters[1]))
                        {
                            rotationAngle = angles[1];
                            if (flipDirections[1])
                            {
                                rotationAngle += 180;
                            }
                        }
                        else
                        {
                            rotationAngle = angles[0];
                        }

                        break;

                    case 3:
                        //Tee or Tap fitting or similiar.  Rotate toward the odd line.
                        int tee = FindTee(angles[0], angles[1], angles[2]);
                        rotationAngle = angles[tee];
                        if (flipDirections[tee])
                        {
                            rotationAngle += 180;
                        }
                        break;

                    case 4:
                        // Cross fitting or similar. Any of the angles should work.
                        rotationAngle = (int)angles[0];
                        break;

                    default:
                        break;
                    }
                }
                catch
                {
                    return(-1);
                }
            }


            //If needed, convert to geographic degrees(zero north clockwise)
            if (rotationAngle > 360)
            {
                rotationAngle -= 360;
            }
            if (rotationAngle < 0)
            {
                rotationAngle += 360;
            }
            if (rotationAngle != null & m_rotationType == esriSymbolRotationType.esriRotateSymbolGeographic)
            {
                int a = (int)rotationAngle;

                if (a > 0 & a <= 90)
                {
                    rotationAngle = 90 - a;
                }
                else if (a > 90 & a <= 360)
                {
                    rotationAngle = 450 - a;
                }
            }

            //Apply any spin angle
            if (rotationAngle != null)
            {
                rotationAngle += m_spinAngle;
                if (rotationAngle > 360)
                {
                    rotationAngle -= 360;
                }
                if (rotationAngle < 0)
                {
                    rotationAngle += 360;
                }
            }


            return(rotationAngle);
        }
Exemple #28
0
        private static ITraceFlowSolver CreateTraceFlowSolver()
        {
            int              num;
            INetFlag         netFlag;
            ITraceFlowSolver solver  = (ITraceFlowSolver) new TraceFlowSolverClass();
            INetSolver       solver2 = (INetSolver)solver;
            INetwork         network = m_pAnalystGN.Network;

            solver2.SourceNetwork = network;
            INetElements elements = (INetElements)network;

            if (m_JunFlags.Count > 0)
            {
                IJunctionFlag[] junctionOrigins = new IJunctionFlag[m_JunFlags.Count];
                for (num = 0; num < m_JunFlags.Count; num++)
                {
                    netFlag = (m_JunFlags[num] as NetFlagWrap).NetFlag;
                    junctionOrigins[num] = (IJunctionFlag)netFlag;
                }
                (solver as ITraceFlowSolverGEN).PutJunctionOrigins(ref junctionOrigins);
            }
            if (m_EdgeFlags.Count > 0)
            {
                IEdgeFlag[] edgeOrigins = new IEdgeFlag[m_EdgeFlags.Count];
                for (num = 0; num < m_EdgeFlags.Count; num++)
                {
                    netFlag          = (m_EdgeFlags[num] as NetFlagWrap).NetFlag;
                    edgeOrigins[num] = (IEdgeFlag)netFlag;
                }
                (solver as ITraceFlowSolverGEN).PutEdgeOrigins(ref edgeOrigins);
            }
            INetSolverWeightsGEN sgen = (INetSolverWeightsGEN)solver;

            if (JunctionWeight != null)
            {
                sgen.JunctionWeight = JunctionWeight;
            }
            if (FromToEdgeWeight != null)
            {
                sgen.JunctionWeight = FromToEdgeWeight;
            }
            if (ToFromEdgeWeight != null)
            {
                sgen.JunctionWeight = ToFromEdgeWeight;
            }
            if (JunctionFilterWeight != null)
            {
                sgen.JunctionFilterWeight = JunctionFilterWeight;
            }
            if (FromToEdgeFilterWeight != null)
            {
                sgen.FromToEdgeFilterWeight = FromToEdgeFilterWeight;
            }
            if (ToFromEdgeFilterWeight != null)
            {
                sgen.ToFromEdgeFilterWeight = ToFromEdgeFilterWeight;
            }
            if (JuncfromValues != null)
            {
                sgen.SetFilterRanges(esriElementType.esriETJunction, ref JuncfromValues, ref JunctoValues);
                sgen.SetFilterType(esriElementType.esriETJunction, esriWeightFilterType.esriWFRange,
                                   ApplyJuncFilterWeight);
            }
            else
            {
                sgen.SetFilterType(esriElementType.esriETJunction, esriWeightFilterType.esriWFNone,
                                   ApplyJuncFilterWeight);
            }
            if (EdgefromValues != null)
            {
                sgen.SetFilterRanges(esriElementType.esriETEdge, ref EdgefromValues, ref EdgetoValues);
                sgen.SetFilterType(esriElementType.esriETEdge, esriWeightFilterType.esriWFRange, ApplyJuncFilterWeight);
            }
            else
            {
                sgen.SetFilterType(esriElementType.esriETEdge, esriWeightFilterType.esriWFNone, ApplyEdgeFilterWeight);
            }
            INetElementBarriers netElementBarriers = GetNetElementBarriers(esriElementType.esriETJunction);

            if (netElementBarriers != null)
            {
                (solver as INetSolver).set_ElementBarriers(esriElementType.esriETJunction, netElementBarriers);
            }
            netElementBarriers = GetNetElementBarriers(esriElementType.esriETEdge);
            if (netElementBarriers != null)
            {
                (solver as INetSolver).set_ElementBarriers(esriElementType.esriETEdge, netElementBarriers);
            }
            return(solver);
        }
Exemple #29
0
        //!在这儿进行修改,将对高程埋深数据存储在不同位置进行统一处理
        private void method_2()
        {
            IMap         map         = m_context.FocusMap;
            IEnumFeature enumFeature = (IEnumFeature)map.FeatureSelection;
            IFeature     feature     = enumFeature.Next();
            bool         isMUsing    = false;
            int          qdgcIndex   = -1;
            int          qdmsIndex   = -1;
            int          zdgcIndex   = -1;
            int          zdmsIndex   = -1;

            if (feature == null)
            {
                return;
            }
            if (feature.FeatureType != esriFeatureType.esriFTSimpleEdge)
            {
                return;
            }

            this.arrayList_1.Clear();
            this.arrayList_2.Clear();
            int num = 0;

            while (feature != null)
            {
                IPolyline egLine    = feature.Shape as IPolyline;
                IPoint    newCenter = new PointClass();
                egLine.QueryPoint(esriSegmentExtension.esriNoExtension, 0.01, true, newCenter);
                IEdgeFeature  pEgFeature    = feature as IEdgeFeature;
                IFeatureClass pClass        = feature.Class as IFeatureClass;
                INetworkClass pNetworkClass = pClass as INetworkClass;
                INetElements  network       = pNetworkClass.GeometricNetwork.Network as INetElements;
                IEnumFeature  enumFeatures  = pNetworkClass.GeometricNetwork.SearchForNetworkFeature(newCenter,
                                                                                                     esriFeatureType.esriFTSimpleEdge);

                ISimpleEdgeFeature simpleEdgeFeature = enumFeatures.Next() as ISimpleEdgeFeature;

                IFeature realFeature = null;

                int userClassID, userID, userSubID;

                network.QueryIDs(simpleEdgeFeature.EID, esriElementType.esriETEdge, out userClassID, out userID,
                                 out userSubID);
                if (pClass.FeatureClassID == userClassID)
                {
                    realFeature = pClass.GetFeature(userID);
                }
                else
                {
                    IEnumDataset dses = pNetworkClass.FeatureDataset.Subsets;
                    dses.Reset();
                    IDataset ds = dses.Next();
                    while (ds != null)
                    {
                        if (ds is IFeatureClass)
                        {
                            IFeatureClass pClass2 = ds as IFeatureClass;
                            if (pClass2.FeatureClassID == userClassID)
                            {
                                realFeature = pClass2.GetFeature(userID);
                                break;
                            }
                        }
                    }
                }

                IMAware mAware = realFeature.Shape as IMAware;
                isMUsing = mAware.MAware;
                IFeatureLayer   pLayer     = MapHelper.GetLayerByFeature(map as IBasicMap, realFeature);
                IBasicLayerInfo lineConfig =
                    PipeConfig.GetBasicLayerInfo(realFeature.Class.AliasName) as IBasicLayerInfo;


                if (!isMUsing)
                {
                    qdgcIndex =
                        realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.QDGC));
                    qdmsIndex =
                        realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.QDMS));
                    zdgcIndex =
                        realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.ZDGC));
                    zdmsIndex =
                        realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.ZDMS));
                }
                PipeLine         pipeLine        = new PipeLine();
                IPolyline        polyline        = (IPolyline)feature.Shape;
                IPointCollection pointCollection = (IPointCollection)polyline;
                int pointCount = pointCollection.PointCount;
                pipeLine.Clear();
                if (isMUsing)
                {
                    for (int i = 0; i < pointCount; i++)
                    {
                        IPoint point = new ESRI.ArcGIS.Geometry.Point();
                        if (((SortInfo)this.arrayList_0[num]).bRightDirection)
                        {
                            point = pointCollection.get_Point(i);
                        }
                        else
                        {
                            point = pointCollection.get_Point(pointCount - i - 1);
                        }

                        if (double.IsNaN(point.M))
                        {
                            pipeLine.PushBack(point.X, point.Y, point.Z, point.Z + 1.0);
                        }
                        else
                        {
                            pipeLine.PushBack(point.X, point.Y, point.Z - point.M, point.Z);
                        }
                    }
                }
                else
                {
                    double height = 0;
                    double qdgc   = GetDoubleValue(realFeature, qdgcIndex, out height);
                    double zdgc   = GetDoubleValue(realFeature, zdgcIndex, out height);
                    double qdms   = GetDoubleValue(realFeature, qdmsIndex, out height);
                    double zdms   = GetDoubleValue(realFeature, zdmsIndex, out height);
                    if (qdms == 0)
                    {
                        qdms = 1;
                    }
                    if (zdms == 0)
                    {
                        zdms = 1;
                    }
                    IPoint startPoint = pointCollection.Point[0];
                    IPoint endPoint   = pointCollection.Point[pointCollection.PointCount - 1];
                    pipeLine.PushBack(startPoint.X, startPoint.Y, qdgc - qdms, qdgc);
                    pipeLine.PushBack(endPoint.X, endPoint.Y, zdgc - zdms, zdgc);
                }
                //string text = "管线性质";
                string text = lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GDXZ) == ""
                    ? "管线性质"
                    : lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GDXZ);

                int    num2  = realFeature.Fields.FindField(text);
                string text2 = "";
                if (num2 != -1)
                {
                    object obj = realFeature.get_Value(num2);
                    if (obj == null || Convert.IsDBNull(obj))
                    {
                        text2 = "";
                    }
                    else
                    {
                        text2 = obj.ToString();
                    }
                }
                pipeLine.ID          = Convert.ToInt32(realFeature.get_Value(0).ToString());
                pipeLine.DatasetName = text2;
                int num3 = realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GXCZ));
                pipeLine.Material = num3 == -1 ? "" : realFeature.get_Value(num3).ToString();

                //管径
                num3 = realFeature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GJ));
                string text3 = num3 == -1 ? "" : realFeature.get_Value(num3).ToString();

                //断面尺寸
                num3 = feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.DMCC));
                string text4 = num3 == -1 ? "" : realFeature.get_Value(num3).ToString();

                Color featureColor = CommonUtils.GetFeatureColor(map, realFeature.Class.AliasName, realFeature);
                pipeLine.Red   = (int)featureColor.R;
                pipeLine.Green = (int)featureColor.G;
                pipeLine.Blue  = (int)featureColor.B;
                if (text3 != "")
                {
                    pipeLine.PipeWidthHeight = text3;
                }
                if (text4 != "")
                {
                    pipeLine.PipeWidthHeight = text4;
                }
                if (pipeLine.PipeWidthHeight == null)
                {
                    pipeLine.PipeWidthHeight = "";
                }
                this.arrayList_1.Add(pipeLine);
                IFeature feature2 = (IFeature)((IEdgeFeature)realFeature).FromJunctionFeature;
                IFeature feature3 = (IFeature)((IEdgeFeature)realFeature).ToJunctionFeature;
                IFeature feature4;
                if (num == 0)
                {
                    PipePoint pipePoint = new PipePoint();
                    if (((SortInfo)this.arrayList_0[num]).bRightDirection)
                    {
                        feature4 = feature2;
                    }
                    else
                    {
                        feature4 = feature3;
                    }
                    pipePoint.nID             = Convert.ToInt32(feature4.get_Value(0));
                    pipePoint.nAtPipeSegID    = pipeLine.ID;
                    pipePoint.bstrDatasetName = text2;

                    IBasicLayerInfo pointConfig =
                        PipeConfig.GetBasicLayerInfo(feature4.Class.AliasName) as IBasicLayerInfo;
                    num3 = feature4.Fields.FindField(pointConfig.GetFieldName(PipeConfigWordHelper.PointWords.FSW));
                    if (num3 == -1)
                    {
                        pipePoint.bstrPointKind = "";
                    }
                    else
                    {
                        pipePoint.bstrPointKind = feature4.get_Value(num3).ToString();
                    }
                    Color featureColor2 = CommonUtils.GetFeatureColor(map, feature4.Class.AliasName, feature4);
                    pipePoint.Red   = (int)featureColor2.R;
                    pipePoint.Green = (int)featureColor2.G;
                    pipePoint.Blue  = (int)featureColor2.B;
                    this.arrayList_2.Add(pipePoint);
                }
                PipePoint pipePoint2 = new PipePoint();
                if (((SortInfo)this.arrayList_0[num]).bRightDirection)
                {
                    feature4 = feature3;
                }
                else
                {
                    feature4 = feature2;
                }
                pipePoint2.nID             = Convert.ToInt32(feature4.get_Value(0));
                pipePoint2.nAtPipeSegID    = pipeLine.ID;
                pipePoint2.bstrDatasetName = text2;
                IBasicLayerInfo pointConfig3 =
                    PipeConfig.GetBasicLayerInfo(feature4.Class.AliasName) as IBasicLayerInfo;
                num3 = feature4.Fields.FindField(pointConfig3.GetFieldName(PipeConfigWordHelper.PointWords.FSW));
                if (num3 == -1)
                {
                    pipePoint2.bstrPointKind = "";
                }
                else
                {
                    pipePoint2.bstrPointKind = feature4.get_Value(num3).ToString();
                }
                Color featureColor3 = CommonUtils.GetFeatureColor(map, feature4.Class.AliasName, feature4);
                pipePoint2.Red   = (int)featureColor3.R;
                pipePoint2.Green = (int)featureColor3.G;
                pipePoint2.Blue  = (int)featureColor3.B;
                this.arrayList_2.Add(pipePoint2);
                feature = enumFeature.Next();
                num++;
            }
            this.method_3(this.arrayList_2, this.arrayList_1);
            this.method_4(this.arrayList_3, this.arrayList_1);
            this.method_5(this.arrayList_4, this.arrayList_2);
            this.method_6();
            this.method_7(this.arrayList_3);
        }
Exemple #30
0
        public override void GetSelectedData()
        {
            this.method_3();
            IMap map = this.m_context.FocusMap;
            ITopologicalOperator topologicalOperator = (ITopologicalOperator)this.m_pBaseLine;
            IGeometry            geometry            = topologicalOperator.Buffer(0.0);

            map.ClearSelection();
            ISelectionEnvironment selectionEnvironment = new SelectionEnvironment();

            map.SelectByShape(geometry, selectionEnvironment, false);
            IEnumFeature enumFeature = (IEnumFeature)map.FeatureSelection;
            IFeature     feature     = enumFeature.Next();

            while (feature != null)
            {
                if (feature.FeatureType == esriFeatureType.esriFTSimpleEdge)
                {
                    IPolyline egLine    = feature.Shape as IPolyline;
                    IPoint    newCenter = new PointClass();
                    egLine.QueryPoint(esriSegmentExtension.esriNoExtension, 0.01, true, newCenter);

                    IEdgeFeature pEgFeature = feature as IEdgeFeature;


                    IFeatureClass pClass        = feature.Class as IFeatureClass;
                    INetworkClass pNetworkClass = pClass as INetworkClass;
                    INetElements  network       = pNetworkClass.GeometricNetwork.Network as INetElements;
                    IPointToEID   pntEID        = new PointToEIDClass();
                    pntEID.GeometricNetwork = pNetworkClass.GeometricNetwork;
                    pntEID.SourceMap        = m_context.FocusMap;
                    pntEID.SnapTolerance    = CommonHelper.ConvertPixelsToMapUnits(m_context.ActiveView, 5.0);
                    double percent;
                    int    edgeID;
                    IPoint location;
                    pntEID.GetNearestEdge(newCenter, out edgeID, out location, out percent);
                    if (percent == 0)
                    {
                        feature = enumFeature.Next();
                        continue;
                    }

                    int userClassID, userID, userSubID;

                    network.QueryIDs(edgeID, esriElementType.esriETEdge, out userClassID, out userID, out userSubID);
                    if (pClass.FeatureClassID == userClassID)
                    {
                        feature = pClass.GetFeature(userID);
                    }
                    else
                    {
                        IEnumDataset dses = pNetworkClass.FeatureDataset.Subsets;
                        dses.Reset();
                        IDataset ds = dses.Next();
                        while (ds != null)
                        {
                            if (ds is IFeatureClass)
                            {
                                IFeatureClass pClass2 = ds as IFeatureClass;
                                if (pClass2.FeatureClassID == userClassID)
                                {
                                    feature = pClass2.GetFeature(userID);
                                    break;
                                }
                            }
                        }
                    }
                }
                string  smpClassName = CommonUtils.GetSmpClassName(feature.Class.AliasName);
                IMAware mWAware      = feature.Shape as IMAware;
                bool    isMUsing     = mWAware.MAware;

                IBasicLayerInfo lineConfig = PipeConfig.GetBasicLayerInfo(feature.Class.AliasName) as IBasicLayerInfo;
                if (lineConfig == null && !smpClassName.ToUpper().Contains("JT_JT_L") &&
                    !smpClassName.ToUpper().Contains("SY_ZX_L") && !smpClassName.ToUpper().Contains("ZB_LD_R"))
                {
                    feature = enumFeature.Next();
                }
                else
                {
                    IGeometry shape = feature.Shape;
                    if (shape.GeometryType != esriGeometryType.esriGeometryPolyline &&
                        shape.GeometryType != esriGeometryType.esriGeometryPolygon)
                    {
                        feature = enumFeature.Next();
                    }
                    else
                    {
                        IPolyline polyline;
                        if (shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                        {
                            polyline = this.PolygonToPolyline((IPolygon)shape);
                        }
                        else
                        {
                            polyline = (IPolyline)shape;
                        }
                        GPoints gPoints = null;
                        if (isMUsing)
                        {
                            gPoints = this.CalculateIntersections(this.m_pBaseLine, polyline);
                        }
                        else
                        {
                            gPoints = this.CalculateIntersections(this.m_pBaseLine, feature, lineConfig);
                        }

                        //string text = "管线性质";
                        string text            = lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GDXZ);
                        string bstrDatasetName = "";
                        int    num             = feature.Fields.FindField(text);
                        if (num != -1)
                        {
                            object obj = feature.get_Value(num);
                            if (obj == null || Convert.IsDBNull(obj))
                            {
                                bstrDatasetName = "";
                            }
                            else
                            {
                                bstrDatasetName = obj.ToString();
                            }
                        }
                        if (gPoints == null)
                        {
                            feature = enumFeature.Next();
                        }
                        else
                        {
                            int num2 = gPoints.Size();
                            for (int i = 0; i < num2; i++)
                            {
                                GPoint gPoint = gPoints[i];

                                PipePoint pipePoint = new PipePoint();
                                if (smpClassName.ToUpper().Contains("JT_JT_L"))
                                {
                                    pipePoint.PointType = PipePoint.SectionPointType.sptRoadBorder;
                                }
                                else if (smpClassName.ToUpper().Contains("SY_ZX_L"))
                                {
                                    pipePoint.PointType = PipePoint.SectionPointType.sptMidRoadLine;
                                }
                                else if (smpClassName.ToUpper().Contains("ZB_LD_R"))
                                {
                                    pipePoint.PointType = PipePoint.SectionPointType.sptMidGreen;
                                }
                                else
                                {
                                    pipePoint.PointType = PipePoint.SectionPointType.sptPipe;
                                }
                                pipePoint.x = gPoint.X;
                                pipePoint.y = gPoint.Y;
                                pipePoint.z = gPoint.Z;
                                pipePoint.m = gPoint.M;
                                pipePoint.bstrDatasetName = bstrDatasetName;
                                //  int num3 = feature.Fields.FindField(base.PipeConfig.get_Material());
                                int num3 =
                                    feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GXCZ));
                                if (num3 == -1)
                                {
                                    pipePoint.strMaterial = "";
                                }
                                else
                                {
                                    object obj2 = feature.get_Value(num3);
                                    if (obj2 != null)
                                    {
                                        pipePoint.strMaterial = feature.get_Value(num3).ToString();
                                    }
                                    else
                                    {
                                        pipePoint.strMaterial = "";
                                    }
                                }
                                // num3 = feature.Fields.FindField(base.PipeConfig.get_Diameter());
                                num3 =
                                    feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GJ));
                                string text2;
                                if (num3 != -1 && feature.get_Value(num3) != null)
                                {
                                    text2 = feature.get_Value(num3).ToString();
                                }
                                else
                                {
                                    text2 = "";
                                }
                                num3 =
                                    feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.DMCC));
                                string text3;
                                if (num3 != -1 && feature.get_Value(num3) != null)
                                {
                                    text3 = feature.get_Value(num3).ToString();
                                }
                                else
                                {
                                    text3 = "";
                                }
                                if (text2 != "")
                                {
                                    pipePoint.strPipeWidthHeight = text2;
                                }
                                if (text3 != "")
                                {
                                    pipePoint.strPipeWidthHeight = text3;
                                }
                                Color featureColor = CommonUtils.GetFeatureColor(map, feature.Class.AliasName, feature);
                                pipePoint.Red   = (int)featureColor.R;
                                pipePoint.Green = (int)featureColor.G;
                                pipePoint.Blue  = (int)featureColor.B;
                                this.m_arrPipePoints.Add(pipePoint);
                            }
                            feature = enumFeature.Next();
                        }
                    }
                }
            }
            map.ClearSelection();
            IPointCollection pointCollection = (IPointCollection)this.m_pBaseLine;
            int pointCount = pointCollection.PointCount;

            if (pointCount != 0)
            {
                for (int j = 0; j < pointCount; j++)
                {
                    IPoint    point      = pointCollection.get_Point(j);
                    double    x          = point.X;
                    double    y          = point.Y;
                    PipePoint pipePoint2 = new PipePoint();
                    pipePoint2.x         = x;
                    pipePoint2.y         = y;
                    pipePoint2.PointType = PipePoint.SectionPointType.sptDrawPoint;
                    this.m_arrPipePoints.Add(pipePoint2);
                }
                this.fEswZsmwIx((PipePoint)this.m_arrPipePoints[this.m_arrPipePoints.Count - 2]);
                this.method_1();
                if (this.method_2())
                {
                    this.method_5(this.m_arrPipePointsDraw, this.m_arrPipePoints);
                    this.method_4();
                    this.method_7(this.m_arrPipePointsDraw);
                }
            }
        }
        public override void OnMouseDown(int button, int Shift, int x, int y)
        {
            if (button != 1)
            {
                return;
            }

            this.SelectByClick(x, y);
            IMap         map         = _context.FocusMap;
            IEnumFeature enumFeature = (IEnumFeature)map.FeatureSelection;
            IFeature     feature     = enumFeature.Next();

            if (feature == null)
            {
                if (Shift == 1)
                {
                    this.m_SectionControl.RebuildSelection();
                }
                else
                {
                    this.m_SectionControl.LayerName = "";
                    this.m_SectionControl.Clear();
                    this._context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, _context.ActiveView.Extent);
                }
            }
            else
            {
                string aliasName = feature.Class.AliasName;
                int    oID;
                if (feature.HasOID)
                {
                    oID = feature.OID;
                }
                else
                {
                    if (feature.FeatureType == esriFeatureType.esriFTSimpleEdge ||
                        feature.FeatureType == esriFeatureType.esriFTComplexEdge)
                    {
                        IPolyline egLine    = feature.Shape as IPolyline;
                        IPoint    newCenter = new PointClass();
                        egLine.QueryPoint(esriSegmentExtension.esriNoExtension, 0.01, true, newCenter);
                        IEdgeFeature  pEgFeature    = feature as IEdgeFeature;
                        IFeatureClass pClass        = feature.Class as IFeatureClass;
                        INetworkClass pNetworkClass = pClass as INetworkClass;
                        INetElements  network       = pNetworkClass.GeometricNetwork.Network as INetElements;
                        IPointToEID   pntEID        = new PointToEIDClass();
                        pntEID.GeometricNetwork = pNetworkClass.GeometricNetwork;
                        pntEID.SourceMap        = _context.FocusMap;
                        pntEID.SnapTolerance    = CommonHelper.ConvertPixelsToMapUnits(_context.ActiveView, 5.0);
                        double percent;
                        int    edgeID;
                        IPoint location;
                        pntEID.GetNearestEdge(newCenter, out edgeID, out location, out percent);
                        if (percent == 0)
                        {
                            return;
                        }

                        int userClassID, userID, userSubID;

                        network.QueryIDs(edgeID, esriElementType.esriETEdge, out userClassID, out userID, out userSubID);
                        if (pClass.FeatureClassID == userClassID)
                        {
                            feature = pClass.GetFeature(userID);
                        }
                        else
                        {
                            IEnumDataset dses = pNetworkClass.FeatureDataset.Subsets;
                            dses.Reset();
                            IDataset ds = dses.Next();
                            while (ds != null)
                            {
                                if (ds is IFeatureClass)
                                {
                                    IFeatureClass pClass2 = ds as IFeatureClass;
                                    if (pClass2.FeatureClassID == userClassID)
                                    {
                                        feature = pClass2.GetFeature(userID);
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    oID = feature.OID;
                }
                if (Shift != 1)
                {
                    this.m_SectionControl.Clear();
                    this.m_SectionControl.LayerName = aliasName;
                    this.m_SectionControl.Add(oID);
                }
                else if (this.m_SectionControl.Count == 0)
                {
                    this.m_SectionControl.LayerName = aliasName;
                    this.m_SectionControl.Add(oID);
                }
                else if (this.m_SectionControl.IsInSameLayer(aliasName))
                {
                    this.m_SectionControl.LayerName = aliasName;
                    this.m_SectionControl.Add(oID);
                }
            }
        }