Exemple #1
0
        //Ϊ�����������ñߵ�Flag
        private void BurstSetEdgeFlag(IPoint pPoint)
        {
            //
            try
            {
                INetElements pNetElements = pGeoNetwork.Network as INetElements;
                IPointToEID pPtToEID = new PointToEIDClass();
                IPoint pNewPt;
                int iUserClassID;
                int iUserID;
                int iUserSubID;
                double dPercent;
                int eid;
                pPtToEID.SourceMap = axMapControl1.ActiveView.FocusMap;
                pPtToEID.GeometricNetwork = pGeoNetwork;
                pPtToEID.SnapTolerance = axMapControl1.ActiveView.Extent.Envelope.Width / 100;
                pPtToEID.GetNearestEdge(pPoint, out eid, out pNewPt, out dPercent);
                if (pNewPt == null)
                {
                    MessageBox.Show("û�в������ٽ��ı�");
                }
                else
                {
                    pNetElements.QueryIDs(eid, esriElementType.esriETEdge, out iUserClassID, out iUserID, out iUserSubID);
                    IMarkerSymbol pMarkerSym = new SimpleMarkerSymbolClass();
                    IRgbColor pRGBColor = new RgbColorClass();
                    pRGBColor.Red = 255;
                    pRGBColor.Green = 0;
                    pRGBColor.Blue = 0;
                    pMarkerSym.Color = pRGBColor;
                    pMarkerSym.Size = 20;
                    //�����µ�Flag

                    IEdgeFlagDisplay pEdgeFlagDisplay = new EdgeFlagDisplayClass();
                    IFlagDisplay pFlagDisplay = pEdgeFlagDisplay as IFlagDisplay;
                    pFlagDisplay.Symbol = pMarkerSym as ISymbol;
                    pFlagDisplay.Geometry = pNewPt;
                    pFlagDisplay.FeatureClassID = iUserClassID;
                    pFlagDisplay.FID = iUserID;
                    pFlagDisplay.SubID = iUserSubID;

                    //���Ƹõ�
                    IScreenDisplay pScreenDisplay = axMapControl1.ActiveView.ScreenDisplay;
                    pScreenDisplay.StartDrawing(pScreenDisplay.hDC, 0);
                    pScreenDisplay.SetSymbol(pMarkerSym as ISymbol);
                    pScreenDisplay.DrawPoint(pNewPt as IGeometry);
                    pScreenDisplay.FinishDrawing();
                    BurstFindValves(pFlagDisplay);
                }
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }
        }
        public static void UpStreamTrace(AxMapControl ppAxMapControl, IPoint pPoint, IGeometricNetwork pGeoNetwork)
        {
            try
            {
                //�����ͼ��ѡ��
                ppAxMapControl.ActiveView.FocusMap.ClearSelection();
                INetElements pNetElements = pGeoNetwork.Network as INetElements;
                IPointToEID pPtToEID = new PointToEIDClass();
                int pJunctionID = 0;
                int iUserClassID;
                int iUserID;
                int iUserSubID;
                IPoint pLocation;

                pPtToEID.SourceMap = ppAxMapControl.ActiveView.FocusMap;
                pPtToEID.GeometricNetwork = pGeoNetwork;
                pPtToEID.SnapTolerance = ppAxMapControl.ActiveView.Extent.Envelope.Width / 100;
                pPtToEID.GetNearestJunction(pPoint, out pJunctionID, out pLocation);
                if (pJunctionID == 0)
                {
                    MessageBox.Show("û�в������ٽ��ĵ�");
                }
                else
                {
                    pNetElements.QueryIDs(pJunctionID, esriElementType.esriETJunction, out iUserClassID, out iUserID, out iUserSubID);
                    INetFlag ipNetFlag = new JunctionFlagClass();
                    ipNetFlag.UserClassID = iUserClassID;
                    ipNetFlag.UserID = iUserID;
                    ipNetFlag.UserSubID = iUserSubID;

                    IMarkerSymbol pMarkerSym = new SimpleMarkerSymbolClass();
                    IRgbColor pRGBColor = new RgbColorClass();
                    pRGBColor.Red = 255;
                    pRGBColor.Green = 0;
                    pRGBColor.Blue = 0;
                    pMarkerSym.Color = pRGBColor;
                    pMarkerSym.Size = 20;
                    //�����µ�Flag

                    IEdgeFlagDisplay pEdgeFlagDisplay = new EdgeFlagDisplayClass();
                    IFlagDisplay pFlagDisplay = pEdgeFlagDisplay as IFlagDisplay;
                    pFlagDisplay.Symbol = pMarkerSym as ISymbol;
                    pFlagDisplay.Geometry = pLocation;
                    pFlagDisplay.FeatureClassID = iUserClassID;
                    pFlagDisplay.FID = iUserID;
                    pFlagDisplay.SubID = iUserSubID;

                    //���Ƹõ�
                    IScreenDisplay pScreenDisplay = ppAxMapControl.ActiveView.ScreenDisplay;
                    pScreenDisplay.StartDrawing(pScreenDisplay.hDC, 0);
                    pScreenDisplay.SetSymbol(pMarkerSym as ISymbol);
                    pScreenDisplay.DrawPoint(pLocation as IGeometry);
                    pScreenDisplay.FinishDrawing();
                    //����׷�ٽ��
                    FindStreamTraceResult(ppAxMapControl, ipNetFlag, pGeoNetwork);
                }
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }
        }
Exemple #3
0
        /// <summary>
        /// Adds  edge flags for a feature layer
        /// </summary>
        /// <param name="layer">The feature layer</param>
        private void AddEdgeFlags(IFeatureLayer layer)
        {
            try
            {
                // QI all the network analysis interfaces
                INetworkAnalysisExt         netAnalyst = (INetworkAnalysisExt)this.UtilityNetAnalysisExt;
                INetworkAnalysisExtFlags    flags      = (INetworkAnalysisExtFlags)this.UtilityNetAnalysisExt;
                INetworkAnalysisExtBarriers barriers   = (INetworkAnalysisExtBarriers)this.UtilityNetAnalysisExt;

                IPointToEID point2EID = new PointToEIDClass();
                point2EID.GeometricNetwork = this.NetworkAnalysisExt.CurrentNetwork;
                point2EID.SourceMap        = ((IMxDocument)this.Application.Document).FocusMap;
                point2EID.SnapTolerance    = this.SnapTolerance;

                INetElements networkElements = (INetElements)this.NetworkAnalysisExt.CurrentNetwork.Network;

                IFeatureSelection featureSelection = (IFeatureSelection)layer;
                ISelectionSet     selectionSet     = (ISelectionSet)featureSelection.SelectionSet;

                IEnumIDs ids = selectionSet.IDs;

                int i;

                while ((i = ids.Next()) > 0)
                {
                    IFeature feature = layer.FeatureClass.GetFeature(i);

                    IPoint locationPoint;
                    int    nearestEdgeID;
                    double perCent;

                    point2EID.GetNearestEdge((IPoint)feature.ShapeCopy, out nearestEdgeID, out locationPoint, out perCent);

                    if (networkElements.IsValidElement(nearestEdgeID, esriElementType.esriETEdge))
                    {
                        int userclassID;
                        int userID;
                        int usersubID;

                        networkElements.QueryIDs(nearestEdgeID, esriElementType.esriETEdge, out userclassID, out userID, out usersubID);

                        IFlagDisplay flagDisplay = new EdgeFlagDisplayClass();
                        flagDisplay.FeatureClassID = userclassID;
                        flagDisplay.FID            = userID;
                        flagDisplay.SubID          = usersubID;

                        flagDisplay.Geometry = locationPoint;

                        flagDisplay.Symbol = this.EdgeFlagSymbol;

                        flags.AddEdgeFlag((IEdgeFlagDisplay)flagDisplay);
                        this.AddFlagCount++;
                        this.OnAddFlag(locationPoint);
                    }
                    else
                    {
                        this.OnAddFlagError(layer.Name, "No nearby edge feature.", feature.OID);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.StackTrace);
                throw;
            }
        }