本文整理汇总了C#中ESRI.DeleteIndex方法的典型用法代码示例。如果您正苦于以下问题:C# ESRI.DeleteIndex方法的具体用法?C# ESRI.DeleteIndex怎么用?C# ESRI.DeleteIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ESRI
的用法示例。
在下文中一共展示了ESRI.DeleteIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildShapefileSpatialIndex
public System.Boolean BuildShapefileSpatialIndex(ESRI.ArcGIS.Geodatabase.IFeatureClass ShapefileFeatureClass)
{
ESRI.ArcGIS.Geodatabase.IFields indexShapefileFields = null;
ESRI.ArcGIS.Geodatabase.IFieldsEdit indexShapefileFieldsEdit = null;
ESRI.ArcGIS.Geodatabase.IField shapefileGeometryField = null;
ESRI.ArcGIS.Geodatabase.IIndex shapefileSpatialIndex = null;
ESRI.ArcGIS.Geodatabase.IIndexEdit shapefileSpatialIndexEdit = null;
ESRI.ArcGIS.Geodatabase.IEnumIndex shapefileExistingIndices = null;
ESRI.ArcGIS.Geodatabase.IIndex shapefileDeleteIndex = null;
try
{
// Make sure the Feature Class Object is not a NULL Pointer before moving on.
if (ShapefileFeatureClass == null)
{
// Let the User know that a valid Shapefile Name MUST be passed before the index can
// be created.
if (ErrorMessage != null)
{
ErrorMessage("A Valid Shapefile Object must be passed to this method! The MaintTools.FeatureClassUtilities.BuildShapefileSpatialIndex() Method failed!");
}
// Return FALSE to the calling method to indicate that this method failed.
return false;
}
// If the Process Message Event has been instantiated, let the user know what is happening.
if (ProcessMessage != null)
{
ProcessMessage(" - Opening the Shapefile Geometry Field and preparing it to be indexed...");
}
// Create a Fields Object and open an Editing Object on it so that new fields can be added.
indexShapefileFields = new ESRI.ArcGIS.Geodatabase.FieldsClass();
indexShapefileFieldsEdit = (ESRI.ArcGIS.Geodatabase.IFieldsEdit)indexShapefileFields;
// Find the Geometry Field in the Field in the Shapefile Fields Object and add it to the
// Fields Collection.
indexShapefileFieldsEdit.FieldCount_2 = 1;
int l = ShapefileFeatureClass.FindField(ShapefileFeatureClass.ShapeFieldName);
if (l < 0)
{
// Let the user know that the Geometry Field of the Shapefile Feature Class could not
// be found.
if (ErrorMessage != null)
{
ErrorMessage("The Shapefile Geometry Field could not be found! The MaintTools.FeatureClassUtilities.BuildShapefileSpatialIndex() Method failed!");
}
// Return FALSE to the calling method to indicate that this process failed.
return false;
}
shapefileGeometryField = ShapefileFeatureClass.Fields.get_Field(l);
indexShapefileFieldsEdit.set_Field(0, shapefileGeometryField);
// If the Process Message Event has been instantiated, let the user know what is happening.
if (ProcessMessage != null)
{
ProcessMessage(" - Creating the Index and applying it to the Shapefile Feature Class Geometry Field...");
}
// Create a new index and prepare it to be added to the table.
shapefileSpatialIndex = new ESRI.ArcGIS.Geodatabase.IndexClass();
shapefileSpatialIndexEdit = (ESRI.ArcGIS.Geodatabase.IIndexEdit)shapefileSpatialIndex;
shapefileSpatialIndexEdit.Fields_2 = indexShapefileFields;
shapefileSpatialIndexEdit.Name_2 = "Idx_1";
// Remove all Indices from the table.
shapefileExistingIndices = ShapefileFeatureClass.Indexes.FindIndexesByFieldName(ShapefileFeatureClass.ShapeFieldName);
shapefileDeleteIndex = shapefileExistingIndices.Next();
while (shapefileDeleteIndex != null)
{
ShapefileFeatureClass.DeleteIndex(shapefileDeleteIndex);
shapefileDeleteIndex = shapefileExistingIndices.Next();
}
// Add the index to the Shapefile.
ShapefileFeatureClass.AddIndex(shapefileSpatialIndex);
// If the process made it to here it was successful so return TRUE to the calling method.
return true;
}
catch (System.Exception caught)
{
// Determine the Line Number from which the exception was thrown.
System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(caught, true);
System.Diagnostics.StackFrame stackFrame = stackTrace.GetFrame(stackTrace.FrameCount - 1);
int lineNumber = stackFrame.GetFileLineNumber();
// Let the user know that this method failed.
if (ErrorMessage != null)
{
ErrorMessage("The MaintTools.FeatureClassUtilities.BuildShapefileSpatialIndex() Method failed with error message - " + caught.Message + " (Line: " + lineNumber.ToString() + ")!");
}
//.........这里部分代码省略.........