protected override void OnUpdate()
        {
            // by default, disable the command
            Enabled = false;

            // if there is not a current edit session, then disable the command
            if (m_editorExt.EditState != esriEditState.esriStateEditing)
            {
                return;
            }

            // otherwise, check to see if the flow direction is properly set for each edge EID
            IUtilityNetwork utilNet  = GetCurrentNetwork() as IUtilityNetwork;
            IEnumNetEID     edgeEIDs = GetCurrentEIDs(esriElementType.esriETEdge);

            edgeEIDs.Reset();
            for (int i = 0; i < edgeEIDs.Count; i++)
            {
                int edgeEID = edgeEIDs.Next();
                esriFlowDirection flowDir = utilNet.GetFlowDirection(edgeEID);
                if (flowDir != esriFlowDirection.esriFDWithFlow)
                {
                    // enable the command if the flow direction is not with the digitized direction
                    Enabled = true;

                    // we can return right now, since only one edge needs to have
                    // incorrect flow direction in order to enable the command
                    return;
                }
            }
        }
        protected override void OnClick()
        {
            // get the current network
            IUtilityNetwork utilNet = GetCurrentNetwork() as IUtilityNetwork;

            // create an edit operation enabling an undo for this operation
            m_editorExt.StartOperation();

            // get a list of the current EIDs for edges in the network
            IEnumNetEID edgeEIDs = GetCurrentEIDs(esriElementType.esriETEdge);

            // set the flow direction for each edge in the network
            edgeEIDs.Reset();
            for (int i = 0; i < edgeEIDs.Count; i++)
            {
                int edgeEID = edgeEIDs.Next();
                utilNet.SetFlowDirection(edgeEID, esriFlowDirection.esriFDWithFlow);
            }

            // stop the edit operation, specifying a name for this operation
            m_editorExt.StopOperation("Set Flow Direction");

            // refresh the display to update the flow direction arrows
            IActiveView mapView = ArcMap.Document.ActiveView;

            mapView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
 /// <summary>
 /// Converts an Esri enumerable interface to a DotNet IEnumerable.
 /// </summary>
 /// <param name="esriEnum">An enumerable Esri interface.</param>
 /// <returns>The adapted dotnet enumeration.</returns>
 public static IEnumerable <int> Enumerate(this IEnumNetEID esriEnum)
 {
     esriEnum.Reset();
     for (int item = esriEnum.Next(); item > 0; item = esriEnum.Next())
     {
         yield return(item);
     }
 }
Exemple #4
0
        /// <summary>
        ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="IEnumNetEID" />
        /// </summary>
        /// <param name="source">An <see cref="IEnumNetEID" /> to create an <see cref="IEnumerable{T}" /> from.</param>
        /// <returns>An <see cref="IEnumerable{T}" /> that contains the datasets from the input source.</returns>
        public static IEnumerable <int> AsEnumerable(this IEnumNetEID source)
        {
            if (source != null)
            {
                source.Reset();
                int eid = source.Next();
                while (eid != 0)
                {
                    yield return(eid);

                    eid = source.Next();
                }
            }
        }
Exemple #5
0
        private void method_4(INetwork network)
        {
            IUtilityNetwork utilityNetwork = (IUtilityNetwork)network;
            IEnumNetEID     enumNetEID     = network.CreateNetBrowser((esriElementType)2);

            enumNetEID.Reset();
            long num  = (long)enumNetEID.Count;
            int  num2 = 0;

            while ((long)num2 < num)
            {
                int num3 = enumNetEID.Next();
                utilityNetwork.SetFlowDirection(num3, (esriFlowDirection)1);
                num2++;
            }
        }
        //��˷׷�ٲ��ҹ����漰�ĵؿ�
        public static void UpStreamFindParcels(AxMapControl ppAxMapControl, IEnumNetEID pEnumResultEdges, IGeometricNetwork pGeoNetwork)
        {
            try
            {

                IFeatureLayer pFeatLayerSewerLines = FindFeatLayer("Sewer Lines", ppAxMapControl);
                IFeatureLayer pFeatLayerParcels = FindFeatLayer("Parcels", ppAxMapControl);
                //����ѡ���Sewer�������д������ΰ�

                IGeometryCollection pGeomBag = new GeometryBagClass();
                object missing = Type.Missing;
                int lEID;
                int iUserClassID;
                int iUserID;
                int iUserSubID;
                INetElements pNetElements = pGeoNetwork.Network as INetElements;
                pEnumResultEdges.Reset();
                IFeature pFeature;

                for (int j = 0; j <= pEnumResultEdges.Count - 1; j++)
                {
                    lEID = pEnumResultEdges.Next();
                    pNetElements.QueryIDs(lEID, esriElementType.esriETEdge, out iUserClassID, out iUserID, out iUserSubID);
                    pFeature = pFeatLayerSewerLines.FeatureClass.GetFeature(iUserID);
                    pGeomBag.AddGeometry(pFeature.Shape, ref missing, ref missing);
                    // MessageBox.Show(iUserClassID.ToString()+","+iUserID.ToString()+","+iUserSubID.ToString());
                }
                //���пռ����˵��Ӳ��������ڲ��ҵؿ���Ϣ
                ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                pSpatialFilter.Geometry = pGeomBag as IGeometry;
                pSpatialFilter.GeometryField = "Shape";
                pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;

                //��ý��浽�ĵؿ���Ϣ
                IFeatureCursor pFeatCursor = pFeatLayerParcels.FeatureClass.Search(pSpatialFilter, false);
                //���ӱ�ѡ��ĵؿ����ݵ���ͼ��ͼ��ͼ��������
                ICompositeGraphicsLayer pComGraphicLayer = new CompositeGraphicsLayerClass();
                ILayer pLayer = pComGraphicLayer as ILayer;
                pLayer.Name = "��Ӱ��ĵؿ�";
                IGraphicsContainer pGraphicContainer = pComGraphicLayer as IGraphicsContainer;
                //������ѡ��ĵؿ鵽ͼ��������
                ISimpleFillSymbol pSymFill = new SimpleFillSymbolClass();
                IFillSymbol pFillSymbol = pSymFill as IFillSymbol;
                IRgbColor pRgbColor = new RgbColorClass();
                pRgbColor.Red = 0;
                pRgbColor.Green = 200;
                pRgbColor.Blue = 100;
                pFillSymbol.Color = pRgbColor as IColor;
                ICartographicLineSymbol pCartoLine = new CartographicLineSymbolClass();
                IRgbColor pRgbColor2 = new RgbColorClass();
                pRgbColor2.Red = 100;
                pRgbColor2.Green = 200;
                pRgbColor2.Blue = 100;
                pCartoLine.Width = 2;
                pCartoLine.Color = pRgbColor2 as IColor;
                pFillSymbol.Outline = pCartoLine;
                //����������еؿ�����������
                IArray pFeatArray = new ArrayClass();
                pFeature = pFeatCursor.NextFeature();
                while (pFeature != null)
                {
                    IElement pPolyElement = new PolygonElementClass();
                    IFillShapeElement pFillShapeElement = pPolyElement as IFillShapeElement;
                    pPolyElement.Geometry = pFeature.Shape;
                    pFillShapeElement.Symbol = pFillSymbol;
                    pGraphicContainer.AddElement(pPolyElement, 0);
                    pFeatArray.Add(pFeature);
                    pFeature = pFeatCursor.NextFeature();
                }
                ppAxMapControl.AddLayer(pGraphicContainer as ILayer);
                ppAxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                //ma
                //frmUpstreamCreateOwnerList frmUpstreamCreateOwnerList1 = new frmUpstreamCreateOwnerList(ppAxMapControl,pFeatLayerParcels, pFeatArray);
                //frmUpstreamCreateOwnerList1.Show();
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }
        }
        //�������ĸ߳�����
        public static void ProfileGetRelatedSewerElevData(AxMapControl ppAxMapControl, IGeometricNetwork pGeoNetwork, IEnumNetEID pResultEdges, IEnumNetEID pResultJunctions)
        {
            try
            {
                //��ñ������Զ�Ӧ������׷�ٽ��
                IArray pSewerElevArray = new ArrayClass();
                IEIDHelper pEIDHelper = new EIDHelperClass();
                pEIDHelper.GeometricNetwork = pGeoNetwork;
                pEIDHelper.ReturnFeatures = true;
                pEIDHelper.ReturnGeometries = true;
                pEIDHelper.PartialComplexEdgeGeometry = true;
                pEIDHelper.AddField("Component_Key2");
                IEnumEIDInfo pEnumEIDInfo = pEIDHelper.CreateEnumEIDInfo(pResultEdges);
                //�������߻�����ص������߼�¼
                pEnumEIDInfo.Reset();
                IEIDInfo pEIDInfo = pEnumEIDInfo.Next();
                IFeature pFeature = pEIDInfo.Feature;
                IGeometry pFeatGeo = pEIDInfo.Geometry;
                //�������л�ù�ϵ
                IEnumRelationshipClass pEnumRelationshipCls = pFeature.Class.get_RelationshipClasses(esriRelRole.esriRelRoleOrigin);
                pEnumRelationshipCls.Reset();
                IRelationshipClass pRelationshipCls = pEnumRelationshipCls.Next();
                //�����ȷ�Ĺ�ϵ��
                string s = "SewerToMainline";
                while (pRelationshipCls != null)
                {
                    if (pRelationshipCls.ForwardPathLabel.ToUpper() == s.ToUpper())
                        break;
                    else
                        pRelationshipCls = pEnumRelationshipCls.Next();
                }
                //��ѯ���ɹ�����ÿ������ص����ݣ������1-1�Ĺ�ϵ����ֻ����һ����¼
                //  because the arcs are ordered and directional, if the start node is an
                //  fnode then get subsequent tnode's for the rest of the arcs, else if the
                //  start node is a tnode, get subsequent fnode's.  Related data has elev
                //  attributes for up and down stream manhole elevs, so related to from and to node of arc.
                // get the first junction in the network trace results to determine if the
                //first junction is a from-node or a to-node for graphing sewer line elev
                if (pRelationshipCls != null)
                {
                    ISet pMainlineRelatedSet;
                    IRow pMainlineRow;
                    IEIDHelper pEIDHelper2 = new EIDHelperClass();
                    pEIDHelper2.GeometricNetwork = pGeoNetwork;
                    pEIDHelper2.ReturnFeatures = true;
                    pEIDHelper2.ReturnGeometries = true;
                    pEIDHelper2.PartialComplexEdgeGeometry = true;
                    IEnumEIDInfo pEnumEIDInfo2 = pEIDHelper2.CreateEnumEIDInfo(pResultJunctions);
                    pEnumEIDInfo2.Reset();
                    //pFeature is the first arc in the network trace results
                    // check the junctions on the first arc to see which is the starting
                    // junction, this determines which sewer elev attribute (ups_elev, dwn_elev)
                    // will be used to calculate the sewer line profile
                    IEdgeFeature pEdgeFeat = pFeature as IEdgeFeature;
                    string strStartAttr;
                    string strMHelevAttr;
                    double lastelev = 0;
                    int lastnodeEID;
                    if (pEnumEIDInfo2.Next().EID == pEdgeFeat.FromJunctionEID)
                    {
                        // trace is in the direction of flow, flow goes down hill
                        strStartAttr = "Ups_elev";
                        strMHelevAttr = "Dwn_elev";
                    }
                    else
                    {
                        //trace is in the opposite direction of flow, flow goes up hill
                        strStartAttr = "Dwn_elev";
                        strMHelevAttr = "Ups_elev";
                    }
                    lastnodeEID = pEnumEIDInfo2.Next().EID;
                    // create a polyline from the result junctions, make the polyline in the
                    //direction of the trace, not in the direction of the original arcs/edges
                    IPolyline pPolyline = new PolylineClass();
                    IPointCollection pPointColl = pPolyline as IPointCollection;
                    pEnumEIDInfo2.Reset();
                    object missing = Type.Missing;
                    for (int i = 0; i <= pEnumEIDInfo2.Count - 1; i++)
                    {
                        pPointColl.AddPoint(pEnumEIDInfo2.Next().Geometry as IPoint, ref missing, ref missing);
                    }
                    ISegmentCollection pSegColl = pPolyline as ISegmentCollection;
                    //�򻯶����
                    ITopologicalOperator pTopoOp = pPolyline as ITopologicalOperator;
                    pTopoOp.Simplify();
                    pPolyline.SimplifyNetwork();
                    pPolyline.Densify(50, 0.01);
                    pResultEdges.Reset();
                    pEnumEIDInfo2.Reset();
                    IPolyline pNewSegPolyline;
                    IPolyline pPolyLineFeat;
                    IRelationalOperator pRelOpFeat;
                    ISegmentCollection pNewSegColl;
                    ISegmentCollection pSegmentColl = pPolyline as ISegmentCollection;
                    for (int i = 0; i <= pResultEdges.Count - 1; i++)
                    {
                        pMainlineRelatedSet = pRelationshipCls.GetObjectsRelatedToObject(pFeature);
                        pMainlineRelatedSet.Reset();
                        pMainlineRow = pMainlineRelatedSet.Next() as IRow;
                        pPolyLineFeat = pFeature.Shape as IPolyline;
                        pRelOpFeat = pPolyLineFeat as IRelationalOperator;
                        for (int j = 0; j <= pSegmentColl.SegmentCount - 1; j++)
                        {
                            pNewSegPolyline = new PolylineClass();
                            pNewSegColl = pNewSegPolyline as ISegmentCollection;
                            pNewSegColl.AddSegment(pSegmentColl.get_Segment(j), ref missing, ref missing);
                            if (pRelOpFeat.Contains(pNewSegPolyline as IGeometry))
                            {
                                if (j == 0)
                                {
                                    pSewerElevArray.Add(pMainlineRow.get_Value(pMainlineRow.Fields.FindField(strStartAttr)));
                                    lastelev = Convert.ToDouble(pMainlineRow.get_Value(pMainlineRow.Fields.FindField(strMHelevAttr)));
                                }
                                else
                                {
                                    if (lastelev == Convert.ToDouble(pMainlineRow.get_Value(pMainlineRow.Fields.FindField(strMHelevAttr))))
                                    {
                                        pSewerElevArray.Add(-99);
                                    }
                                    else
                                    {
                                        pSewerElevArray.Add(lastelev);
                                        lastelev = Convert.ToDouble(pMainlineRow.get_Value(pMainlineRow.Fields.FindField(strMHelevAttr)));
                                    }
                                }
                            }
                        }
                        // get the next feature and check to see what direction it's going and
                        //adjust the variables accordingly
                        if (i < pResultEdges.Count - 1)
                        {
                            lastnodeEID = pEdgeFeat.ToJunctionEID;
                            pFeature = pEnumEIDInfo.Next().Feature;
                            pEdgeFeat = pFeature as IEdgeFeature;
                            if (pEdgeFeat.FromJunctionEID == lastnodeEID)
                                strMHelevAttr = "Dwn_elev";
                            else
                                strMHelevAttr = "Ups_elev";

                        }
                        else
                        {
                            pSewerElevArray.Add(pMainlineRow.get_Value(pMainlineRow.Fields.FindField(strMHelevAttr)));

                        }
                    }
                    ProfileCreateGraph(ppAxMapControl, pPolyline, pSewerElevArray);
                }
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }
        }
        public static string TracePath(double[] Xs, double[] Ys, string GeoNetName, IApplication app, IMap map, bool traceIndeterminate,
                                   double snapTol, bool selectEdges, out IEnumNetEID juncEIDs, out IEnumNetEID edgeEIDs, out IGeometricNetwork gn)
        {
            gn = null;

            juncEIDs = null;
            edgeEIDs = null;

            List<INetFlag> pNetFlags = null;
            IFlagDisplay pFlagDisplay = null;

            IJunctionFlag[] junctionFlags = null;
            IEdgeFlag[] edgeFlags = null;

            ITraceFlowSolverGEN traceFlowSolver = null;

            List<IEdgeFlag> pEdgeFlags = null;
            List<IJunctionFlag> pJunctionFlags = null;
            INetElementBarriers pEdgeElementBarriers;
            INetElementBarriers pJunctionElementBarriers;
            ISelectionSetBarriers pSelectionSetBarriers;
            List<IGeometricNetwork> gnList = null;
            INetworkAnalysisExt pNetAnalysisExt = null;
            UID pID = null;
            try
            {
                gnList = Globals.GetGeometricNetworks(ref map);
                if (gnList == null)
                {
                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_17a"));
                    return "";
                }

                int gnIdx = -1;

                gnIdx = Globals.GetGeometricNetwork(ref gnList, GeoNetName);
                if (gnIdx != -1)
                {
                    gn = (IGeometricNetwork)gnList[gnIdx];
                }

                pNetFlags = new List<INetFlag>();

                //  INetFlag[] netFlags = new INetFlag[Xs.Length];

                for (int i = 0; i < Xs.Length; i++)
                {
                    IPoint snappedPoint = null; int EID = -1;
                    if (gn == null)
                    {

                        pNetFlags.Add(Globals.GetJunctionFlag(Xs[i], Ys[i], ref map, ref gnList, snapTol, ref gnIdx,
                                    out snappedPoint, out EID, out  pFlagDisplay, true) as INetFlag);

                        //Set network to trace
                        if (gnIdx > -1)
                            gn = gnList[gnIdx] as IGeometricNetwork;

                    }
                    else
                    {
                        pNetFlags.Add(Globals.GetJunctionFlagWithGN(Xs[i], Ys[i], ref map, ref gn, ref snapTol, out snappedPoint, out EID, out  pFlagDisplay, true) as INetFlag);

                    }
                }

                if (gn == null || pNetFlags.Count < 1)
                {
                    return (A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_17b"));

                }

                if (app != null)
                {

                    pID = new UID();

                    pID.Value = "esriEditorExt.UtilityNetworkAnalysisExt";
                    pNetAnalysisExt = (INetworkAnalysisExt)app.FindExtensionByCLSID(pID);
                    Globals.SetCurrentNetwork(ref pNetAnalysisExt, ref gn);
                    traceFlowSolver = Globals.CreateTraceFlowSolverFromToolbar(ref pNetAnalysisExt, out pEdgeFlags, out pJunctionFlags, out pEdgeElementBarriers, out pJunctionElementBarriers, out pSelectionSetBarriers) as ITraceFlowSolverGEN;

                }
                else
                {
                    traceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolverGEN;
                    INetSolver netSolver = traceFlowSolver as INetSolver;

                    netSolver.SourceNetwork = gn.Network;

                }

                traceFlowSolver.TraceIndeterminateFlow = traceIndeterminate;

                if (pEdgeFlags != null)
                {
                    foreach (IEdgeFlag pEdFl in pEdgeFlags)
                    {
                        pNetFlags.Add((INetFlag)pEdFl);

                    }
                }
                if (pJunctionFlags != null)
                {

                    foreach (IJunctionFlag pJcFl in pJunctionFlags)
                    {
                        pNetFlags.Add((INetFlag)pJcFl);
                    }
                }
                //if (startNetFlag != null)
                //{

                //    pNetFlags.Add((INetFlag)startNetFlag);

                //}

                Globals.AddFlagsToTraceSolver(pNetFlags.ToArray(), ref traceFlowSolver, out junctionFlags, out edgeFlags);
                int intCount = 1;
                System.Object[] segCosts = new System.Object[1];
                segCosts[0] = new System.Object();

                traceFlowSolver.FindPath(esriFlowMethod.esriFMConnected, esriShortestPathObjFn.esriSPObjFnMinMax,
                    out juncEIDs, out edgeEIDs, intCount, ref segCosts);

                //Select junction features
                map.ClearSelection();
                IJunctionFlag[] junctionFlag = null;
                Globals.SelectJunctions(ref map, ref  gn, ref juncEIDs, ref junctionFlag, "", "", "", true);
                if (selectEdges)
                    Globals.SelectEdges(ref map, ref gn, ref edgeEIDs);
                edgeEIDs.Reset();

                //Draw edge graphics
                IEnvelope env = Globals.DrawEdges(ref map, ref gn, ref edgeEIDs);

                return edgeEIDs.Count.ToString();

            }
            catch (Exception Ex)
            {
                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsLbl_17a") + "\n" + Ex.Message);
                return "";

            }
        }
Exemple #9
0
        public void GetFlow(IMap pMap)
        {
            int num4;

            this.m_pPointcol = new MultipointClass();
            this.m_eFlowDirection.Clear();
            this.m_angle.Clear();
            INetwork        network  = NetworkAnalyst.m_pAnalystGN.Network;
            IUtilityNetwork network2 = network as IUtilityNetwork;
            IEnumNetEID     netEIDs  = network.CreateNetBrowser(esriElementType.esriETEdge);
            IEnumNetEID     teid2    = network.CreateNetBrowser(esriElementType.esriETJunction);

            netEIDs.Reset();
            int        count  = netEIDs.Count;
            int        num2   = teid2.Count;
            IEIDHelper helper = new EIDHelperClass
            {
                GeometricNetwork       = NetworkAnalyst.m_pAnalystGN,
                OutputSpatialReference = pMap.SpatialReference,
                ReturnGeometries       = true,
                ReturnFeatures         = true
            };
            IEnumEIDInfo info = helper.CreateEnumEIDInfo(teid2);
            int          num3 = info.Count;

            teid2.Reset();
            info.Reset();
            IPointCollection points = new MultipointClass();
            object           before = Missing.Value;

            for (num4 = 0; num4 < num2; num4++)
            {
                IPoint inPoint = info.Next().Geometry as IPoint;
                points.AddPoint(inPoint, ref before, ref before);
            }
            info = null;
            info = helper.CreateEnumEIDInfo(netEIDs);
            num3 = info.Count;
            netEIDs.Reset();
            info.Reset();
            IList list  = new ArrayList();
            ILine line  = new LineClass();
            IList list2 = new ArrayList();
            int   num5  = 0;

            for (num4 = 0; num4 < count; num4++)
            {
                int edgeEID = netEIDs.Next();
                this.m_eFlowDirection.Add(network2.GetFlowDirection(edgeEID));
                IEIDInfo         info2         = info.Next();
                IGeometry        geometry      = info2.Geometry;
                IEdgeFeature     feature       = info2.Feature as IEdgeFeature;
                IPointCollection points2       = geometry as IPointCollection;
                int                 pointCount = points2.PointCount;
                IPoint              other      = new PointClass();
                IPoint[]            pointArray = new IPoint[pointCount];
                IRelationalOperator @operator  = points as IRelationalOperator;
                IPointCollection    points3    = new MultipointClass();
                int                 num8       = 0;
                for (int i = 0; i < pointCount; i++)
                {
                    other = points2.get_Point(i);
                    if (@operator.Contains(other))
                    {
                        IPoint point3 = points2.get_Point(i);
                        points3.AddPoint(point3, ref before, ref before);
                        pointArray[i] = point3;
                    }
                    else
                    {
                        pointArray[i] = null;
                    }
                }
                IPoint[] pointArray2 = new IPoint[pointCount];
                num8 = points3.PointCount;
                int index = -1;
                if (num5 < (points3.PointCount - 1))
                {
                    for (int j = 0; j < pointCount; j++)
                    {
                        if (pointArray[j] != null)
                        {
                            index++;
                        }
                        if (index == num5)
                        {
                            index = j;
                            break;
                        }
                    }
                    IPoint point4 = new PointClass();
                    pointArray2[index]     = pointArray[index];
                    pointArray2[index + 1] = points2.get_Point(index + 1);
                    point4.X = (pointArray2[index].X + pointArray2[index + 1].X) / 2.0;
                    point4.Y = (pointArray2[index].Y + pointArray2[index + 1].Y) / 2.0;
                    this.m_pPointcol.AddPoint(point4, ref before, ref before);
                    line.FromPoint = pointArray2[index];
                    line.ToPoint   = pointArray2[index + 1];
                    this.m_angle.Add(line.Angle);
                    num5++;
                    if (num5 == (num8 - 1))
                    {
                        num5 = 0;
                    }
                }
            }
            this.ShowFlow(pMap as IActiveView);
        }
Exemple #10
0
        //上朔追踪查找管线涉及的地块
        public static void UpStreamFindParcels(MainFrm pMainFrm, IEnumNetEID pEnumResultEdges, IGeometricNetwork pGeoNetwork)
        {
            try
            {
                AxMapControl axMap = pMainFrm.getMapControl();
                IFeatureLayer pFeatLayerSewerLines = FindFeatLayer("Sewer Lines", pMainFrm);
                IFeatureLayer pFeatLayerParcels = FindFeatLayer("Parcels", pMainFrm);
                //从所选择的Sewer线特征中创建几何包
               
                IGeometryCollection pGeomBag = new GeometryBagClass();
                object missing = Type.Missing;
                int lEID;
                int iUserClassID;
                int iUserID;
                int iUserSubID;
                INetElements pNetElements = pGeoNetwork.Network as INetElements;
                pEnumResultEdges.Reset();
                IFeature pFeature;

                for (int j = 0; j <= pEnumResultEdges.Count - 1; j++)
                {
                    lEID = pEnumResultEdges.Next();
                    pNetElements.QueryIDs(lEID, esriElementType.esriETEdge, out iUserClassID, out iUserID, out iUserSubID);
                    pFeature = pFeatLayerSewerLines.FeatureClass.GetFeature(iUserID);
                    pGeomBag.AddGeometry(pFeature.Shape, ref missing, ref missing);
                    // MessageBox.Show(iUserClassID.ToString()+","+iUserID.ToString()+","+iUserSubID.ToString());
                }                                
                                //进行空间拓扑叠加操作以用于查找地块信息
                ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                pSpatialFilter.Geometry = pGeomBag as IGeometry ;
                pSpatialFilter.GeometryField = "Shape";
                pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;
                                
                
                //获得交叉到的地块信息
                 IFeatureCursor pFeatCursor=pFeatLayerParcels.FeatureClass.Search(pSpatialFilter, false);
                //增加被选择的地块数据到地图的图形图层数据中
                ICompositeGraphicsLayer pComGraphicLayer = new CompositeGraphicsLayerClass();
                ILayer pLayer = pComGraphicLayer as ILayer ;
                pLayer.Name = "受影响的地块";
                IGraphicsContainer pGraphicContainer = pComGraphicLayer as IGraphicsContainer;
                //增加所选择的地块到图形容器中
                ISimpleFillSymbol pSymFill=new SimpleFillSymbolClass();
                IFillSymbol pFillSymbol=pSymFill as IFillSymbol;
                IRgbColor pRgbColor=new RgbColorClass();
                pRgbColor.Red=0;
                pRgbColor.Green=200;
                pRgbColor.Blue=100;
                pFillSymbol.Color=pRgbColor as IColor;
                ICartographicLineSymbol pCartoLine=new CartographicLineSymbolClass();
                IRgbColor pRgbColor2=new RgbColorClass();
                pRgbColor2.Red=100;
                pRgbColor2.Green=200;
                pRgbColor2.Blue=100;
                pCartoLine.Width=2;
                pCartoLine.Color =pRgbColor2 as IColor;
                pFillSymbol.Outline=pCartoLine;
                //创建存放所有地块特征的数组
                IArray pFeatArray = new ArrayClass();
                pFeature=pFeatCursor.NextFeature();
                while (pFeature != null)
                {
                    IElement pPolyElement = new PolygonElementClass();
                    IFillShapeElement pFillShapeElement = pPolyElement as IFillShapeElement;
                    pPolyElement.Geometry = pFeature.Shape;
                    pFillShapeElement.Symbol = pFillSymbol;
                    pGraphicContainer.AddElement(pPolyElement, 0);
                    pFeatArray.Add(pFeature);
                    pFeature = pFeatCursor.NextFeature();
                }
                axMap.AddLayer(pGraphicContainer as ILayer);
                axMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null,null);
                frmUpstreamCreateOwnerList frmUpstreamCreateOwnerList1 = new frmUpstreamCreateOwnerList(pMainFrm,pFeatLayerParcels, pFeatArray);
                frmUpstreamCreateOwnerList1.Show();
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }

        }