Ejemplo n.º 1
0
        /// <summary>
        /// Determines the coincident ends of the given edges and returns the junction's shape as IPoint
        /// </summary>
        /// <param name="featureA">One edge feature</param>
        /// <param name="featureB">Another edge feature</param>
        /// <returns>IPoint</returns>
        public static ESRI.ArcGIS.Geometry.IPoint GetJunctionPoint(ESRI.ArcGIS.Geodatabase.IEdgeFeature featureA, ESRI.ArcGIS.Geodatabase.IEdgeFeature featureB)
        {
            #region Validation

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

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

            #endregion

            int aFromEid = featureA.FromJunctionEID;
            int aToEid   = featureA.ToJunctionEID;
            int bFromEid = featureB.FromJunctionEID;
            int bToEid   = featureB.ToJunctionEID;

            ESRI.ArcGIS.Geodatabase.IJunctionFeature junctionFt = null;
            if (aFromEid == bFromEid || aFromEid == bToEid)
            {
                junctionFt = featureA.FromJunctionFeature;
            }
            else if (aToEid == bFromEid || aToEid == bToEid)
            {
                junctionFt = featureA.ToJunctionFeature;
            }

            if (null == junctionFt)
            {
                throw new Exception("Unable to find junction feature for provided edges.");
            }

            ESRI.ArcGIS.Geometry.IGeometry geometry = ((ESRI.ArcGIS.Geodatabase.IFeature)junctionFt).ShapeCopy;
            if (geometry.GeometryType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
            {
                throw new Exception("Junction feature's geometry is not a point.");
            }

            return(geometry as ESRI.ArcGIS.Geometry.IPoint);
        }
Ejemplo 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);
        }