コード例 #1
0
ファイル: PERFQA_ARCFM.cs プロジェクト: UDCUS/ArcFM_PerfQA
        private bool PlaceFlag(string sClassName, string sOID)
        {
            IFeatureClass pFC;
            IFeatureWorkspace pFWKS;
            IFeature pFeat;
            INetElements pNetElements;
            ISimpleJunctionFeature pJunc;
            INetworkAnalysisExt pNetworkAnalysisExt;
            IMxDocument pMXDoc;
            IApplication pApp;
            IMxApplication pMXApp;
            INetworkAnalysisExtFlags pNetworkAnalysisExtFlags;
            UID pUID;
            ITraceFlowSolverGEN pTraceFlowSolver;
            INetSolver pNetSolver;
            Miner.Interop.IMMTraceUIUtilities pTraceUtils;
            IPolycurve pPoly;
            int iCLSID;
            int iOID;
            int iSUBID;

            try
            {
                SW1.Reset();
                SW1.Start();

                Type t = Type.GetTypeFromProgID("esriFramework.AppRef");
                System.Object obj = Activator.CreateInstance(t);
                pApp = obj as IApplication;
                pMXApp = (IMxApplication)pApp;
                pMXDoc = (IMxDocument)pApp.Document;
                pUID = new UID();
                pUID.Value = "esriEditorExt.UtilityNetworkAnalysisExt";
                pNetworkAnalysisExt = (INetworkAnalysisExt)pApp.FindExtensionByCLSID(pUID);
                pNetworkAnalysisExtFlags = (INetworkAnalysisExtFlags)pNetworkAnalysisExt;
                pNetElements = (INetElements)pNetworkAnalysisExt.CurrentNetwork.Network;
                pTraceUtils = new Miner.Interop.MMTraceUIUtilities();

                pFWKS = (IFeatureWorkspace)Workspace;
                pFC = pFWKS.OpenFeatureClass(sClassName);
                if (pFC != null)
                {
                    pFeat = pFC.GetFeature(Convert.ToInt32(sOID));
                    INetworkFeature pNetFeat = (INetworkFeature)pFeat;
                    m_pGN = pNetFeat.GeometricNetwork;
                    if (pFeat != null)
                    {
                        pTraceFlowSolver = (ITraceFlowSolverGEN)new TraceFlowSolver();
                        pNetSolver = (INetSolver)pTraceFlowSolver;
                        if (pFeat.FeatureType == esriFeatureType.esriFTSimpleJunction)
                        {
                            pJunc = (ISimpleJunctionFeature)pFeat;
                            pNetElements.QueryIDs(pJunc.EID, esriElementType.esriETEdge, out iCLSID, out iOID, out iSUBID);
                            //pJFlag = (INetFlag)new JunctionFlag();
                            //pJFlag.UserClassID = iCLSID;
                            //pJFlag.UserID = iOID;
                            //pJFlag.UserSubID = iSUBID;
                            IFlagDisplay pFlagDisplay = new JunctionFlagDisplay();
                            pFlagDisplay.Symbol = (ISymbol)CreateMarkerSymbol(0);
                            pFlagDisplay.Geometry = (IPoint)pFeat.ShapeCopy;
                            //Set pNetSolver.SourceNetwork = pNetElements
                            pNetworkAnalysisExtFlags.AddJunctionFlag((IJunctionFlagDisplay)pFlagDisplay);
                        }
                        else
                        {
                            IPoint pPoint;
                            pPoint = new Point();
                            double dDist;
                            dDist = .5;
                            pPoly = (IPolycurve)pFeat.ShapeCopy;
                            pPoly.QueryPoint(esriSegmentExtension.esriNoExtension, dDist, true, pPoint);
                            IFlagDisplay pFlagDisplay = new EdgeFlagDisplay();
                            IEdgeFeature pEdge = (IEdgeFeature)pFeat;
                            IObjectClass pOC = (IObjectClass)pFeat.Table;
                            int iEID = pNetElements.GetEID(pOC.ObjectClassID, pFeat.OID, 0, esriElementType.esriETEdge);
                            //pNetElements.QueryIDs(pEdge.ToJunctionEID, esriElementType.esriETEdge, out iCLSID, out iOID, out iSUBID);
                            pFlagDisplay.FeatureClassID = pOC.ObjectClassID;
                            pFlagDisplay.FID = pFeat.OID;
                            pFlagDisplay.SubID = 0;
                            //pFlagDisplay.Geometry = pPoint;
                            pFlagDisplay.Symbol = (ISymbol)CreateMarkerSymbol(0);
                            ISimpleMarkerSymbol pSMS = (ISimpleMarkerSymbol)pFlagDisplay.Symbol;
                            IColor pColor;
                            pColor = new RgbColor();
                            pColor.RGB = 100;
                            pSMS.Size = 10;
                            pNetworkAnalysisExtFlags.AddEdgeFlag((IEdgeFlagDisplay)pFlagDisplay);
                        }
                    }
                }
                SW1.Stop();
                RecordActionTime("PLACEFLAG" , SW1.ElapsedMilliseconds);
                return true;
            }
            catch (Exception EX)
            {
                Logger.WriteLine("Error in PlaceFlags " + EX.Message + " " + EX.StackTrace);
                return false;
            }
        }
コード例 #2
0
ファイル: PERFQA_ARCFM.cs プロジェクト: UDCUS/ArcFM_PerfQA
        private bool ArcFMGasTrace(string sTraceType)
        {
            ESRI.ArcGIS.EditorExt.INetworkAnalysisExt _pNetworkAnalysisExt = null;
            ESRI.ArcGIS.EditorExt.INetworkAnalysisExtFlags _pNetworkAnalysisExtFlags = null;
            ESRI.ArcGIS.EditorExt.INetworkAnalysisExtResults _pNetworkAnalysisExtResults = null;
            ESRI.ArcGIS.EditorExt.ITraceTask _pArcFMGasValveIsolationTask = null;
            ESRI.ArcGIS.Geodatabase.IGeometricNetwork _pGeometricNetwork = null;
            ESRI.ArcGIS.Geodatabase.IEnumNetEID _pResultJunctions = null;
            ESRI.ArcGIS.Geodatabase.IEnumNetEID _pResultEdges = null;
            Miner.Interop.IMMTraceUIUtilities _pTraceUtils = null;
            ArrayList _pBackFeedStarterEdges = null;
            ArrayList _pResultEdgeEIDs = null;
            ArrayList _pResultJunctionEIDs = null;

            try
            {
                SW1.Reset();
                SW1.Start();
                IMxDocument pMXDoc;
                IApplication pApp;
                Type t = Type.GetTypeFromProgID("esriFramework.AppRef");
                System.Object obj = Activator.CreateInstance(t);
                pApp = obj as IApplication;
                pMXDoc = (IMxDocument)pApp.Document;

                _pNetworkAnalysisExt = (INetworkAnalysisExt)pApp.FindExtensionByName("Utility Network Analyst");
                if (_pNetworkAnalysisExt != null)
                {
                    _pNetworkAnalysisExtFlags = (INetworkAnalysisExtFlags)_pNetworkAnalysisExt;
                    _pNetworkAnalysisExtResults = (INetworkAnalysisExtResults)_pNetworkAnalysisExt;
                    _pGeometricNetwork = _pNetworkAnalysisExt.CurrentNetwork;
                    _pTraceUtils = new Miner.Interop.MMTraceUIUtilities();
                    if (_pTraceUtils != null)
                    {
                        _pArcFMGasValveIsolationTask = _pTraceUtils.GetTraceTaskByName(_pNetworkAnalysisExt, "ArcFM Gas Valve Isolation");
                        if (_pArcFMGasValveIsolationTask != null)
                        {
                            // Set current task on the network.
                            ITraceTasks pTraceTasks = (ITraceTasks)_pNetworkAnalysisExt;
                            pTraceTasks.CurrentTask = _pArcFMGasValveIsolationTask;
                            // Set up the flag symbol. (Only necessary for ITraceTask integration,
                            // since flags are not displayed as part of this application.)
                            // Allocate supporting structures.
                            _pBackFeedStarterEdges = new ArrayList();
                            _pBackFeedStarterEdges.Clear();
                            INetElements pNetElements = (INetElements)_pGeometricNetwork.Network;

                            // Start from scratch.
                            _pResultEdgeEIDs = new ArrayList();
                            _pResultEdgeEIDs.Clear();
                            _pResultJunctionEIDs = new ArrayList();
                            _pResultJunctionEIDs.Clear();

                            // Accumulate results.
                            ITraceTaskResults pArcFMGasValveIsolationTaskResults = (ITraceTaskResults)_pArcFMGasValveIsolationTask;
                            _pResultJunctions = pArcFMGasValveIsolationTaskResults.ResultJunctions;
                            _pResultJunctions.Reset();
                            for (int iCntr = 0; iCntr < _pResultJunctions.Count; iCntr++)
                            {
                                int iEID = _pResultJunctions.Next();
                                if (!(_pResultJunctionEIDs.Contains(iEID)))
                                    _pResultJunctionEIDs.Add(iEID);
                            }
                            _pResultEdges = pArcFMGasValveIsolationTaskResults.ResultEdges;
                            _pResultEdges.Reset();
                            for (int iCntr = 0; iCntr < _pResultEdges.Count; iCntr++)
                            {
                                int iEID = _pResultEdges.Next();
                                if (!_pResultEdgeEIDs.Contains(iEID))
                                    _pResultEdgeEIDs.Add(iEID);
                            }
                        }
                    }
                    SW1.Stop();
                    RecordActionTime("ArcFMGasTrace", SW1.ElapsedMilliseconds);
                }
                else
                {
                    this.Logger.WriteLine("Missing Utility Network AnalysisExt");
                    return false;
                }
                return true;
            }
            catch (Exception EX)
            {
                this.Logger.WriteLine("Error in ArcFMGasTrace " + EX.Message + " " + EX.StackTrace);
                return false;
            }
        }