I have two feature classes. I'm intersecting both of them. I have to return features which does not intersect with the other.Lets take an example.I have two feature classes: villages and colleges. I'm intersecting both of them.My query is "Select villages where population greater then 500 and not having colleges."So villages "having population greater then" is working finely but then it spatially search for colleges in those villages.what all I need is to select villages which does not have colleges.
public ArrayList Attributespatialquery(String StrTableA, String StrTableB, String Vcode, String GISColumn, String SDE) { string TableA, TableB; ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop); AoInitialize initA = new AoInitialize(); IWorkspaceFactory pworkspaceFactory = null; IWorkspace pworkspace = null; ESRI.ArcGIS.Geodatabase.IFeatureWorkspace pfeatureWorkspace = null; ESRI.ArcGIS.Geodatabase.IFeatureClass TableBfeatureClass = null; ESRI.ArcGIS.Geodatabase.IFeatureClass TableAfeatureClass = null; IFeatureCursor pFeatCusr = null; IFeatureCursor pFeatCusr1 = null; IFeature pFeature = null; IFeature pFeature1 = null; //System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(); //System.Data.DataSet dataset = new System.Data.DataSet(); //// MyConnection objCon = new MyConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DBConnectionGIS"].ToString()); //con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DBConnectionGIS"].ToString(); try { // initialize an ArcGIS Server license if the license is available if (initA.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeStandard) == esriLicenseStatus.esriLicenseAvailable) initA.Initialize(esriLicenseProductCode.esriLicenseProductCodeStandard); // throw an exception if the license is not available else throw new Exception("ESRI ArcGIS Server License is unavailable or has failed"); Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory"); pworkspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType); pworkspace = pworkspaceFactory.OpenFromFile(SDE, 0); pfeatureWorkspace = (IFeatureWorkspace)pworkspace; TableA = "dbo." + StrTableA; // Explict Cast TableAfeatureClass = pfeatureWorkspace.OpenFeatureClass(TableA); TableB = "dbo." + StrTableB; // Explict Cast TableBfeatureClass = pfeatureWorkspace.OpenFeatureClass(TableB); IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.SubFields = "*"; pQueryFilter.WhereClause = GISColumn + " in (" + Vcode + ")"; pFeatCusr = TableAfeatureClass.Search(pQueryFilter, false); while ((pFeature = pFeatCusr.NextFeature()) != null) { ISpatialFilter spatialFilter = new SpatialFilterClass(); spatialFilter.Geometry = pFeature.Shape; spatialFilter.GeometryField = TableAfeatureClass.ShapeFieldName; spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; pFeatCusr1 = TableBfeatureClass.Search(spatialFilter, false); while ((pFeature1 = pFeatCusr1.NextFeature()) != null) if (!arrSpatial.Contains(pFeature1)) { arrSpatial.Add(pFeature1.OID); // WriteLog("values added"); } }
أكثر...
public ArrayList Attributespatialquery(String StrTableA, String StrTableB, String Vcode, String GISColumn, String SDE) { string TableA, TableB; ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop); AoInitialize initA = new AoInitialize(); IWorkspaceFactory pworkspaceFactory = null; IWorkspace pworkspace = null; ESRI.ArcGIS.Geodatabase.IFeatureWorkspace pfeatureWorkspace = null; ESRI.ArcGIS.Geodatabase.IFeatureClass TableBfeatureClass = null; ESRI.ArcGIS.Geodatabase.IFeatureClass TableAfeatureClass = null; IFeatureCursor pFeatCusr = null; IFeatureCursor pFeatCusr1 = null; IFeature pFeature = null; IFeature pFeature1 = null; //System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(); //System.Data.DataSet dataset = new System.Data.DataSet(); //// MyConnection objCon = new MyConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DBConnectionGIS"].ToString()); //con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DBConnectionGIS"].ToString(); try { // initialize an ArcGIS Server license if the license is available if (initA.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeStandard) == esriLicenseStatus.esriLicenseAvailable) initA.Initialize(esriLicenseProductCode.esriLicenseProductCodeStandard); // throw an exception if the license is not available else throw new Exception("ESRI ArcGIS Server License is unavailable or has failed"); Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory"); pworkspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType); pworkspace = pworkspaceFactory.OpenFromFile(SDE, 0); pfeatureWorkspace = (IFeatureWorkspace)pworkspace; TableA = "dbo." + StrTableA; // Explict Cast TableAfeatureClass = pfeatureWorkspace.OpenFeatureClass(TableA); TableB = "dbo." + StrTableB; // Explict Cast TableBfeatureClass = pfeatureWorkspace.OpenFeatureClass(TableB); IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.SubFields = "*"; pQueryFilter.WhereClause = GISColumn + " in (" + Vcode + ")"; pFeatCusr = TableAfeatureClass.Search(pQueryFilter, false); while ((pFeature = pFeatCusr.NextFeature()) != null) { ISpatialFilter spatialFilter = new SpatialFilterClass(); spatialFilter.Geometry = pFeature.Shape; spatialFilter.GeometryField = TableAfeatureClass.ShapeFieldName; spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; pFeatCusr1 = TableBfeatureClass.Search(spatialFilter, false); while ((pFeature1 = pFeatCusr1.NextFeature()) != null) if (!arrSpatial.Contains(pFeature1)) { arrSpatial.Add(pFeature1.OID); // WriteLog("values added"); } }
أكثر...