Пример #1
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);
        }
Пример #2
0
        private List <int> _FindDownstreamPipeEnds()
        {
            List <int> endPointOidList = new List <int>();

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

            bool inletInNetwork = false;
            IEnumFeatureClass junctionClasses = _geometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleJunction);
            IFeatureClass     junctionClass   = junctionClasses.Next();

            while (junctionClass != null)
            {
                if (junctionClass == _inletClass)
                {
                    inletInNetwork = true;
                    break;
                }
                else
                {
                    UrbanDelineationExtension.ReleaseComObject(junctionClass);
                }
                junctionClass = junctionClasses.Next();
            }

            if (!inletInNetwork)
            {
                throw new Exception("The selected inlet class is not part of the pipe network.");
            }

            IFeatureCursor cursor = null;

            try
            {
                int  edgeId;
                bool towardJunction;

                cursor = _inletClass.Search(null, false);
                IFeature inlet = cursor.NextFeature();
                while (inlet != null)
                {
                    try
                    {
                        ISimpleJunctionFeature junction = inlet as ISimpleJunctionFeature;

                        //Check that inlet is a valid part of network before testing if it is at downstream end
                        if (!inlet.Shape.IsEmpty && junction.EID != 0)
                        {
                            bool isDownstream = junction.EdgeFeatureCount > 0;
                            for (int i = 0; i < junction.EdgeFeatureCount; i++)
                            {
                                netTopology.GetAdjacentEdge(junction.EID, i, out edgeId, out towardJunction);
                                if (!towardJunction)
                                {
                                    isDownstream = false;
                                    break;
                                }
                            }

                            if (isDownstream)
                            {
                                endPointOidList.Add(inlet.OID);
                            }
                        }
                    }
                    finally
                    {
                        UrbanDelineationExtension.ReleaseComObject(inlet);
                    }
                    inlet = cursor.NextFeature();
                }
            }
            finally
            {
                UrbanDelineationExtension.ReleaseComObject(cursor);
            }

            return(endPointOidList);
        }