Esempio n. 1
0
        //public static FiberSpliceConnectionHelper Instance(object hook, ESRI.ArcGIS.Editor.IEditor editor)
        //{
        //    if (_instance != null)
        //    {
        //        return _instance;
        //    }
        //    else
        //    {
        //        _instance = new FiberSpliceConnectionHelper(hook, editor);
        //        return _instance;
        //    }
        //}


        /// <summary>
        /// Gets a list of cable features that are connected to the splice closure in the geometric network
        /// </summary>
        /// <param name="spliceClosure">Splice to check</param>
        /// <returns>List of IFeature</returns>
        public List <ESRI.ArcGIS.Geodatabase.IFeature> GetConnectedCables(SpliceClosureWrapper spliceClosure)
        {
            // At the time of this comment, splicable means they are connected in the
            // geometric network and the splice closure "touches" one of the ends of the cable
            List <ESRI.ArcGIS.Geodatabase.IFeature> result = new List <ESRI.ArcGIS.Geodatabase.IFeature>();

            if (null == spliceClosure)
            {
                throw new ArgumentNullException("spliceClosure");
            }

            ESRI.ArcGIS.Geometry.IRelationalOperator relOp = spliceClosure.Feature.Shape as ESRI.ArcGIS.Geometry.IRelationalOperator;
            if (relOp == null)
            {
                throw new ArgumentNullException("spliceClosure");
            }

            ESRI.ArcGIS.Geodatabase.ISimpleJunctionFeature junction = spliceClosure.Feature as ESRI.ArcGIS.Geodatabase.ISimpleJunctionFeature;
            if (null != junction)
            {
                for (int i = 0; i < junction.EdgeFeatureCount; i++)
                {
                    ESRI.ArcGIS.Geodatabase.IFeature connectedEdge = junction.get_EdgeFeature(i) as ESRI.ArcGIS.Geodatabase.IFeature;
                    ESRI.ArcGIS.Geodatabase.IDataset dataset       = connectedEdge.Class as ESRI.ArcGIS.Geodatabase.IDataset;
                    string ftClassName = GdbUtils.ParseTableName(dataset);

                    if (0 == string.Compare(ftClassName, ConfigUtil.FiberCableFtClassName, true))
                    {
                        // Test feature edge is coincident with splice closure. Cables are
                        // complex features so splice might lie half way along some cables
                        // but will not be providing any splice connectivity to them.
                        if (relOp.Touches(connectedEdge.Shape)) // only true if point at either end of a line
                        {
                            result.Add(connectedEdge);
                        }
                    }
                }
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets all cables that are considered splicable to another cable at a given splice closure.
        /// </summary>
        /// <param name="cable">Cable to splice with</param>
        /// <param name="spliceClosure">Splice Closure to splice at</param>
        /// <returns>List of SpliceableCableWrapper</returns>
        public List <SpliceableCableWrapper> GetSpliceableCables(FiberCableWrapper cable, SpliceClosureWrapper spliceClosure)
        {
            // At the time of this comment, splicable means they are connected in the geometric network
            List <SpliceableCableWrapper> result = new List <SpliceableCableWrapper>();

            if (null == cable)
            {
                throw new ArgumentNullException("cable");
            }
            if (null == spliceClosure)
            {
                throw new ArgumentNullException("spliceClosure");
            }

            int searchOid = cable.Feature.OID;

            ESRI.ArcGIS.Geodatabase.IEdgeFeature cableFt = cable.Feature as ESRI.ArcGIS.Geodatabase.IEdgeFeature;
            ESRI.ArcGIS.Carto.IFeatureLayer      ftLayer = _hookHelper.FindFeatureLayer(ConfigUtil.FiberCableFtClassName);
            int displayIdx = ftLayer.FeatureClass.FindField(ftLayer.DisplayField);

            if (null != cableFt)
            {
                // We assume it is simple. Complex junctions are not supported for splicing cables
                ESRI.ArcGIS.Geodatabase.ISimpleJunctionFeature junction = spliceClosure.Feature as ESRI.ArcGIS.Geodatabase.ISimpleJunctionFeature;

                if (null != junction)
                {
                    bool isAFromEnd = false; // would be in the case that junction.EID == cableFt.ToJunctionEID
                    if (junction.EID == cableFt.FromJunctionEID)
                    {
                        isAFromEnd = true;
                    }
                    else if (junction.EID != cableFt.ToJunctionEID)
                    {
                        // It isn't the from or the two? It shouldn't have been passed in as if it was coincident with the cable
                        return(result);
//                        throw new InvalidOperationException("Given splice closure is not the junction for the given cable.");
                    }

                    int edgeCount = junction.EdgeFeatureCount;
                    for (int i = 0; i < edgeCount; i++)
                    {
                        ESRI.ArcGIS.Geodatabase.IEdgeFeature connectedEdge = junction.get_EdgeFeature(i);
                        ESRI.ArcGIS.Geodatabase.IFeature     feature       = (ESRI.ArcGIS.Geodatabase.IFeature)connectedEdge;
                        ESRI.ArcGIS.Geodatabase.IDataset     dataset       = feature.Class as ESRI.ArcGIS.Geodatabase.IDataset;
                        string featureClassName = GdbUtils.ParseTableName(dataset);

                        if (0 == string.Compare(featureClassName, ConfigUtil.FiberCableFtClassName) &&
                            feature.OID != searchOid)
                        {
                            if (junction.EID == connectedEdge.FromJunctionEID)
                            {
                                result.Add(new SpliceableCableWrapper(feature, true, isAFromEnd, displayIdx));
                            }
                            else if (junction.EID == connectedEdge.ToJunctionEID)
                            {
                                result.Add(new SpliceableCableWrapper(feature, false, isAFromEnd, displayIdx));
                            }
                        }
                    }
                }
            }

            return(result);
        }