FRAMES | NO FRAMES |
Deletes features in a repository feature layer.
Availability: Business Analyst Server 9.3.1 SP1.
bool DeleteFeatures ( DeleteFeaturesParameters Parameters );
Parameter | Description |
---|---|
Parameters | Configuration options for the utility. Type DeleteFeaturesParameters. |
Variable of type Boolean whose true value means that at least one feature was deleted.
This method deletes features whose Object ID value is listed in the input OIDs array. Typically, values of Object ID are enumerated in a repository feature layer from zero (for shapefile workspace type) or one (in other cases). When features are removed from a repository feature layer, Object IDs of remaining features can be changed. For example, in the case of shapefile workspace, Object IDs of remaining features are renumbered.
NOTE: The name of the Object ID attribute of features depends on a feature class workspace type used. Typical names for Object ID are "FID", "OID", or "OBJECTID".
The example below creates a store feature layer in the repository by geocoding store address records and removes some feature records from this layer.
NOTE: The signature of the BAServerHelper.DeleteFeatures method is modified against this method—an array of OIDs and a folder item are passed in parameters instead of DeleteFeaturesParameters type.
C# |
// Instantiate the BAServerHelper class to access analysis methods BAServerHelper baServerHelper = new BAServerHelper(); baServerHelper.ActiveDatasetID = "USA_ESRI"; // Optional parameter baServerHelper.IsFullErrorMessage = true; // Default is false RenderingParameters imageOptions; TaskOutputType[] outputOptions; esriFolderItem outputLayer; // ========= STEP 1: Create a record set by store addresses RecordSetByAddress[] storeAddresses = new RecordSetByAddress[3]; storeAddresses[0] = new RecordSetByAddress(); storeAddresses[0].Name = "pizza1"; storeAddresses[0].Description = "Rush Street Store"; storeAddresses[0].StoreID = "1"; storeAddresses[0].Address = "730 N. Rush St."; storeAddresses[0].City = "Chicago"; storeAddresses[0].State = "IL"; storeAddresses[0].ZIP = "60611"; storeAddresses[1] = new RecordSetByAddress(); storeAddresses[1].Name = "pizza2"; storeAddresses[1].Description = "Clark Street Store"; storeAddresses[1].StoreID = "2"; storeAddresses[1].Address = "2121 N. Clark St."; storeAddresses[1].City = "Chicago"; storeAddresses[1].State = "IL"; storeAddresses[1].ZIP = "60614"; storeAddresses[2] = new RecordSetByAddress(); storeAddresses[2].Name = "pizza3"; storeAddresses[2].Description = "31st Street Store"; storeAddresses[2].StoreID = "3"; storeAddresses[2].Address = "4254 W. 31st St."; storeAddresses[2].City = "Chicago"; storeAddresses[2].State = "IL"; storeAddresses[2].ZIP = "60623"; TaskResultOutput recordSetResult = baServerHelper.CreateRecordSetByAddresses(storeAddresses, esriFolderType.esriFolderStoreLayers); // Create a table from the address record set TableData tableData = new TableData(); tableData.RecordSet = recordSetResult.RecordSet; GeocodeData geocodeData = new GeocodeData(); geocodeData.Table = tableData; // ========= STEP 2: Geocode the record set with stores CustomerStoreSetupByGeocodeTableParameters geocodeParameters = new CustomerStoreSetupByGeocodeTableParameters(); // Set specific analysis parameters geocodeParameters.GeocodeCustomers = false; geocodeParameters.GeocodeData = geocodeData; geocodeParameters.NameField = "NAME"; geocodeParameters.StoreIDField = "STORE_ID"; // Set other parameters imageOptions = null; outputOptions = new TaskOutputType[0]; // Empty output! // In general, a non-null esriFolderItem is specified to save a newly-created // item to the server-side repository or to reference an existing item in it. outputLayer = new esriFolderItem(); outputLayer.folderType = esriFolderType.esriFolderStoreLayers; outputLayer.itemName = "storeLayer_DeleteFeatures"; outputLayer.workspaceName = "Default Workspace"; outputLayer.projectName = "Default Project"; baServerHelper.CustomerStoreSetupByGeocodeTable(geocodeParameters, imageOptions, outputOptions, outputLayer); // ========= STEP 3: Delete features and test that features were deleted // Feature OID values depend on a feature layer workspaces used in repository. // Features created at Step 2 will have either OIDs 0, 1, and 2 // (for shapefile workspace) or 1, 2, and 3 (in other cases). // Anyway, after deleting features with OIDs 1 and 2, only one feature remains. bool deleted = baServerHelper.DeleteFeatures(new int[] { 1, 2 }, outputLayer); TaskResultOutput result = baServerHelper.OpenFeatureLayer(outputLayer); bool featuresDeleted = result.RecordSet.Records.Length == 1; |