//public static FiberDeviceConnectionHelper Instance(HookHelperExt hookHelper, ESRI.ArcGIS.Editor.IEditor editor) //{ // if(_instance != null) // { // return _instance; // } // else // { // _instance = new FiberDeviceConnectionHelper(hookHelper, editor); // return _instance; // } //} /// <summary> /// Returns cables which have an endpoint coincident with the device point /// </summary> /// <param name="deviceWrapper">Device to check</param> /// <returns>List of ConnectableCableWrapper</returns> public List <ConnectableCableWrapper> GetCoincidentCables(DeviceWrapper deviceWrapper) { List <ConnectableCableWrapper> result = new List <ConnectableCableWrapper>(); if (null == deviceWrapper) { throw new ArgumentNullException("deviceWrapper"); } ESRI.ArcGIS.Geometry.IPoint devicePoint = deviceWrapper.Feature.Shape as ESRI.ArcGIS.Geometry.IPoint; ESRI.ArcGIS.Carto.IFeatureLayer cableLayer = _hookHelper.FindFeatureLayer(ConfigUtil.FiberCableFtClassName); ESRI.ArcGIS.Geodatabase.IFeatureClass cableFtClass = cableLayer.FeatureClass; int displayIdx = cableFtClass.FindField(cableLayer.DisplayField); double buffer = _hookHelper.ConvertPixelsToMapUnits(1); List <ESRI.ArcGIS.Geodatabase.IFeature> coincidentCables = GdbUtils.GetLinearsWithCoincidentEndpoints(devicePoint, cableFtClass, buffer); for (int i = 0; i < coincidentCables.Count; i++) { ESRI.ArcGIS.Geodatabase.IFeature ft = coincidentCables[i]; ESRI.ArcGIS.Geometry.IPolyline line = ft.Shape as ESRI.ArcGIS.Geometry.IPolyline; ESRI.ArcGIS.Geometry.IRelationalOperator lineToPoint = line.ToPoint as ESRI.ArcGIS.Geometry.IRelationalOperator; bool isFromEnd = true; if (lineToPoint.Equals(devicePoint)) { isFromEnd = false; } result.Add(new ConnectableCableWrapper(ft, isFromEnd, displayIdx)); } return(result); }
public void SelectTracedDevices() { // ----------------------------------------------- // Following section of code causes cable, splice // and device features to be selected on the map // using the IFeatureSelection & ISelectionSet // interfaces // ----------------------------------------------- // Remove any previous trace results. _hookHelper.FocusMap.ClearSelection(); Dictionary <string, List <int> > deviceOidLists = new Dictionary <string, List <int> >(); // First get set of OIDs that were traced. foreach (IRow traceItem in this._traceResults) { ESRI.ArcGIS.Geodatabase.IDataset dataset = traceItem.Table as ESRI.ArcGIS.Geodatabase.IDataset; string className = GdbUtils.ParseTableName(dataset); if (ConfigUtil.IsDeviceClassName(className)) { List <int> deviceOids = null; if (deviceOidLists.ContainsKey(className)) { deviceOids = deviceOidLists[className]; } else { deviceOids = new List <int>(); deviceOidLists[className] = deviceOids; } deviceOids.Add(traceItem.OID); } } // Do the actual selections foreach (KeyValuePair <string, List <int> > deviceOidPair in deviceOidLists) { ESRI.ArcGIS.Carto.IFeatureSelection deviceFtSelection = _hookHelper.FindFeatureLayer(deviceOidPair.Key) as ESRI.ArcGIS.Carto.IFeatureSelection; if (null != deviceFtSelection) { ESRI.ArcGIS.Geodatabase.ISelectionSet deviceSelectionSet = deviceFtSelection.SelectionSet; List <int> deviceOidList = deviceOidPair.Value; if (null != deviceSelectionSet && 0 < deviceOidList.Count) { int[] oidList = deviceOidList.ToArray(); deviceSelectionSet.AddList(deviceOidList.Count, ref oidList[0]); } } else { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", deviceOidPair.Key + " not found.", "Layer removed from TOC?"); } } }
/// <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); }