Ejemplo n.º 1
0
        /// <summary>
        /// Gets the features from the selection that are from a given ft class
        /// </summary>
        /// <param name="ftClassName">ft class name</param>
        /// <returns>List of IFeature</returns>
        public List <ESRI.ArcGIS.Geodatabase.IFeature> GetSelectedFeatures(IFeatureLayer layer)
        {
            List <ESRI.ArcGIS.Geodatabase.IFeature> result = new List <ESRI.ArcGIS.Geodatabase.IFeature>();

            if (layer == null)
            {
                return(result);
            }

            ESRI.ArcGIS.Carto.IFeatureSelection ftSelection = layer as ESRI.ArcGIS.Carto.IFeatureSelection;

            if (null != ftSelection &&
                null != ftSelection.SelectionSet)
            {
                ESRI.ArcGIS.Geodatabase.ISelectionSet selectionSet = ftSelection.SelectionSet;
                ESRI.ArcGIS.Geodatabase.ICursor       cursor       = null;

                try
                {
                    selectionSet.Search(null, false, out cursor);
                    ESRI.ArcGIS.Geodatabase.IRow ft = cursor.NextRow();
                    while (null != ft)
                    {
                        result.Add((ESRI.ArcGIS.Geodatabase.IFeature)ft);
                        ft = cursor.NextRow();
                    }
                }
                finally
                {
                    ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(cursor);
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public void FeatureSelectionOnActiveView(string whereClause, IActiveView pActiveView, IFeatureLayer pFLayer)
        {
            try
            {
                //pActiveView.GraphicsContainer.DeleteAllElements();
                ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = pFLayer as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast

                // Set up the query
                ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
                queryFilter.WhereClause = whereClause;

                // Invalidate only the selection cache. Flag the original selection
                pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                // Perform the selection
                featureSelection.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, false);

                // Flag the new selection
                //pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);
                pActiveView.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception:" + ex.Message);
                return;
            }
        }
Ejemplo n.º 3
0
        private void FeatureSelectionOnActiveView(string whereClause, IActiveView pActiveView, IFeatureLayer pFLayer)
        {
            try
            {
                ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = pFLayer as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast

                // Set up the query
                ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
                queryFilter.WhereClause = whereClause;

                // Invalidate only the selection cache. Flag the original selection
                pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                // Perform the selection
                featureSelection.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, false);

                // Flag the new selection
                pActiveView.Refresh();
                //pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Ejemplo n.º 4
0
        private void dgvAttTable_MouseUp(object sender, MouseEventArgs e)
        {
            try
            {
                int           intSelCounts = dgvAttTable.SelectedRows.Count;
                IFeatureLayer pFLayer      = m_pLayer as IFeatureLayer;
                if (intSelCounts == 0)
                {
                    m_pSnippet.ClearSelectedMapFeatures(m_pActiveView, pFLayer);
                }
                else//Brushing on Map
                {
                    for (int i = 0; i < intSelCounts; i++)
                    {
                        string value1 = dgvAttTable.SelectedRows[i].Cells[0].Value.ToString();


                        string whereClause = "FID =" + value1;

                        if (m_pActiveView == null || pFLayer == null || whereClause == null || value1 == "")
                        {
                            return;
                        }
                        ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = pFLayer as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast

                        // Set up the query
                        ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
                        queryFilter.WhereClause = whereClause;

                        // Invalidate only the selection cache. Flag the original selection
                        m_pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                        // Perform the selection
                        if (i == 0)
                        {
                            featureSelection.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, false);
                        }
                        else
                        {
                            featureSelection.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultAdd, false);
                        }
                    }
                    // Flag the new selection
                    m_pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                    //Brushing to other graphs
                    m_pBL.BrushingToOthers(pFLayer, this.Handle);
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
        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?");
                }
            }
        }
Ejemplo n.º 6
0
        private void BrushingOnMapControl(ISpatialFilter pSpatialFilter, IActiveView pActiveView, IFeatureLayer pFLayer)
        {
            ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = pFLayer as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast

            // Invalidate only the selection cache. Flag the original selection
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

            // Perform the selection
            featureSelection.SelectFeatures(pSpatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false);

            // Flag the new selection
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
Ejemplo n.º 7
0
        public void ClearSelectedMapFeatures(ESRI.ArcGIS.Carto.IActiveView activeView, ESRI.ArcGIS.Carto.IFeatureLayer featureLayer) //dhncho 01.10
        {
            if (activeView == null || featureLayer == null)
            {
                return;
            }
            ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = featureLayer as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast

            // Invalidate only the selection cache. Flag the original selection
            activeView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

            // Clear the selection
            featureSelection.Clear();

            // Flag the new selection
            activeView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
Ejemplo n.º 8
0
        private void frmDrawDenPlot_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (pGeofeatureLayer != null && pFLayer != null)
            {
                //Remove Layer
                pActiveView.FocusMap.DeleteLayer(pGeofeatureLayer);

                //Clear Selection
                ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = pFLayer as ESRI.ArcGIS.Carto.IFeatureSelection;
                featureSelection.Clear();

                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            }
            else
            {
                return;
            }
        }
        public void SelectTracedSpliceClosures()
        {
            // -----------------------------------------------
            // Following section of code causes cable, splice
            // and device features to be selected on the map
            // using the IFeatureSelection & ISelectionSet
            // interfaces
            // -----------------------------------------------

            List <int> spliceOidList = new 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 (0 == string.Compare(className, ConfigUtil.SpliceClosureFtClassName, true))
                {
                    if (traceItem.HasOID)
                    {
                        spliceOidList.Add(traceItem.OID);
                    }
                }
            }

            // Do the actual selection
            ESRI.ArcGIS.Carto.IFeatureSelection scFtSelection = _hookHelper.FindFeatureLayer(ConfigUtil.SpliceClosureFtClassName) as ESRI.ArcGIS.Carto.IFeatureSelection;
            if (scFtSelection == null)
            {
                // No selection to be made as layer not in TOC
                _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", ConfigUtil.SpliceClosureFtClassName + " not found.", "Layer removed from TOC?");
            }
            else
            {
                ESRI.ArcGIS.Geodatabase.ISelectionSet scSelectionSet = scFtSelection.SelectionSet;
                if (null != scSelectionSet &&
                    0 < spliceOidList.Count)
                {
                    int[] oidList = spliceOidList.ToArray();
                    scSelectionSet.AddList(spliceOidList.Count, ref oidList[0]);
                }
            }
        }
Ejemplo n.º 10
0
        internal void addFeatureClassToMapAsLayer(ref IFeatureClass fc, string LayerName, string whereClause)
        {
            try
            {
                // define a new layer for the asset catalog
                IFeatureLayer player = new FeatureLayer();
                player.FeatureClass = fc;
                player.Name         = LayerName;

                // TODO: Specifically set the spatial reference

                // Set up the query
                ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
                queryFilter.WhereClause = whereClause;

                // create a feature selection object
                ESRI.ArcGIS.Carto.IFeatureSelection featureSelection
                    = player as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast

                // Perform the selection
                featureSelection.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, false);

                //Create a GxLayer to stylize the layer.
                ESRI.ArcGIS.Catalog.IGxLayer gxLayerCls = new ESRI.ArcGIS.Catalog.GxLayer();
                ESRI.ArcGIS.Catalog.IGxFile  gxFile     = (ESRI.ArcGIS.Catalog.IGxFile)gxLayerCls;
                //Explicit Cast.

                // create an assembly file object to determine where on the system this is running
                log.Debug("Attempting to locate the executing extension assembly.");
                Uri assemblyUri = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
                System.IO.FileInfo assemblyFileInfo
                    = new System.IO.FileInfo(Path.GetDirectoryName(assemblyUri.LocalPath));
                log.Debug("Executing from: " + assemblyFileInfo.FullName);

                //Set the path for where the layer file is located on disk.
                gxFile.Path = assemblyFileInfo.FullName + "\\GME_Catalog_Style.lyr";
                log.Debug("lyr Path: " + gxFile.Path);

                // validate the symbology layers exist
                if (!(gxLayerCls.Layer == null))
                {
                    // create a geo feature layer for the master symbology
                    IGeoFeatureLayer symbologyGeoFeatureLayer = gxLayerCls.Layer as IGeoFeatureLayer;

                    // create a geo feature layer for the new features
                    IGeoFeatureLayer pGeoFeatureLayer = player as IGeoFeatureLayer;

                    // apply the renderer from the template to the new feature layer
                    pGeoFeatureLayer.Renderer = symbologyGeoFeatureLayer.Renderer;
                }

                // add the layer to the map
                m_map.AddLayer(player);

                // Flag the new selection
                ArcMap.Document.ActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                // manually trigger the selection has changed event to determine if the buttons should re-enable
                ArcMap_SelectionChanged();
            }
            catch (System.Exception ex)
            {
                // an error occured
                log.Error(ex);
                System.Windows.Forms.MessageBox.Show("Unable to add feature class to the map.");
            }
        }
Ejemplo n.º 11
0
 private void FeatureSelectionOnActiveView(IActiveView pActiveView, IFeatureLayer pFLayer, ISelectionSet pSelSet)
 {
     ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = pFLayer as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast
     featureSelection.SelectionSet = pSelSet;
     pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
 }
Ejemplo n.º 12
0
        private void button_Import_Click(object sender, System.EventArgs e)
        {
            // point to the first selected feature:
            ESRI.ArcGIS.Animation.IAGImportPathOptions AGImportPathOptionsCls = new ESRI.ArcGIS.Animation.AGImportPathOptionsClass();

            // Set properties for AGImportPathOptions
            AGImportPathOptionsCls.BasicMap        = (ESRI.ArcGIS.Carto.IBasicMap)globe;              // Explicit Cast
            AGImportPathOptionsCls.AnimationTracks = (ESRI.ArcGIS.Animation.IAGAnimationTracks)globe; // Explicit Cast
            AGImportPathOptionsCls.AnimationType   = new ESRI.ArcGIS.GlobeCore.AnimationTypeGlobeCameraClass();
            AGImportPathOptionsCls.AnimatedObject  = globe.GlobeDisplay.ActiveViewer.Camera;

            if (this.radioButton_flyby.Checked == true)
            {
                AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathObsAndTarget;
                AGImportPathOptionsCls.PutAngleCalculationMethods(esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative);
                AGImportPathOptionsCls.PutAngleCalculationValues(0.0, 0.0, 0.0);
            }
            else if (this.radioButton_currentTarget.Checked == true)
            {
                AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathObserver;
            }
            else if (this.radioButton_currentObserver.Checked == true)
            {
                AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathTarget;
            }

            double pAzimuth, pInclination, pRollVal;

            AGImportPathOptionsCls.GetAngleCalculationValues(out pAzimuth, out pInclination, out pRollVal);

            AGImportPathOptionsCls.LookaheadFactor   = this.trackBarSimplificationFactor.Value / 100;
            AGImportPathOptionsCls.TrackName         = this.textBox_TrackName.Text;
            AGImportPathOptionsCls.OverwriteExisting = Convert.ToBoolean(this.checkBox_Overwrite.CheckState);
            AGImportPathOptionsCls.VerticalOffset    = Convert.ToDouble(this.textBox_VertOffset.Text);
            AGImportPathOptionsCls.ReversePath       = Convert.ToBoolean(this.checkBox_ReverseOrder.CheckState);

            // get the layer selected in the combo box
            if (this.comboBoxLayers.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a layer before you proceed");
            }
            else
            {
                //set the layer based on the item selected in the combo box
                ESRI.ArcGIS.Carto.ILayer layer = (ESRI.ArcGIS.Carto.ILayer)layerArray.get_Element(this.comboBoxLayers.SelectedIndex);                  // Explicit Cast

                // Get the line feature selected in the layer
                ESRI.ArcGIS.Carto.IFeatureLayer       featureLayer     = (ESRI.ArcGIS.Carto.IFeatureLayer)layer;       // Explicit Cast
                ESRI.ArcGIS.Carto.IFeatureSelection   featureSelection = (ESRI.ArcGIS.Carto.IFeatureSelection)layer;   // Explicit Cast
                ESRI.ArcGIS.Geodatabase.ISelectionSet selectionSet     = featureSelection.SelectionSet;
                ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass     = featureLayer.FeatureClass;
                string shapeField = featureClass.ShapeFieldName;
                ESRI.ArcGIS.Geodatabase.ISpatialFilter spatialFilterCls = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass();

                IScene scene = globe.GlobeDisplay.Scene;

                ESRI.ArcGIS.Geometry.ISpatialReference spatialReference = scene.SpatialReference;
                spatialFilterCls.GeometryField = shapeField;
                spatialFilterCls.set_OutputSpatialReference(shapeField, spatialReference);
                ESRI.ArcGIS.Geodatabase.ICursor cursor;
                selectionSet.Search(spatialFilterCls, true, out cursor);
                ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = (ESRI.ArcGIS.Geodatabase.IFeatureCursor)cursor;                 // Explicit Cast

                ESRI.ArcGIS.Geodatabase.IFeature lineFeature;
                lineFeature = featureCursor.NextFeature();
                if (lineFeature == null)
                {
                    MessageBox.Show("Please select a feature in the feature layer selected");
                }
                else
                {
                    CreateFlybyFromPathAnimation(globe, lineFeature, AGImportPathOptionsCls);
                }
            }
            this.Close();
        }