djain-esristaff

get non intersecting features

Discussion created by djain-esristaff on Sep 28, 2011
Latest reply on Sep 29, 2011 by djain-esristaff
get code from attachment or

-----------------------------
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.ArcMapUI;
using ESRI.ArcGIS.Carto;
using System.Windows.Forms;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Editor;
using ESRI.ArcGIS.Geoprocessing;
using ESRI.ArcGIS.esriSystem;
using System.Collections.Generic;
using System.IO;



public void ButtonClick()
        {

            IMxDocument pmxdoc = (IMxDocument)m_application.Document;
            IMap pmap = pmxdoc.FocusMap;

            ILayer pLinelayer = null;
            ILayer pPolylayer = null;

            IFeatureCursor getFeatCur = getSelectedFeatures(pLinelayer);
            getNonIntersectingFeature(pLinelayer, pPolylayer, getFeatCur);
       
        }

        public IFeatureCursor getSelectedFeatures(ILayer plinelayer)
        {
            IFeatureLayer pFeatLayer = (IFeatureLayer)plinelayer;
            IFeatureClass pLineFC = pFeatLayer.FeatureClass;

            IFeatureSelection pFeatSel = (IFeatureSelection)plinelayer;
            ISelectionSet pSelSet = pFeatSel.SelectionSet;

            IFeatureCursor pFeatCur = null;
            pSelSet.Search(null, true, out pFeatCur);

            return pFeatCur;
       
               
        }

        public void getNonIntersectingFeature(ILayer pLineLayer, ILayer pPolyLayer, IFeatureCursor pFeatCur)
        {
            IFeature pfeature = null;
            pfeature = pFeatCur.NextFeature();

            IFeatureLayer pFeatLayer = (IFeatureLayer)pPolyLayer;
            IFeatureClass pPolyFeatClass = pFeatLayer.FeatureClass;

            ISpatialFilter pSpatialFil = new SpatialFilterClass();
            pSpatialFil.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

            while (pfeature != null)

            {
                pSpatialFil.set_GeometryEx((IGeometry)pfeature, true);
                IFeatureCursor pFCur = pPolyFeatClass.Search(pSpatialFil, true);

                if (pFCur == null)
                {
                    string oid = pfeature.OID.ToString();
               
                }
                pfeature = pFeatCur.NextFeature();
            }
       
        }

Attachments

Outcomes